]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
userns: Don't read extents twice in m_start
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 31 Oct 2017 22:09:34 +0000 (17:09 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Tue, 31 Oct 2017 22:23:12 +0000 (17:23 -0500)
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>
kernel/user_namespace.c

index 563a2981d7c79e894d772ac2657d1f7262c74c5b..4f7e357ac1e2366ab3aff89ff9abcab001ea9f09 100644 (file)
@@ -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];