From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Horman Subject: Re: [PATCH v2] RDMA: Directly cast the sockaddr union to sockaddr Date: Thu, 16 May 2019 14:44:28 +0200 Message-ID: <20190516124428.hytvkwfltfi24lrv@verge.net.au> References: <20190514005521.GA18085@ziepe.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190514005521.GA18085@ziepe.ca> Sender: linux-kernel-owner@vger.kernel.org To: Jason Gunthorpe Cc: Linus Torvalds , David Miller , Doug Ledford , linux-rdma , Linux List Kernel Mailing , Netdev List-Id: linux-rdma@vger.kernel.org On Mon, May 13, 2019 at 09:55:21PM -0300, Jason Gunthorpe wrote: > 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 > --- > 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(-) > > I missed the ocrdma files in the v1 > > We can revisit what to do with that repetitive union after the merge > window, but this simple patch will eliminate the warnings for now. > > Linus, I'll send this as a PR tomorrow - there is also a bug fix for > the rdma-netlink changes posted that should go too. <2c> I would be very happy to see this revisited in such a way that some use is made of the C type system (instead of casts).