Skip to content

doc: warn that argument comparisons don't ignore the upper 32 bits - #504

Open
ricardobranco777 wants to merge 1 commit into
seccomp:mainfrom
ricardobranco777:doc-cmp32-upper-bits
Open

ricardobranco777 wants to merge 1 commit into
seccomp:mainfrom
ricardobranco777:doc-cmp32-upper-bits

Conversation

@ricardobranco777

Copy link
Copy Markdown

The kernel's seccomp filter sees the raw 64-bit argument registers, while syscalls with 32-bit argument types (e.g. the socket(2) domain) ignore the upper 32 bits. A rule such as

SCMP_A0(SCMP_CMP_EQ, AF_NETLINK)

is therefore bypassed by socket(0x100000000|AF_NETLINK, ...). The SCMP_CMP32/SCMP_A{0-5}_32 macros don't help, as they only truncate the datum and mask values and still compare the full 64-bit argument.

Document this in seccomp_rule_add(3) and in the SCMP_CMP32 header comment, and recommend SCMP_CMP_MASKED_EQ with a 0xffffffff mask for arguments the kernel treats as 32-bit.

The kernel's seccomp filter sees the raw 64-bit argument registers,
while syscalls with 32-bit argument types (e.g. the socket(2) domain)
ignore the upper 32 bits. A rule such as

  SCMP_A0(SCMP_CMP_EQ, AF_NETLINK)

is therefore bypassed by socket(0x100000000|AF_NETLINK, ...). The
SCMP_CMP32/SCMP_A{0-5}_32 macros don't help, as they only truncate the
datum and mask values and still compare the full 64-bit argument.

Document this in seccomp_rule_add(3) and in the SCMP_CMP32 header
comment, and recommend SCMP_CMP_MASKED_EQ with a 0xffffffff mask for
arguments the kernel treats as 32-bit.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant