[BUG] landlock: sleeping function called from invalid context in hook_sb_delete()

Günther Noack gnoack3000 at gmail.com
Thu Nov 20 08:48:43 UTC 2025


Hello!

Thanks for the report!

CC-ing Mickaël, who authored that code

On Wed, Nov 12, 2025 at 10:35:17AM +0800, 许佳凯 wrote:
> The call trace indicates that hook_sb_delete() holds s_inode_list_lock (a spinlock) while invoking operations that may eventually call iput(), which can sleep.
> This violates the locking context expectations and triggers __might_sleep() warnings.
> The issue seems to be related to how Landlock handles superblock cleanup during security_sb_delete().
> 
> 
> I’m currently only reporting this issue to the community; the exact fix will likely need to be confirmed and implemented by the Landlock and filesystem maintainers.

This looks like a false positive to me.

There are three places where iput() is being called in hook_sb_delete,
two of them are in places where it is *not* holding the
s_inode_list_lock.  The one that *is* holding the s_inode_list_lock
has the following comment:

/*
 * 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.
 */

That seems to indicate that the sleepability concern was taken into
consideration.  iput() only sleeps if the refcount reaches zero, and
if you can exclude that, it won't sleep.

—Günther

-- 



More information about the Linux-security-module-archive mailing list