diff mbox series

efivarfs: use INODE_CHILD nested lock to traverse variables on resume

Message ID 20250317073032.2665183-2-ardb+git@google.com
State New
Headers show
Series efivarfs: use INODE_CHILD nested lock to traverse variables on resume | expand

Commit Message

Ard Biesheuvel March 17, 2025, 7:30 a.m. UTC
From: Ard Biesheuvel <ardb@kernel.org>

syzbot warns about a potential deadlock, but this is a false positive
resulting from a missing lockdep annotation: iterate_dir() locks the
parent whereas the inode_lock() it warns about locks the child, which is
guaranteed to be a different lock.

So use inode_lock_nested() instead with the appropriate lock class.

Reported-by: syzbot+019072ad24ab1d948228@syzkaller.appspotmail.com
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 fs/efivarfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 6eae8cf655c1..642dff82f364 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -421,7 +421,7 @@  static bool efivarfs_actor(struct dir_context *ctx, const char *name, int len,
 	if (err)
 		size = 0;
 
-	inode_lock(inode);
+	inode_lock_nested(inode, INODE_CHILD);
 	i_size_write(inode, size);
 	inode_unlock(inode);