Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

userns: Rename id_map_mutex to userns_state_mutex

Generalize id_map_mutex so it can be used for more state of a user namespace.

Cc: stable@vger.kernel.org
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

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