lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220517180303.GK63055@ziepe.ca>
Date:   Tue, 17 May 2022 15:03:03 -0300
From:   Jason Gunthorpe <jgg@...pe.ca>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Haowen Bai <baihaowen@...zu.com>,
        Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
        Leon Romanovsky <leon@...nel.org>, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RDMA: remove null check after call container_of()

On Tue, May 17, 2022 at 07:54:38PM +0200, Christophe JAILLET wrote:
> Le 17/05/2022 à 14:16, Jason Gunthorpe a écrit :
> > On Tue, May 17, 2022 at 09:33:28AM +0800, Haowen Bai wrote:
> > > container_of() will never return NULL, so remove useless code.
> > 
> > It is confusing here, but it can be null.
> 
> Hi,
> 
> out of curiosity, can you elaborate how it can be NULL?

It is guarented/required that that container_of is a 0 offset. The
normal usage of the ib_alloc_device macro:

#define ib_alloc_device(drv_struct, member)                                    \
	container_of(_ib_alloc_device(sizeof(struct drv_struct) +              \
				      BUILD_BUG_ON_ZERO(offsetof(              \
					      struct drv_struct, member))),    \
		     struct drv_struct, member)

Enforces this property with a BUILD_BUG_ON

So, if the input pointer to container_of is reliably NULL or ERR_PTR
then the output pointer will be the same.

The rvt code here open codes the call because it is a mid-layer and
the sizeof() calculation above is not correct for it.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ