diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2017-10-31 23:09:34 +0100 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2017-10-31 23:23:12 +0100 |
commit | d5e7b3c5f51fc6d34e12b6d87bfd30ab277c4625 (patch) | |
tree | a72ab0e9c38b7fb30d02e32dcb6785f1ab122a00 | |
parent | userns: Simplify the user and group mapping functions (diff) | |
download | linux-d5e7b3c5f51fc6d34e12b6d87bfd30ab277c4625.tar.xz linux-d5e7b3c5f51fc6d34e12b6d87bfd30ab277c4625.zip |
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>
-rw-r--r-- | kernel/user_namespace.c | 6 |
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, struct uid_gid_map *map) { loff_t pos = *ppos; + unsigned extents = map->nr_extents; + smp_rmb(); - if (pos >= map->nr_extents) + if (pos >= extents) return NULL; - if (map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS) + if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS) return &map->extent[pos]; return &map->forward[pos]; |