Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbdGaPdC (ORCPT ); Mon, 31 Jul 2017 11:33:02 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12524 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbdGaPdA (ORCPT ); Mon, 31 Jul 2017 11:33:00 -0400 X-IronPort-AV: E=Sophos;i="5.40,442,1496073600"; d="scan'208";a="39024214" From: Bart Van Assche To: "monis@mellanox.com" , "arnd@arndb.de" CC: "linux-kernel@vger.kernel.org" , "keescook@chromium.org" , "linux-rdma@vger.kernel.org" , "parav@mellanox.com" , "Michal.Kalderon@cavium.com" , Bart Van Assche , "sean.hefty@intel.com" , "danielmicay@gmail.com" , "Ariel.Elior@cavium.com" , "hal.rosenstock@gmail.com" , "davem@davemloft.net" , "dledford@redhat.com" , "noaos@mellanox.com" Subject: Re: [PATCH] infiniband: avoid overflow warning Thread-Topic: [PATCH] infiniband: avoid overflow warning Thread-Index: AQHTCclSAgfpevQT8ke8UGOQKFNr46JthC8AgAAF7gCAAIaagA== Date: Mon, 31 Jul 2017 15:32:00 +0000 Message-ID: <1501515117.2466.9.camel@wdc.com> References: <20170731065016.2947796-1-arnd@arndb.de> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1535;20:dpaWfmaoenw1+Gx9qFbXJHdSga/Di+FJicEpPyy9NEhgVTvGesGmlc+51wimn2mEto6E5uEQIyfHVDx0Na0WnVKsMX85JYXnx39EwmNqhDQ7qWfbsjgFBi1izZkJl4FjY1/sdUP+5CGcdy3wF1nw9XBePFV1Y1qtezTZ/4bEx98= x-ms-office365-filtering-correlation-id: adaed8f8-09fa-4eee-3e3f-08d4d8294962 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR0401MB1535; x-ms-traffictypediagnostic: CY1PR0401MB1535: wdcipoutbound: EOP-TRUE x-exchange-antispam-report-test: UriScan:(788757137089); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR0401MB1535;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR0401MB1535; x-forefront-prvs: 03853D523D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39840400002)(39860400002)(39410400002)(39400400002)(39850400002)(39450400003)(199003)(189002)(24454002)(377424004)(377454003)(2900100001)(7736002)(6436002)(97736004)(6486002)(229853002)(77096006)(6506006)(54356999)(76176999)(50986999)(103116003)(33646002)(25786009)(53936002)(53546010)(39060400002)(6246003)(38730400002)(4326008)(101416001)(105586002)(106356001)(3846002)(102836003)(189998001)(14454004)(8936002)(3660700001)(54906002)(305945005)(99286003)(2501003)(5660300001)(8676002)(81166006)(81156014)(66066001)(6116002)(2906002)(3280700002)(72206003)(86362001)(68736007)(2950100002)(6512007)(7416002)(478600001)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1535;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-ID: <8D3E85DACC6D504DBC4E86D0A80AF622@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2017 15:32:00.0797 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1535 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v6VFX9Au013427 Content-Length: 2134 Lines: 48 On Mon, 2017-07-31 at 09:30 +0200, Arnd Bergmann wrote: > On Mon, Jul 31, 2017 at 9:08 AM, Moni Shoua wrote: > > On Mon, Jul 31, 2017 at 9:50 AM, Arnd Bergmann wrote: > > > --- 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; > > > > what happens if you replace 16 with sizeof(struct in6_addr)? > > Same thing: the problem is that gcc already knows the size of the structure we > pass in here, and it is in fact shorter. > > I also tried changing the struct sockaddr pointer to a sockaddr_storage pointer, > without success. Other approaches that do work are: > > - mark addr_event() as "noinline" to prevent gcc from seeing the true > size of the > inetaddr_event stack object in rdma_ip2gid(). I considered this a little ugly. > > - change inetaddr_event to put a larger structure on the stack, using > sockaddr_storage or sockaddr_in6. This would be less efficient. > > - define a union of sockaddr_in and sockaddr_in6, and use that as the argument > to rdma_ip2gid/rdma_gid2ip, and change all callers to use that union type. > This is probably the cleanest approach as it gets rid of a lot of questionable > type casts, but it's a relatively large patch and also slightly less > efficient as we have > to zero more stack storage in some cases. Hello Arnd, So inetaddr_event() assigns AF_INET so .sin_family and gcc warns about code that is only executed if .sin_family == AF_INET6? Since this warning is the result of incorrect interprocedural analysis by gcc, shouldn't this be reported as a bug to the gcc authors? Thanks, Bart.