aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2017-10-31 18:09:34 -0400
committerEric W. Biederman <ebiederm@xmission.com>2017-10-31 18:23:12 -0400
commitd5e7b3c5f51fc6d34e12b6d87bfd30ab277c4625 (patch)
treea72ab0e9c38b7fb30d02e32dcb6785f1ab122a00 /kernel
parent3edf652fa16562fb57a5a4b996ba72e2d7cdc38b (diff)
userns: Don't read extents twice in m_start
This is important so reading /proc/<pid>/{uid_map,gid_map,projid_map} while the map is being written does not do strange things. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/user_namespace.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 563a2981d7c7..4f7e357ac1e2 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -683,11 +683,13 @@ static void *m_start(struct seq_file *seq, loff_t *ppos,
683 struct uid_gid_map *map) 683 struct uid_gid_map *map)
684{ 684{
685 loff_t pos = *ppos; 685 loff_t pos = *ppos;
686 unsigned extents = map->nr_extents;
687 smp_rmb();
686 688
687 if (pos >= map->nr_extents) 689 if (pos >= extents)
688 return NULL; 690 return NULL;
689 691
690 if (map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS) 692 if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
691 return &map->extent[pos]; 693 return &map->extent[pos];
692 694
693 return &map->forward[pos]; 695 return &map->forward[pos];