From: Greg Kroah-Hartman Date: Tue, 2 Jul 2019 06:44:13 +0000 (+0200) Subject: 5.1-stable patches X-Git-Tag: v5.1.16~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b928c8df27e4e672b629a9ef70cfdf94a3a93de6;p=thirdparty%2Fkernel%2Fstable-queue.git 5.1-stable patches added patches: rdma-directly-cast-the-sockaddr-union-to-sockaddr.patch --- diff --git a/queue-5.1/rdma-directly-cast-the-sockaddr-union-to-sockaddr.patch b/queue-5.1/rdma-directly-cast-the-sockaddr-union-to-sockaddr.patch new file mode 100644 index 00000000000..25cd8a91351 --- /dev/null +++ b/queue-5.1/rdma-directly-cast-the-sockaddr-union-to-sockaddr.patch @@ -0,0 +1,118 @@ +From 641114d2af312d39ca9bbc2369d18a5823da51c6 Mon Sep 17 00:00:00 2001 +From: Jason Gunthorpe +Date: Sun, 12 May 2019 21:57:57 -0300 +Subject: RDMA: Directly cast the sockaddr union to sockaddr + +From: Jason Gunthorpe + +commit 641114d2af312d39ca9bbc2369d18a5823da51c6 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: Jason Gunthorpe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/infiniband/core/addr.c | 16 ++++++++-------- + drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 5 ++--- + drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 ++--- + 3 files changed, 12 insertions(+), 14 deletions(-) + +--- a/drivers/infiniband/core/addr.c ++++ b/drivers/infiniband/core/addr.c +@@ -730,8 +730,8 @@ int roce_resolve_route_from_path(struct + if (rec->roce.route_resolved) + return 0; + +- rdma_gid2ip(&sgid._sockaddr, &rec->sgid); +- rdma_gid2ip(&dgid._sockaddr, &rec->dgid); ++ rdma_gid2ip((struct sockaddr *)&sgid, &rec->sgid); ++ rdma_gid2ip((struct sockaddr *)&dgid, &rec->dgid); + + if (sgid._sockaddr.sa_family != dgid._sockaddr.sa_family) + return -EINVAL; +@@ -742,7 +742,7 @@ int roce_resolve_route_from_path(struct + dev_addr.net = &init_net; + dev_addr.sgid_attr = attr; + +- ret = addr_resolve(&sgid._sockaddr, &dgid._sockaddr, ++ ret = addr_resolve((struct sockaddr *)&sgid, (struct sockaddr *)&dgid, + &dev_addr, false, true, 0); + if (ret) + return ret; +@@ -814,22 +814,22 @@ int rdma_addr_find_l2_eth_by_grh(const u + struct rdma_dev_addr dev_addr; + struct resolve_cb_context ctx; + union { +- struct sockaddr _sockaddr; + struct sockaddr_in _sockaddr_in; + struct sockaddr_in6 _sockaddr_in6; + } sgid_addr, dgid_addr; + int ret; + +- rdma_gid2ip(&sgid_addr._sockaddr, sgid); +- rdma_gid2ip(&dgid_addr._sockaddr, dgid); ++ rdma_gid2ip((struct sockaddr *)&sgid_addr, sgid); ++ rdma_gid2ip((struct sockaddr *)&dgid_addr, dgid); + + memset(&dev_addr, 0, sizeof(dev_addr)); + dev_addr.net = &init_net; + dev_addr.sgid_attr = sgid_attr; + + init_completion(&ctx.comp); +- ret = rdma_resolve_ip(&sgid_addr._sockaddr, &dgid_addr._sockaddr, +- &dev_addr, 1000, resolve_cb, true, &ctx); ++ ret = rdma_resolve_ip((struct sockaddr *)&sgid_addr, ++ (struct sockaddr *)&dgid_addr, &dev_addr, 1000, ++ resolve_cb, true, &ctx); + if (ret) + return ret; + +--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c ++++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c +@@ -83,7 +83,6 @@ static inline int set_av_attr(struct ocr + struct iphdr ipv4; + const struct ib_global_route *ib_grh; + union { +- struct sockaddr _sockaddr; + struct sockaddr_in _sockaddr_in; + struct sockaddr_in6 _sockaddr_in6; + } sgid_addr, dgid_addr; +@@ -133,9 +132,9 @@ static inline int set_av_attr(struct ocr + ipv4.tot_len = htons(0); + ipv4.ttl = ib_grh->hop_limit; + ipv4.protocol = nxthdr; +- rdma_gid2ip(&sgid_addr._sockaddr, sgid); ++ rdma_gid2ip((struct sockaddr *)&sgid_addr, sgid); + ipv4.saddr = sgid_addr._sockaddr_in.sin_addr.s_addr; +- rdma_gid2ip(&dgid_addr._sockaddr, &ib_grh->dgid); ++ rdma_gid2ip((struct sockaddr*)&dgid_addr, &ib_grh->dgid); + ipv4.daddr = dgid_addr._sockaddr_in.sin_addr.s_addr; + memcpy((u8 *)ah->av + eth_sz, &ipv4, sizeof(struct iphdr)); + } else { +--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c ++++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +@@ -2499,7 +2499,6 @@ static int ocrdma_set_av_params(struct o + u32 vlan_id = 0xFFFF; + u8 mac_addr[6], hdr_type; + union { +- struct sockaddr _sockaddr; + struct sockaddr_in _sockaddr_in; + struct sockaddr_in6 _sockaddr_in6; + } sgid_addr, dgid_addr; +@@ -2541,8 +2540,8 @@ static int ocrdma_set_av_params(struct o + + hdr_type = rdma_gid_attr_network_type(sgid_attr); + if (hdr_type == RDMA_NETWORK_IPV4) { +- rdma_gid2ip(&sgid_addr._sockaddr, &sgid_attr->gid); +- rdma_gid2ip(&dgid_addr._sockaddr, &grh->dgid); ++ rdma_gid2ip((struct sockaddr *)&sgid_addr, &sgid_attr->gid); ++ rdma_gid2ip((struct sockaddr *)&dgid_addr, &grh->dgid); + memcpy(&cmd->params.dgid[0], + &dgid_addr._sockaddr_in.sin_addr.s_addr, 4); + memcpy(&cmd->params.sgid[0], diff --git a/queue-5.1/series b/queue-5.1/series index c0269c12f80..a55763fc03e 100644 --- a/queue-5.1/series +++ b/queue-5.1/series @@ -50,3 +50,4 @@ bpf-udp-ipv6-avoid-running-reuseport-s-bpf_prog-from-__udp6_lib_err.patch arm64-futex-avoid-copying-out-uninitialised-stack-in-failed-cmpxchg.patch bpf-arm64-use-more-scalable-stadd-over-ldxr-stxr-loop-in-xadd.patch futex-update-comments-and-docs-about-return-values-of-arch-futex-code.patch +rdma-directly-cast-the-sockaddr-union-to-sockaddr.patch