Re: [RFC PATCH v6 01/26] userns: Factor out idmap validation and commit helpers
From: bot+bpf-ci
Date: Sat Nov 21 2026 - 20:57:08 EST
> userns: Factor out idmap validation and commit helpers
TL;DR: Nit only: the smp_rmb() pairing comment in commit_new_idmap() names
map_id_up(), which has no barrier; it should name map_id_range_up(),
map_id_range_down() and m_start().
> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
> --- a/kernel/user_namespace.c
> +++ b/kernel/user_namespace.c
[ ... ]
> +static void commit_new_idmap(struct uid_gid_map *map,
> + struct uid_gid_map *new_map)
> +{
> + if (new_map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS) {
> + memcpy(map->extent, new_map->extent,
> + new_map->nr_extents * sizeof(new_map->extent[0]));
> + } else {
> + map->forward = new_map->forward;
> + map->reverse = new_map->reverse;
> + }
> + /* Pairs with smp_rmb() in map_id_range_down() / map_id_up(). */
^^^^^^^^^
This isn't a bug, but the comment doesn't match the readers that contain
the paired smp_rmb(). map_id_up() has no barrier of its own:
u32 map_id_up(const struct uid_gid_map *map, u32 id)
{
return map_id_range_up(map, id, 1);
}
The barrier is in map_id_range_up(), which is also called directly (for
example from statmount_mnt_idmap()). The procfs reader m_start() also
pairs with this barrier:
unsigned extents = map->nr_extents;
smp_rmb();
Could the comment name map_id_range_down(), map_id_range_up() and
m_start() instead?
> + smp_wmb();
> + map->nr_extents = new_map->nr_extents;
> + memset(new_map, 0, sizeof(*new_map));
> +}
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44972669664