Re: [RFC PATCH v7 10/26] userland: Add core infrastructure
From: bot+bpf-ci
Date: Sun Nov 22 2026 - 15:28:25 EST
> userland: Add core infrastructure
TL;DR:
- USERLAND_ALL_FLAGS in the uapi header becomes fixed ABI; adding flags later
may break rebuilt programs, so consider keeping it kernel-internal
- USERLAND_CLOSE_ON_EXEC naming nit: other flags use *_CLOEXEC
> diff --git a/include/uapi/linux/userland.h b/include/uapi/linux/userland.h
> new file mode 100644
> --- /dev/null
> +++ b/include/uapi/linux/userland.h
[ ... ]
> +enum userland_flags {
> + USERLAND_KILL_ON_CLOSE = 0x00000001,
> + USERLAND_CLOSE_ON_EXEC = 0x00000002,
> + USERLAND_ALL_FLAGS = 0x00000003,
> +};
Should the USERLAND_ALL_FLAGS mask be exported in the uapi header? The
later userland_open() syscall validates with:
if (flags & ~USERLAND_ALL_FLAGS)
return -EINVAL;
Once released, the value of this mask is fixed ABI. If a later kernel adds
a flag and grows the mask, a program rebuilt against the new header that
uses USERLAND_ALL_FLAGS would get -EINVAL on older kernels. If the mask is
left unchanged, the in-kernel check stops covering the new flag.
fanotify hit this: include/uapi/linux/fanotify.h marks FAN_ALL_CLASS_BITS,
FAN_ALL_INIT_FLAGS and FAN_ALL_MARK_FLAGS as "Deprecated - do not use this
in programs and do not add new flags here!", and the valid masks live in
include/linux/fanotify.h (FANOTIFY_INIT_FLAGS). Other fd-returning
syscalls keep their valid-flag masks kernel-internal, for example
CLONE_LEGACY_FLAGS in include/linux/sched/task.h and VALID_RESOLVE_FLAGS in
include/linux/fcntl.h. Would it make sense to move the mask to
include/linux/userland.h?
Also, this isn't a bug, but should USERLAND_CLOSE_ON_EXEC be spelled
USERLAND_CLOEXEC? The other close-on-exec flags under include/uapi all use
the *_CLOEXEC form (FSOPEN_CLOEXEC, FSMOUNT_CLOEXEC, OPEN_TREE_CLOEXEC,
MFD_CLOEXEC, EFD_CLOEXEC, ...), and the name cannot be changed after the
ABI is released.
---
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/45063222848