Skip to content

Commit 6f3bf1e

Browse files
ebiedermgregkh
authored andcommitted
userns: Rename id_map_mutex to userns_state_mutex
commit f0d62ae upstream. Generalize id_map_mutex so it can be used for more state of a user namespace. Reviewed-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7faecd4 commit 6f3bf1e

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎kernel/user_namespace.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/fs_struct.h>
2525

2626
static struct kmem_cache *user_ns_cachep __read_mostly;
27+
static DEFINE_MUTEX(userns_state_mutex);
2728

2829
static bool new_idmap_permitted(const struct file *file,
2930
struct user_namespace *ns, int cap_setid,
@@ -581,9 +582,6 @@ static bool mappings_overlap(struct uid_gid_map *new_map, struct uid_gid_extent
581582
return false;
582583
}
583584

584-
585-
static DEFINE_MUTEX(id_map_mutex);
586-
587585
static ssize_t map_write(struct file *file, const char __user *buf,
588586
size_t count, loff_t *ppos,
589587
int cap_setid,
@@ -600,7 +598,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
600598
ssize_t ret = -EINVAL;
601599

602600
/*
603-
* The id_map_mutex serializes all writes to any given map.
601+
* The userns_state_mutex serializes all writes to any given map.
604602
*
605603
* Any map is only ever written once.
606604
*
@@ -618,7 +616,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
618616
* order and smp_rmb() is guaranteed that we don't have crazy
619617
* architectures returning stale data.
620618
*/
621-
mutex_lock(&id_map_mutex);
619+
mutex_lock(&userns_state_mutex);
622620

623621
ret = -EPERM;
624622
/* Only allow one successful write to the map */
@@ -745,7 +743,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
745743
*ppos = count;
746744
ret = count;
747745
out:
748-
mutex_unlock(&id_map_mutex);
746+
mutex_unlock(&userns_state_mutex);
749747
if (page)
750748
free_page(page);
751749
return ret;
@@ -837,12 +835,12 @@ bool userns_may_setgroups(const struct user_namespace *ns)
837835
{
838836
bool allowed;
839837

840-
mutex_lock(&id_map_mutex);
838+
mutex_lock(&userns_state_mutex);
841839
/* It is not safe to use setgroups until a gid mapping in
842840
* the user namespace has been established.
843841
*/
844842
allowed = ns->gid_map.nr_extents != 0;
845-
mutex_unlock(&id_map_mutex);
843+
mutex_unlock(&userns_state_mutex);
846844

847845
return allowed;
848846
}

0 commit comments

Comments
 (0)