From patchwork Mon Jul 31 06:50:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9871053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6269F6038F for ; Mon, 31 Jul 2017 06:51:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B00B2859A for ; Mon, 31 Jul 2017 06:51:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E2B2285A8; Mon, 31 Jul 2017 06:51:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB6D2859A for ; Mon, 31 Jul 2017 06:50:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750977AbdGaGux (ORCPT ); Mon, 31 Jul 2017 02:50:53 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:49690 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbdGaGux (ORCPT ); Mon, 31 Jul 2017 02:50:53 -0400 Received: from wuerfel.lan ([78.43.238.10]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MEF9E-1dMhNg0els-00FPGz; Mon, 31 Jul 2017 08:50:24 +0200 From: Arnd Bergmann To: Doug Ledford , Sean Hefty , Hal Rosenstock Cc: Arnd Bergmann , Daniel Micay , Kees Cook , Moni Shoua , "Kalderon, Michal" , Ariel Elior , "David S. Miller" , Bart Van Assche , Parav Pandit , Noa Osherovich , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] infiniband: avoid overflow warning Date: Mon, 31 Jul 2017 08:50:05 +0200 Message-Id: <20170731065016.2947796-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:KGXeKAm2tRL1E2Ix9xq7+4GJhB/7JU15jfai6KsxE7lYyLYT+ev HnoYwJurYSu79krMtsjyz/l+Dj2q27mO8As+R6oZrT0yrMEtxLmIKFF5Eo9iaPk0uKGC8VP Hp9RoQydggTU8EtFDi7O+SR5dD4WNbg9dUkhHVcn7N2PSei0IXRccrVu40gyKxOG9Sm/GEH GiCAOjPj2KQRdlg2tbdIQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:IxMhYnU1sKU=:2x/Kp93ZsS+ZByf2FwXYej zSFaKECEU3x0fpOqJIm7dt2Gqef3ZfMBTqoi0597MwW4TbQT37FNlqx30MnxXeOXYVyZW522u gSmI4WOHbqKrULHIMhHyAp9NcHcdL5T1puAw+G+zN+DFSP75t371JNOBpas5wELoskCxgJMWz s+0CkwPQ+HIL8no3utxQtuSVLNRr5msJeVSXMqC3Dhhiy5mcgYdZnAkDCqJG522wdE/u4tS39 kcNLr0LFimoinwXMtZuld6Phqt7VfOYphLe/d46AvlCVTaPcd96JgTHNszUznNpTDNl3Ol4db wNYXS79UN8obvn6Yvm19HrJVAYRAp5u3ztjwcmtBwU93fD3U2Y6fh+F1vhiL6cymHpaymBDwz 6Q207HPLdecIHk86AUdOfDziw1JdYWqWC+CyglR6cpGRer2PkhhHeDgm/yeYr7PCYRHbSgXPH e4xRy1afat4wQktyiXx0V2BGcLyeFtFHs+9GFDGD9w0rKQ0tqv4DrLUS3jev8mSrsi7Mmajqb hkf10nGnJmYZC+jqRIL+QWZlSOB9QdeYNvmjPfHY+wQ5V70mvacWOUrgRfzE4EPRt+W4UYqxj VK1JGVOwGzUtfB+0kt92d2VOGAzFFCtPyH2YPL3Jtck6lDV09UqFEyV+MdV3Ft/N3ZYAfZ/ca lXeC/aWb0Q0Xarfz9n1hHEPnPLCOXMsTMJ7Vp0TrzrW9gKwwznnO1m/p8n+cEWWd7FRWKFWZX kp3nHxmYWgq4Ntkzs2z+AyeqUJ8/bB/PS/g41g== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A sockaddr_in structure on the stack getting passed into rdma_ip2gid triggers this warning, since we memcpy into a larger sockaddr_in6 structure: In function 'memcpy', inlined from 'rdma_ip2gid' at include/rdma/ib_addr.h:175:3, inlined from 'addr_event.isra.4.constprop' at drivers/infiniband/core/roce_gid_mgmt.c:693:2, inlined from 'inetaddr_event' at drivers/infiniband/core/roce_gid_mgmt.c:716:9: include/linux/string.h:305:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter The warning seems appropriate here, but the code is also clearly correct, so we really just want to shut up this instance of the output. The best way I found so far is to avoid the memcpy() call and instead replace it with a struct assignment. Fixes: 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions") Cc: Daniel Micay Cc: Kees Cook Signed-off-by: Arnd Bergmann --- include/rdma/ib_addr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index 7aca12188ef3..ec5008cf5d51 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -172,7 +172,8 @@ static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid) (struct in6_addr *)gid); break; case AF_INET6: - memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16); + *(struct in6_addr *)&gid->raw = + ((struct sockaddr_in6 *)addr)->sin6_addr; break; default: return -EINVAL;