Skip to content

Commit

Permalink
ipc: Restrict mounting the mqueue filesystem
Browse files Browse the repository at this point in the history
Only allow mounting the mqueue filesystem if the caller has CAP_SYS_ADMIN
rights over the ipc namespace.   The principle here is if you create
or have capabilities over it you can mount it, otherwise you get to live
with what other people have mounted.

This information is not particularly sensitive and mqueue essentially
only reports which posix messages queues exist.  Still when creating a
restricted environment for an application to live any extra
information may be of use to someone with sufficient creativity.  The
historical if imperfect way this information has been restricted has
been not to allow mounts and restricting this to ipc namespace
creators maintains the spirit of the historical restriction.

Cc: [email protected]
Acked-by: Serge Hallyn <[email protected]>
Signed-off-by: "Eric W. Biederman" <[email protected]>
  • Loading branch information
ebiederm committed Mar 27, 2013
1 parent 132c94e commit a636b70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,16 @@ static struct dentry *mqueue_mount(struct file_system_type *fs_type,
int flags, const char *dev_name,
void *data)
{
if (!(flags & MS_KERNMOUNT))
data = current->nsproxy->ipc_ns;
if (!(flags & MS_KERNMOUNT)) {
struct ipc_namespace *ns = current->nsproxy->ipc_ns;
/* Don't allow mounting unless the caller has CAP_SYS_ADMIN
* over the ipc namespace.
*/
if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);

data = ns;
}
return mount_ns(fs_type, flags, data, mqueue_fill_super);
}

Expand Down

0 comments on commit a636b70

Please sign in to comment.