From: syzbot <syzbot+675e84fdf3dde67b4946@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] jffs2: fix double-free of f->target in jffs2_alloc_inode()
Date: Sun, 23 Aug 2026 07:52:30 -0700 [thread overview]
Message-ID: <6a8b092e.dbb3a75c.13dd47.004f.GAE@google.com> (raw)
In-Reply-To: <6a8af6b0.ae6ddae5.3da009.0066.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] jffs2: fix double-free of f->target in jffs2_alloc_inode()
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
jffs2_alloc_inode() does not initialize f->target before returning
the new inode. It is normally cleared later by
jffs2_init_inode_info(), called from jffs2_iget(), but that runs
only after alloc_inode() has already returned successfully.
If inode_init_always() fails in between, alloc_inode() calls
->free_inode() directly on the half-initialized inode.
jffs2_free_inode() then does kfree(f->target) on whatever stale
value was left in the reused slab object, which can be a pointer
that was already freed, causing a double-free.
Initialize f->target to NULL in jffs2_alloc_inode() to close this
window.
Reported-by: syzbot+675e84fdf3dde67b4946@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=675e84fdf3dde67b4946
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
fs/jffs2/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 81396a092ba8..3c32d5c776e1 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -42,6 +42,7 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)
f = alloc_inode_sb(sb, jffs2_inode_cachep, GFP_KERNEL);
if (!f)
return NULL;
+ f->target = NULL;
return &f->vfs_inode;
}
--
2.34.1
prev parent reply other threads:[~2026-08-23 14:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 13:33 [syzbot] [jffs2?] KASAN: invalid-free in jffs2_free_inode syzbot
2026-08-23 14:52 ` syzbot [this message]
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=6a8b092e.dbb3a75c.13dd47.004f.GAE@google.com \
--to=syzbot+675e84fdf3dde67b4946@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.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