Skip to content

Commit 15623c8

Browse files
deepanshu406brauner
authored andcommitted
nsfs: handle inode number mismatches gracefully in file handles
Replace VFS_WARN_ON_ONCE() with graceful error handling when file handles contain inode numbers that don't match the actual namespace inode. This prevents userspace from triggering kernel warnings by providing malformed file handles to open_by_handle_at(). The issue occurs when userspace provides a file handle with valid namespace type and ID that successfully locates a namespace, but specifies an incorrect inode number. Previously, this would trigger VFS_WARN_ON_ONCE() when comparing the real inode number against the provided value. Since file handle data is user-controllable, inode number mismatches should be treated as invalid input rather than kernel consistency errors. Handle this case by returning NULL to indicate the file handle is invalid, rather than warning about what is essentially user input validation. Reported-by: syzbot+9eefe09bedd093f156c2@syzkaller.appspotmail.com Suggested-by: Jan Kara <jack@suse.cz> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fd94619 commit 15623c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/nsfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ static struct dentry *nsfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
490490

491491
VFS_WARN_ON_ONCE(ns->ns_id != fid->ns_id);
492492
VFS_WARN_ON_ONCE(ns->ns_type != fid->ns_type);
493-
VFS_WARN_ON_ONCE(ns->inum != fid->ns_inum);
493+
494+
if (ns->inum != fid->ns_inum)
495+
return NULL;
494496

495497
if (!__ns_ref_get(ns))
496498
return NULL;

0 commit comments

Comments
 (0)