From: syzbot <syzbot+12479ae15958fc3f54ec@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH v1] fs: Move might_sleep() annotation to iput_final()
Date: Wed, 05 Nov 2025 11:38:06 -0800 [thread overview]
Message-ID: <690ba79e.050a0220.3d0d33.008a.GAE@google.com> (raw)
In-Reply-To: <68d32659.a70a0220.4f78.0012.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH v1] fs: Move might_sleep() annotation to iput_final()
Author: mic@digikod.net
iput() don't directly call any sleepable code but mostly checks flags
and decrement a reference counter before calling iput_final() and then
evict().
Some code might call iput() with guarantees that iput_final() will not
be called. This is the case for Landlock's hook_sb_delete() where the
inode counter must de decremented while holding it with another
reference, see comment above the first iput() call.
Move the new might_sleep() call from iput() to iput_final(). The
alternative would be to manually decrement the counter without calling
iput(), but it doesn't seem right.
Cc: Christian Brauner <brauner@kernel.org>
Cc: Edward Adam Davis <eadavis@qq.com>
Cc: Günther Noack <gnoack@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Max Kellermann <max.kellermann@ionos.com>
Cc: Tingmao Wang <m@maowtm.org>
Reported-by: syzbot+12479ae15958fc3f54ec@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/68d32659.a70a0220.4f78.0012.GAE@google.com/
Fixes: 2ef435a872ab ("fs: add might_sleep() annotation to iput() and more")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
From hook_sb_delete():
/*
* At this point, we own the ihold() reference that was
* originally set up by get_inode_object() and the
* __iget() reference that we just set in this loop
* walk. Therefore the following call to iput() will
* not sleep nor drop the inode because there is now at
* least two references to it.
*/
iput(inode);
#syz test
---
fs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/inode.c b/fs/inode.c
index 84f539497857..64120cb21e8b 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1917,6 +1917,7 @@ static void iput_final(struct inode *inode)
const struct super_operations *op = inode->i_sb->s_op;
int drop;
+ might_sleep();
WARN_ON(inode_state_read(inode) & I_NEW);
VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode);
@@ -1969,7 +1970,6 @@ static void iput_final(struct inode *inode)
*/
void iput(struct inode *inode)
{
- might_sleep();
if (unlikely(!inode))
return;
--
2.51.0
prev parent reply other threads:[~2025-11-05 19:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 22:59 [syzbot] [fs?] BUG: sleeping function called from invalid context in hook_sb_delete syzbot
2025-09-24 0:28 ` Hillf Danton
2025-09-24 0:56 ` syzbot
2025-09-24 9:44 ` Edward Adam Davis
2025-09-24 10:43 ` syzbot
2025-09-24 10:38 ` Edward Adam Davis
2025-09-24 10:46 ` Edward Adam Davis
2025-09-24 10:46 ` syzbot
2025-09-24 11:19 ` syzbot
2025-09-24 11:05 ` Jan Kara
2025-09-29 8:51 ` Christian Brauner
2025-10-09 20:56 ` syzbot
2025-11-01 15:32 ` Forwarded: " syzbot
2025-11-05 19:38 ` 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=690ba79e.050a0220.3d0d33.008a.GAE@google.com \
--to=syzbot+12479ae15958fc3f54ec@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