From: syzbot <syzbot+4b4093b1f24ad789bf37@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] nilfs2: fix NULL i_assoc_inode dereference in nilfs_mdt_save_to_shadow_map
Date: Mon, 16 Mar 2026 20:40:31 -0700 [thread overview]
Message-ID: <69b8cd2f.050a0220.12d28.0167.GAE@google.com> (raw)
In-Reply-To: <69b8c713.a00a0220.3b25d1.0029.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] nilfs2: fix NULL i_assoc_inode dereference in nilfs_mdt_save_to_shadow_map
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
When nilfs_dat_read() is called a second time during rollback recovery
from a corrupted segment (checksum error), nilfs_iget_locked() returns
a cached DAT inode that is not I_NEW, causing the function to skip
nilfs_mdt_setup_shadow_map(). This leaves i_assoc_inode as NULL in the
DAT inode, which later causes a general protection fault in
nilfs_mdt_save_to_shadow_map() when NILFS_IOCTL_CLEAN_SEGMENTS is
invoked immediately after mount.
Fix this by redirecting the non-I_NEW path to a new reinit_shadow label
that calls nilfs_mdt_setup_shadow_map() if the shadow map has not been
initialized yet, ensuring i_assoc_inode is always valid before the
segment cleaner uses it.
Reported-by: syzbot+4b4093b1f24ad789bf37@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4b4093b1f24ad789bf37
Signed-off-by: Deepanshu Kartikey <Kartikey406@gmail.com>
---
fs/nilfs2/dat.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index 674380837ab9..c0b656e1c4ef 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -507,7 +507,7 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
if (unlikely(!dat))
return -ENOMEM;
if (!(inode_state_read_once(dat) & I_NEW))
- goto out;
+ goto reinit_shadow;
err = nilfs_mdt_init(dat, NILFS_MDT_GFP, sizeof(*di));
if (err)
@@ -529,6 +529,14 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
goto failed;
unlock_new_inode(dat);
+ goto out;
+reinit_shadow:
+ di = NILFS_DAT_I(dat);
+ if (!di->mi.mi_shadow) {
+ err = nilfs_mdt_setup_shadow_map(dat, &di->shadow);
+ if (err)
+ goto failed;
+ }
out:
*inodep = dat;
return 0;
--
2.43.0
next prev parent reply other threads:[~2026-03-17 3:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 3:14 [syzbot] [nilfs?] general protection fault in nilfs_mdt_save_to_shadow_map syzbot
2026-03-17 3:40 ` syzbot [this message]
2026-03-17 4:25 ` Forwarded: [PATCH] nilfs2: fix wrong inode returned from nilfs_iget_for_shadow on cache hit syzbot
2026-03-17 6:25 ` Forwarded: [PATCH] nilfs2: fix missing i_assoc_inode initialization in nilfs_iget_for_shadow syzbot
2026-03-17 6:47 ` Forwarded: [PATCH] nilfs2: fix uninitialized btree node cache in nilfs_attach_btree_node_cache syzbot
2026-03-17 7:36 ` syzbot
2026-03-17 8:09 ` [syzbot] [nilfs?] general protection fault in nilfs_mdt_save_to_shadow_map Edward Adam Davis
2026-03-17 8:41 ` syzbot
2026-03-17 8:26 ` Forwarded: [PATCH] nilfs2: fix NULL i_assoc_inode dereference " syzbot
2026-03-17 8:29 ` [PATCH] nilfs2: no longer save to shadow map if the num of members is too small Edward Adam Davis
2026-03-17 15:13 ` Deepanshu Kartikey
2026-03-17 15:15 ` Deepanshu Kartikey
2026-03-17 16:51 ` Ryusuke Konishi
2026-03-17 23:00 ` Ryusuke Konishi
2026-03-18 0:08 ` Edward Adam Davis
2026-03-18 0:54 ` Ryusuke Konishi
2026-03-18 1:16 ` Edward Adam Davis
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=69b8cd2f.050a0220.12d28.0167.GAE@google.com \
--to=syzbot+4b4093b1f24ad789bf37@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