statmount: Fix the null-ptr-deref in do_statmount()
PATCH v2 1/1 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 0e5032237ee5 ("statmount: accept fd as a parameter")
Reported-by [email protected]
Signed-off-by Qing Wang <[email protected]>
--- fs/namespace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/namespace.c +4 -1
@@ -5678,13 +5678,16 @@ static int do_statmount(struct kstatmount *s, u64 mnt_id, u64 mnt_ns_id, s->mnt = mnt_file->f_path.mnt; ns =real_mount (s->mnt)->mnt_ns; -if (!ns) +if (IS_ERR (ns)) +return PTR_ERR (ns); +if (!ns) {/* * We can't set mount point and mnt_ns_id since we don't have a * ns for the mount. This can happen if the mount is unmounted * with MNT_DETACH. */ s->mask &= ~(STATMOUNT_MNT_POINT |STATMOUNT_MNT_NS_ID ); + } }else {/* Has the namespace already been emptied? */ if (mnt_ns_id &&mnt_ns_empty (ns))
Signature · 1 line
2.34.1