[v2,06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
Message ID | 20240122223230.4000595-7-dhowells@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:805:b0:101:a8e8:374 with SMTP id e5csp41101dyi; Mon, 22 Jan 2024 14:37:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/GYqFJzROFs2OqHL6NFYlKT7bZAT1ch/FfOpSMv0sJHFFjxGG8n7sfrZq02QWkjQIFXBV X-Received: by 2002:a17:903:32ce:b0:1d7:199:cfa8 with SMTP id i14-20020a17090332ce00b001d70199cfa8mr6388790plr.10.1705963067868; Mon, 22 Jan 2024 14:37:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705963067; cv=pass; d=google.com; s=arc-20160816; b=pV4oBntyVC4bU3FqRzAoOJ6/IrRc6O/ss8TeayYDABqbZvJwhPy51TULpAsYo1bH63 5HnMuFL6/Z0grgosHHwpe2yPTA2vDa6N/nPiuQnX5l/t2lHcodv4Vf+oBAByDycGTDYN S+aW1z18UMpAJWBYapQVofgf3jqd/QDlXfubeukHGtQLS2+vvKslQb/mKClAsqpM624L IFWyYwxvv8759XIn+rtYFT1GNq/OYTLDwHQayTYzU7g1S8f80ezBXrEINMijEfQq10Iu X7HghzSm6wtzFwjmm7Y8j+JfMLaqlX1rgUHDDhKCR9c2OKCrzbm2Jkyq8EP1XOUvCHPF ZY2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XRe99Wj+tzBNI3ZsVZlJ7dd6pgKPiqDyuDCv0Ih9868=; fh=+2KVsuS3QQLhBtnZbdoLaJ8xs7SIeHL/Neowe1JxX6s=; b=XjfBTepnTYSYImXyrpAtC3GtNlx7/Jx6PPlBe4+pANOWnxcBUOgzCsZ4P7GKbKCQCQ mHLz+ByApkBhfKsUeVqur+Ttxe7EW1OSPvir1BQTRZjGAADWr4/kpIO8/6h0XAreOuFL /b0LVdxh8Aix1G0SuQx5Gi4/uNqFH//roAAbbsfhbSbwaZKyx9g4k7rwllgbyaITTVss O7QGPN1siCOQQKW+5HQYjsw3DhR9cwCOQg947w6oF0ZiNxYr4vRwabE30IK+Gn8NupZn PambHBR3Ug3ivX4zkY7r9vvAH+Vqz80tPJkNf+u/n9DLITS3M0Xi3kiVeWnRNlSiKMQ9 Uoyw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AshfL+Xq; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d18-20020a170902aa9200b001d3fbe6900dsi8350677plr.622.2024.01.22.14.37.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:37:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AshfL+Xq; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34246-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 450FDB22C97 for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 22:36:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 697F24BA9D; Mon, 22 Jan 2024 22:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AshfL+Xq" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DC1E4B5AB for <linux-kernel@vger.kernel.org>; Mon, 22 Jan 2024 22:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705962778; cv=none; b=bi/otVFdbNh0nKjRCrvIsCBty6hKTWQSqg98HFT7zr56xd06YSW/dq9JuO1q//YxAthk/QxUDBu18RzgP6FJW38Sk+gFCbtj1+Z+Um7CHBDBwDdKZSbBw4RbpiBZC2yCMOsYM5iDxOKySOMLnZvyTGG23pzxm9bjHQoUB/Ke0U8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705962778; c=relaxed/simple; bh=WkDohQJAiOIl1Ft4waaOXjoJcWWnF6gbh1qSMCNZIGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MBypj1SwP+unXrO0AmFddFQs9n1fT3XWu5o9N8WxFSGG7usp4WaBfStrufg5dtm5xLrI+Eh9DNzrX6PGzUf09uwYXRR70bqzdp5NBaL9kZYJEr7lV8/xCfmYSiDMUFx58c2pcnaFzgZtb0tc1Z8sYKXxfkjLxeFkDDQgUIzpFcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AshfL+Xq; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XRe99Wj+tzBNI3ZsVZlJ7dd6pgKPiqDyuDCv0Ih9868=; b=AshfL+XqYELkK8n7DtRv8201tXTWU8DEhiKjfFN5hsyvbYgXkTn7+b1vUoRIowJKT5yVE2 Y+OMCX5+xIUqZjLD7gvCdrq/Jrz6pprsOZPptz9Rs4rXo+ledjPdqKF9bQmjfQ/6L6RNjF A7zTn5QILzJ1/YvYAHwMfTz719/yLsk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-XfsFasc1N_mUuQUWqPtJ_w-1; Mon, 22 Jan 2024 17:32:52 -0500 X-MC-Unique: XfsFasc1N_mUuQUWqPtJ_w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C97C1C04184; Mon, 22 Jan 2024 22:32:51 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66B69C0FDCA; Mon, 22 Jan 2024 22:32:48 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Christian Brauner <christian@brauner.io> Cc: David Howells <dhowells@redhat.com>, 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>, Jeffle Xu <jefflexu@linux.alibaba.com> Subject: [PATCH v2 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode Date: Mon, 22 Jan 2024 22:32:19 +0000 Message-ID: <20240122223230.4000595-7-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788831929383300806 X-GMAIL-MSGID: 1788831929383300806 |
Series |
netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes
|
|
Commit Message
David Howells
Jan. 22, 2024, 10:32 p.m. UTC
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