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: <2a79206d3472b279079fbef5c9507f8805061c47.camel@kernel.org>
Date:   Thu, 09 Dec 2021 06:20:40 -0500
From:   Jeff Layton <jlayton@...nel.org>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>, idryomov@...il.com,
        davem@...emloft.net, kuba@...nel.org
Cc:     ceph-devel@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] libceph, ceph: potential dereference of null pointer

On Thu, 2021-12-09 at 10:50 +0800, Jiasheng Jiang wrote:
> The return value of kzalloc() needs to be checked.
> To avoid use of null pointer in case of the failure of alloc.
> 
> Fixes: 3d14c5d2b6e1 ("ceph: factor out libceph from Ceph file system")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
>  net/ceph/osd_client.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index ff8624a7c964..3203e8a34370 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -1234,6 +1234,8 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
>  	WARN_ON(onum == CEPH_HOMELESS_OSD);
>  
>  	osd = kzalloc(sizeof(*osd), GFP_NOIO | __GFP_NOFAIL);
> +	if (!osd)
> +		return NULL;
>  	osd_init(osd);
>  	osd->o_osdc = osdc;
>  	osd->o_osd = onum;

__GFP_NOFAIL should ensure that it never returns NULL, right?

Also, if you're going to fix this up to handle that error then you
probably also need to fix lookup_create_osd to handle a NULL return from
create_osd as well.
-- 
Jeff Layton <jlayton@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ