sys_landlock_restrict_self(9)
sys_landlock_restrict_self(9) π
okay so bestie, this is the glow-up of a page from the Kernel API Manual β sys_landlock_restrict_self(9) β and it's all about enforcing a Landlock ruleset on the calling thread. security gatekeeping, but make it syscall. π
π NAME π
sys_landlock_restrict_self β enforce a ruleset on the calling thread. literally the βlock it inβ move for Landlock, no cap. π«Ά
β¨ SYNOPSIS β¨
long sys_landlock_restrict_self (const int ruleset_fd , const __u32
flags );
π ARGUMENTS π
ruleset_fdβ file descriptor tied to the ruleset to merge with the target. like, the little VIP handle for the ruleset you're bringing to the function. ποΈflagsβ supported values: the fiveLANDLOCK_RESTRICT_SELF_*flag girlies listed in DESCRIPTION below. yes, the whole menu, bestie. π
πΈ DESCRIPTION πΈ
okay so these are the supported values for flags, and this page gives us the names, periodt:
LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFFβ a supportedflagsvalue. β¨LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ONβ a supportedflagsvalue. β¨LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFFβ a supportedflagsvalue. β¨LANDLOCK_RESTRICT_SELF_TSYNCβ a supportedflagsvalue. β¨LANDLOCK_RESTRICT_SELF_NO_NEW_PRIVSβ a supportedflagsvalue. β¨
This system call enforces a Landlock ruleset on the current thread. Enforcing a ruleset requires that the task has CAP_SYS_ADMIN in its namespace or is running with no_new_privs. This avoids scenarios where unprivileged tasks can affect the behavior of privileged children. π
With LANDLOCK_RESTRICT_SELF_NO_NEW_PRIVS, the no_new_privs attribute of the calling thread is set only once the enforcement of the ruleset succeeded, which fulfills the above requirement: no_new_privs is set if and only if the call succeeds. highkey iconic behavior. π
and here's the possible-error guest list, in original order:
EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;EINVAL:flagscontains an unknown bit.EBADF:ruleset_fdis not a file descriptor for the current thread;EBADFD:ruleset_fdis not a ruleset file descriptor;EPERM:ruleset_fdhas no read access to the underlying ruleset, orLANDLOCK_RESTRICT_SELF_NO_NEW_PRIVSis not set while the current thread is not running withno_new_privsand doesn't haveCAP_SYS_ADMINin its namespace.E2BIG: The maximum number of stacked rulesets is reached for the current thread.
also this page pulls in the uapi header identifiers, so keep this exact kernel-doc directive energy:
.. kernel-doc:: include/uapi/linux/landlock.h :identifiers:
landlock_restrict_self_flags
π RETURN π
0 on success, or -errno on failure. Possible returned errors are: the whole list we just did above, bestie β EOPNOTSUPP, EINVAL, EBADF, EBADFD, EPERM, and E2BIG. that's the error buffet. π
π¦ SEE ALSO π¦
- Kernel file
./security/landlock/syscalls.c copy_min_struct_from_user(9)sys_landlock_create_ruleset(9)sys_landlock_add_rule(9)
mwah π β this cutie comes from source/version ./security/landlock, dated October 2026. stay slay, bestie. π«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms