linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mateusz Guzik <mjguzik@gmail.com>
To: mic@digikod.net, brauner@kernel.org
Cc: linux-security-module@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	eadavis@qq.com, gnoack@google.com, jack@suse.cz,
	jannh@google.com, max.kellermann@ionos.com, m@maowtm.org,
	syzbot+12479ae15958fc3f54ec@syzkaller.appspotmail.com,
	Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH 2/2] landlock: fix splats from iput() after it started calling might_sleep()
Date: Wed,  5 Nov 2025 22:20:25 +0100	[thread overview]
Message-ID: <20251105212025.807549-2-mjguzik@gmail.com> (raw)
In-Reply-To: <20251105212025.807549-1-mjguzik@gmail.com>

At this point it is guaranteed this is not the last reference.

However, a recent addition of might_sleep() at top of iput() started
generating false-positives as it was executing for all values.

Remedy the problem by using the newly introduced iput_not_last().

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: Mateusz Guzik <mjguzik@gmail.com>
---
 security/landlock/fs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/security/landlock/fs.c b/security/landlock/fs.c
index 0bade2c5aa1d..d9c12b993fa7 100644
--- a/security/landlock/fs.c
+++ b/security/landlock/fs.c
@@ -1335,11 +1335,10 @@ static void hook_sb_delete(struct super_block *const sb)
 			 * 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.
+			 * walk.  Therefore there are at least two references
+			 * on the inode.
 			 */
-			iput(inode);
+			iput_not_last(inode);
 		} else {
 			spin_unlock(&object->lock);
 			rcu_read_unlock();
-- 
2.48.1


  reply	other threads:[~2025-11-05 21:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 21:20 [PATCH 1/2] fs: add iput_not_last() Mateusz Guzik
2025-11-05 21:20 ` Mateusz Guzik [this message]
2025-11-06  8:45   ` [PATCH 2/2] landlock: fix splats from iput() after it started calling might_sleep() Mickaël Salaün
2025-11-06  9:43 ` [PATCH 1/2] fs: add iput_not_last() Jan Kara
2025-11-11 11:46 ` Christian Brauner
2025-11-11 11:53   ` Mateusz Guzik
2025-11-12  9:48     ` Christian Brauner

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=20251105212025.807549-2-mjguzik@gmail.com \
    --to=mjguzik@gmail.com \
    --cc=brauner@kernel.org \
    --cc=eadavis@qq.com \
    --cc=gnoack@google.com \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=m@maowtm.org \
    --cc=max.kellermann@ionos.com \
    --cc=mic@digikod.net \
    --cc=syzbot+12479ae15958fc3f54ec@syzkaller.appspotmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).