Skip to content

Commit

Permalink
fs: relax permissions for statmount()
Browse files Browse the repository at this point in the history
It is sufficient to have capabilities in the owning user namespace of
the mount namespace to stat a mount regardless of whether it's reachable
or not.

Link: https://lore.kernel.org/r/bf5961d71ec479ba85806766b0d8d96043e67bba.1719243756.git.josef@toxicpanda.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
  • Loading branch information
Christian Brauner committed Jun 28, 2024
1 parent dd7cb14 commit f3107df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4930,14 +4930,15 @@ static int copy_statmount_to_user(struct kstatmount *s)
static int do_statmount(struct kstatmount *s)
{
struct mount *m = real_mount(s->mnt);
struct mnt_namespace *ns = m->mnt_ns;
int err;

/*
* Don't trigger audit denials. We just want to determine what
* mounts to show users.
*/
if (!is_path_reachable(m, m->mnt.mnt_root, &s->root) &&
!ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN))
!ns_capable_noaudit(ns->user_ns, CAP_SYS_ADMIN))
return -EPERM;

err = security_sb_statfs(s->mnt->mnt_root);
Expand Down

0 comments on commit f3107df

Please sign in to comment.