From: Shuai Liu <847807867@qq.com>
To: linux-mtd@lists.infradead.org
Cc: richard@nod.at,
syzbot+3a8099322b09d8d073d1@syzkaller.appspotmail.com,
luquijeffrey@gmail.com, linux-kernel@vger.kernel.org,
Shuai Liu <847807867@qq.com>
Subject: [PATCH] jffs2: initialize f->inocache to NULL in jffs2_init_inode_info()
Date: Tue, 3 Nov 2026 11:26:47 +0800 [thread overview]
Message-ID: <tencent_A21BAE90D8EE04A5FB98B4168BA73C695306@qq.com> (raw)
new_inode() can hand back a jffs2_inode_info recycled from slab with a
stale f->inocache still pointing to a jffs2_inode_cache that was freed
by a previous mount's jffs2_free_ino_caches(). jffs2_init_inode_info()
initialises every other pointer field but leaves f->inocache untouched.
If jffs2_new_inode() then fails before jffs2_do_new_inode() assigns a
fresh f->inocache -- e.g. in jffs2_init_acl_pre() -- the error path does
make_bad_inode() + iput(), and evict() ends up calling
jffs2_xattr_delete_inode() which dereferences the stale pointer when
reading ic->pino_nlink, causing a slab-use-after-free:
BUG: KASAN: slab-use-after-free in jffs2_xattr_delete_inode
Read of size 4 at addr ... by task repro
jffs2_xattr_delete_inode
jffs2_do_clear_inode
evict
jffs2_new_inode
jffs2_mkdir
Allocated by jffs2_scan_make_ino_cache (jffs2_do_mount_fs)
Freed by jffs2_free_ino_caches (jffs2_put_super)
Fix by clearing f->inocache in jffs2_init_inode_info(), consistent with
the other pointer fields there. Verified with the syzbot C reproducer
under QEMU with KASAN: the UAF is reported before the patch and absent
after it.
Originally proposed by Lucas Jeffrey <luquijeffrey@gmail.com>
(Link: https://lore.kernel.org/all/20260909023955.1642244-1-luquijeffrey@gmail.com/);
that thread has seen no activity since September 10 while the bug is
still reproducing upstream, so resubmitting with his credit.
Reported-by: syzbot+3a8099322b09d8d073d1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3a8099322b09d8d073d1
Suggested-by: Lucas Jeffrey <luquijeffrey@gmail.com>
Signed-off-by: Shuai Liu <847807867@qq.com>
---
fs/jffs2/os-linux.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index bff2134d771d..e80b786c9ea2 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -55,6 +55,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
f->metadata = NULL;
f->dents = NULL;
f->target = NULL;
+ f->inocache = NULL;
f->flags = 0;
f->usercompr = 0;
}
--
2.43.0
reply other threads:[~2026-11-03 3:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tencent_A21BAE90D8EE04A5FB98B4168BA73C695306@qq.com \
--to=847807867@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=luquijeffrey@gmail.com \
--cc=richard@nod.at \
--cc=syzbot+3a8099322b09d8d073d1@syzkaller.appspotmail.com \
/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
all inboxes | Powered by JetHome®