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: <7790423f-665e-44cc-b4ae-d3f3d2996af5@linux.alibaba.com>
Date: Mon, 22 Jan 2024 21:48:23 +0800
From: Jingbo Xu <jefflexu@...ux.alibaba.com>
To: David Howells <dhowells@...hat.com>,
 Christian Brauner <christian@...uner.io>
Cc: Jeff Layton <jlayton@...nel.org>, Matthew Wilcox <willy@...radead.org>,
 netfs@...ts.linux.dev, linux-afs@...ts.infradead.org,
 linux-cifs@...r.kernel.org, linux-nfs@...r.kernel.org,
 ceph-devel@...r.kernel.org, v9fs@...ts.linux.dev,
 linux-erofs@...ts.ozlabs.org, linux-fsdevel@...r.kernel.org,
 linux-mm@...ck.org, linux-kernel@...r.kernel.org,
 Marc Dionne <marc.dionne@...istor.com>, Gao Xiang <xiang@...nel.org>,
 Chao Yu <chao@...nel.org>, Yue Hu <huyue2@...lpad.com>
Subject: Re: [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when
 cachefiles is not doing ondemand-mode



On 1/22/24 8:38 PM, David Howells wrote:
> cachefiles_ondemand_init_object() as called from cachefiles_open_file() and
> cachefiles_create_tmpfile() does not check if object->ondemand is set
> before dereferencing it, leading to an oops something like:
> 
> 	RIP: 0010:cachefiles_ondemand_init_object+0x9/0x41
> 	...
> 	Call Trace:
> 	 <TASK>
> 	 cachefiles_open_file+0xc9/0x187
> 	 cachefiles_lookup_cookie+0x122/0x2be
> 	 fscache_cookie_state_machine+0xbe/0x32b
> 	 fscache_cookie_worker+0x1f/0x2d
> 	 process_one_work+0x136/0x208
> 	 process_scheduled_works+0x3a/0x41
> 	 worker_thread+0x1a2/0x1f6
> 	 kthread+0xca/0xd2
> 	 ret_from_fork+0x21/0x33
> 
> Fix this by making the calls to cachefiles_ondemand_init_object()
> conditional.
> 
> Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object")
> Reported-by: Marc Dionne <marc.dionne@...istor.com>
> Signed-off-by: David Howells <dhowells@...hat.com>
> cc: Gao Xiang <xiang@...nel.org>
> cc: Chao Yu <chao@...nel.org>
> cc: Yue Hu <huyue2@...lpad.com>
> cc: Jeffle Xu <jefflexu@...ux.alibaba.com>
> cc: linux-erofs@...ts.ozlabs.org
> cc: netfs@...ts.linux.dev
> cc: linux-fsdevel@...r.kernel.org
> ---
>  fs/cachefiles/namei.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
> index 7ade836beb58..180594d24c44 100644
> --- a/fs/cachefiles/namei.c
> +++ b/fs/cachefiles/namei.c
> @@ -473,9 +473,11 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
>  	if (!cachefiles_mark_inode_in_use(object, file_inode(file)))
>  		WARN_ON(1);
>  
> -	ret = cachefiles_ondemand_init_object(object);
> -	if (ret < 0)
> -		goto err_unuse;
> +	if (object->ondemand) {
> +		ret = cachefiles_ondemand_init_object(object);
> +		if (ret < 0)
> +			goto err_unuse;
> +	}

I'm not sure if object->ondemand shall be checked by the caller or
inside cachefiles_ondemand_init_object(), as
cachefiles_ondemand_clean_object() is also called without checking
object->ondemand. cachefiles_ondemand_clean_object() won't trigger the
NULL oops as the called cachefiles_ondemand_send_req() will actually
checks that.

Anyway this patch looks good to me.  Thanks.

Reviewed-by: Jingbo Xu <jefflexu@...ux.alibaba.com>

>  
>  	ni_size = object->cookie->object_size;
>  	ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE);
> @@ -579,9 +581,11 @@ static bool cachefiles_open_file(struct cachefiles_object *object,
>  	}
>  	_debug("file -> %pd positive", dentry);
>  
> -	ret = cachefiles_ondemand_init_object(object);
> -	if (ret < 0)
> -		goto error_fput;
> +	if (object->ondemand) {
> +		ret = cachefiles_ondemand_init_object(object);
> +		if (ret < 0)
> +			goto error_fput;
> +	}
>  
>  	ret = cachefiles_check_auxdata(object, file);
>  	if (ret < 0)

-- 
Thanks,
Jingbo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ