Commit 6548558f authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Khalid Elmously

RDMA: Directly cast the sockaddr union to sockaddr

BugLink: https://bugs.launchpad.net/bugs/1845038

commit 641114d2 upstream.

gcc 9 now does allocation size tracking and thinks that passing the member
of a union and then accessing beyond that member's bounds is an overflow.

Instead of using the union member, use the entire union with a cast to
get to the sockaddr. gcc will now know that the memory extends the full
size of the union.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 53dd4af3
...@@ -481,14 +481,13 @@ int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgi ...@@ -481,14 +481,13 @@ int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgi
struct net_device *dev; struct net_device *dev;
union { union {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in; struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6; struct sockaddr_in6 _sockaddr_in6;
} sgid_addr, dgid_addr; } sgid_addr, dgid_addr;
rdma_gid2ip(&sgid_addr._sockaddr, sgid); rdma_gid2ip((struct sockaddr *)&sgid_addr, sgid);
rdma_gid2ip(&dgid_addr._sockaddr, dgid); rdma_gid2ip((struct sockaddr *)&dgid_addr, dgid);
memset(&dev_addr, 0, sizeof(dev_addr)); memset(&dev_addr, 0, sizeof(dev_addr));
dev_addr.bound_dev_if = if_index; dev_addr.bound_dev_if = if_index;
...@@ -496,8 +495,9 @@ int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgi ...@@ -496,8 +495,9 @@ int rdma_addr_find_dmac_by_grh(const union ib_gid *sgid, const union ib_gid *dgi
ctx.addr = &dev_addr; ctx.addr = &dev_addr;
init_completion(&ctx.comp); init_completion(&ctx.comp);
ret = rdma_resolve_ip(&self, &sgid_addr._sockaddr, &dgid_addr._sockaddr, ret = rdma_resolve_ip(&self, (struct sockaddr *)&sgid_addr,
&dev_addr, 1000, resolve_cb, &ctx); (struct sockaddr *)&dgid_addr, &dev_addr, 1000,
resolve_cb, &ctx);
if (ret) if (ret)
return ret; return ret;
...@@ -519,16 +519,15 @@ int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id) ...@@ -519,16 +519,15 @@ int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id)
int ret = 0; int ret = 0;
struct rdma_dev_addr dev_addr; struct rdma_dev_addr dev_addr;
union { union {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in; struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6; struct sockaddr_in6 _sockaddr_in6;
} gid_addr; } gid_addr;
rdma_gid2ip(&gid_addr._sockaddr, sgid); rdma_gid2ip((struct sockaddr *)&gid_addr, sgid);
memset(&dev_addr, 0, sizeof(dev_addr)); memset(&dev_addr, 0, sizeof(dev_addr));
dev_addr.net = &init_net; dev_addr.net = &init_net;
ret = rdma_translate_ip(&gid_addr._sockaddr, &dev_addr, vlan_id); ret = rdma_translate_ip((struct sockaddr *)&gid_addr, &dev_addr, vlan_id);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment