Commit 54b8ced1efd4a5f2746ff98b34b8c9bee7c6b80d

Authored by Eric W. Biederman
Committed by Greg Kroah-Hartman
1 parent 39d3003edf

userns: Rename id_map_mutex to userns_state_mutex

commit f0d62aec931e4ae3333c797d346dc4f188f454ba 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>

Showing 1 changed file with 6 additions and 8 deletions Side-by-side Diff

kernel/user_namespace.c
... ... @@ -24,6 +24,7 @@
24 24 #include <linux/fs_struct.h>
25 25  
26 26 static struct kmem_cache *user_ns_cachep __read_mostly;
  27 +static DEFINE_MUTEX(userns_state_mutex);
27 28  
28 29 static bool new_idmap_permitted(const struct file *file,
29 30 struct user_namespace *ns, int cap_setid,
... ... @@ -583,9 +584,6 @@
583 584 return false;
584 585 }
585 586  
586   -
587   -static DEFINE_MUTEX(id_map_mutex);
588   -
589 587 static ssize_t map_write(struct file *file, const char __user *buf,
590 588 size_t count, loff_t *ppos,
591 589 int cap_setid,
... ... @@ -602,7 +600,7 @@
602 600 ssize_t ret = -EINVAL;
603 601  
604 602 /*
605   - * The id_map_mutex serializes all writes to any given map.
  603 + * The userns_state_mutex serializes all writes to any given map.
606 604 *
607 605 * Any map is only ever written once.
608 606 *
... ... @@ -620,7 +618,7 @@
620 618 * order and smp_rmb() is guaranteed that we don't have crazy
621 619 * architectures returning stale data.
622 620 */
623   - mutex_lock(&id_map_mutex);
  621 + mutex_lock(&userns_state_mutex);
624 622  
625 623 ret = -EPERM;
626 624 /* Only allow one successful write to the map */
... ... @@ -750,7 +748,7 @@
750 748 *ppos = count;
751 749 ret = count;
752 750 out:
753   - mutex_unlock(&id_map_mutex);
  751 + mutex_unlock(&userns_state_mutex);
754 752 if (page)
755 753 free_page(page);
756 754 return ret;
757 755  
... ... @@ -845,12 +843,12 @@
845 843 {
846 844 bool allowed;
847 845  
848   - mutex_lock(&id_map_mutex);
  846 + mutex_lock(&userns_state_mutex);
849 847 /* It is not safe to use setgroups until a gid mapping in
850 848 * the user namespace has been established.
851 849 */
852 850 allowed = ns->gid_map.nr_extents != 0;
853   - mutex_unlock(&id_map_mutex);
  851 + mutex_unlock(&userns_state_mutex);
854 852  
855 853 return allowed;
856 854 }