Skip to content

Commit 81f16c9

Browse files
Qing Wangbrauner
authored andcommitted
statmount: Fix the null-ptr-deref in do_statmount()
If the mount is internal, it's mnt_ns will be MNT_NS_INTERNAL, which is defined as ERR_PTR(-EINVAL). So, in the do_statmount(), need to check ns of mount by IS_ERR() and return. Fixes: 0e50322 ("statmount: accept fd as a parameter") Reported-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Qing Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Bhavik Sachdev <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 9eed043 commit 81f16c9

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/namespace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5678,6 +5678,8 @@ static int do_statmount(struct kstatmount *s, u64 mnt_id, u64 mnt_ns_id,
56785678

56795679
s->mnt = mnt_file->f_path.mnt;
56805680
ns = real_mount(s->mnt)->mnt_ns;
5681+
if (IS_ERR(ns))
5682+
return PTR_ERR(ns);
56815683
if (!ns)
56825684
/*
56835685
* We can't set mount point and mnt_ns_id since we don't have a

0 commit comments

Comments
 (0)