Re: [PATCH v5 1/2] userns: Add __counted_by_ptr attribute to struct uid_gid_map
From: Christian Brauner
Date: Wed Sep 09 2026 - 03:53:57 EST
On Tue, 08 Sep 2026 22:27:29 +0000, Bill Wendling wrote:
> The compiler attribute __counted_by_ptr associates a pointer field of a
> struct with a sibling field within the same struct that specifies the
> element count of the allocated memory. This enables KASAN and fortified
> bounds-checking to detect out-of-bounds accesses to the pointer field at
> runtime.
>
> We can add the __counted_by_ptr attribute to the 'forward' and 'reverse'
> pointer fields of 'struct uid_gid_map', which are counted by
> 'nr_extents'. Since 'nr_extents' is defined in a sibling anonymous
> struct inside an anonymous union, the nearest common non-anonymous
> struct level is 'struct uid_gid_map' itself, which is supported by the
> compiler.
>
> [...]
Applied to the namespace-7.4.misc branch of the vfs/vfs.git tree.
Patches in the namespace-7.4.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: namespace-7.4.misc
[1/2] userns: Add __counted_by_ptr attribute to struct uid_gid_map
https://git.kernel.org/vfs/vfs/c/b31397fe3007
[2/2] userns: Add KUnit test suite for uid_gid_map
https://git.kernel.org/vfs/vfs/c/f6f1a2496ba5