[PATCH v3 3/5] userns: check the opener and the writer before mapping uid 0
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Oct 21 20:57:41 UTC 2026
> verify_root_map() looks at the cred that opened the map file: it asks
> whether it has CAP_SETFCAP over the parent, or, for an opener inside the
> namespace, whether the creator had. Two things are missing.
>
> The writer isn't checked. For every other privileged mapping
> new_idmap_permitted() wants the capability from the opener and from the
> task that calls write(), but a map that consists of the single line
> "0 0 1" takes the unprivileged branch, where only the opener's euid
> counts. So an open uid_map file is a token for mapping uid 0:
>
> task A: uid 0, full caps task B: uid 0, no CAP_SETFCAP
> fd = open("/proc/<pid>/uid_map")
> B gets fd by inheritance
> or SCM_RIGHTS
> write(fd, "0 0 1")
> [ ... ]
>
> Fixes: db2e718a4798 ("capabilities: require CAP_SETFCAP to map uid 0")
> Reviewed-by: Bradley Morgan <brads at mainlining.org>
> Assisted-by: LLM
> Signed-off-by: Josef Bacik <josef at toxicpanda.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-b4-setfcap-userns-v3-0-97c7ed4e43e1@toxicpanda.com?part=3
More information about the Linux-security-module-archive
mailing list