CEPH-Devel archive mirror
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: David Howells <dhowells@redhat.com>,
	Christian Brauner <christian@brauner.io>
Cc: Jeff Layton <jlayton@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	netfs@lists.linux.dev, linux-afs@lists.infradead.org,
	linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org,
	ceph-devel@vger.kernel.org, v9fs@lists.linux.dev,
	linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Marc Dionne <marc.dionne@auristor.com>,
	Gao Xiang <xiang@kernel.org>, Chao Yu <chao@kernel.org>,
	Yue Hu <huyue2@coolpad.com>
Subject: Re: [PATCH v2 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
Date: Tue, 23 Jan 2024 09:32:56 +0800	[thread overview]
Message-ID: <9bbf3d38-71bd-49c0-9148-6066420d1d91@linux.alibaba.com> (raw)
In-Reply-To: <20240122223230.4000595-7-dhowells@redhat.com>



On 1/23/24 6:32 AM, 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 cachefiles_ondemand_init_object() return immediately if
> cachefiles->ondemand is NULL.
> 
> Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object")
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Gao Xiang <xiang@kernel.org>
> cc: Chao Yu <chao@kernel.org>
> cc: Yue Hu <huyue2@coolpad.com>
> cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> cc: linux-erofs@lists.ozlabs.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
> ---
> 
> Notes:
>     Changes
>     =======
>     ver #2)
>      - Move check of object->ondemand into cachefiles_ondemand_init_object()
> 
>  fs/cachefiles/ondemand.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c
> index 5fd74ec60bef..4ba42f1fa3b4 100644
> --- a/fs/cachefiles/ondemand.c
> +++ b/fs/cachefiles/ondemand.c
> @@ -539,6 +539,9 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object)
>  	struct fscache_volume *volume = object->volume->vcookie;
>  	size_t volume_key_size, cookie_key_size, data_len;
>  
> +	if (!object->ondemand)
> +		return 0;
> +
>  	/*
>  	 * CacheFiles will firstly check the cache file under the root cache
>  	 * directory. If the coherency check failed, it will fallback to


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

-- 
Thanks,
Jingbo

  reply	other threads:[~2024-01-23  1:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 22:32 [PATCH v2 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
2024-01-22 22:32 ` [PATCH v2 01/10] netfs: Don't use certain unnecessary folio_*() functions David Howells
2024-01-22 22:32 ` [PATCH v2 02/10] afs: " David Howells
2024-01-22 22:32 ` [PATCH v2 03/10] cifs: " David Howells
2024-01-22 22:32 ` [PATCH v2 04/10] netfs, fscache: Prevent Oops in fscache_put_cache() David Howells
2024-01-22 22:32 ` [PATCH v2 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() David Howells
2024-01-22 22:32 ` [PATCH v2 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
2024-01-23  1:32   ` Jingbo Xu [this message]
2024-01-22 22:32 ` [PATCH v2 07/10] afs: Hide silly-rename files from userspace David Howells
2024-01-22 22:32 ` [PATCH v2 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus David Howells
2024-01-22 22:32 ` [PATCH v2 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant David Howells
2024-01-22 22:32 ` [PATCH v2 10/10] afs: Fix missing/incorrect unlocking of RCU read lock David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bbf3d38-71bd-49c0-9148-6066420d1d91@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chao@kernel.org \
    --cc=christian@brauner.io \
    --cc=dhowells@redhat.com \
    --cc=huyue2@coolpad.com \
    --cc=jlayton@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netfs@lists.linux.dev \
    --cc=v9fs@lists.linux.dev \
    --cc=willy@infradead.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).