landlock_add_rule on x64

add a new Landlock rule to a ruleset

sys_landlock_add_rule(int ruleset_fd, enum landlock_rule_type rule_type, const void *rule_attr, __u32 flags)
number445 (0x1bd)
abicommon
kconfigCONFIG_SECURITY_LANDLOCK
familylandlock see the whole family on x64
entry pointsys_landlock_add_rule
sinceLinux 5.13
man pagelandlock_add_rule(2)
sourceelixir.bootlin.com

Registers

registervalue
rax445, the syscall number
rdiint ruleset_fd
rsienum landlock_rule_type rule_type
rdxconst void *rule_attr
r10__u32 flags
raxthe return value

Then run syscall to enter the kernel.

The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).

Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.

Same syscall on other architectures

Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/landlock_add_rule