Switch to AppArmor/SELinux based socketcall block#52547
Merged
Conversation
Add a positive test that creates an AF_INET socket via int $0x80 socketcall to ensure the AppArmor "deny network alg" rule only blocks AF_ALG and does not break legitimate socketcall usage. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Add a SELinux CIL module that denies AF_ALG socket creation for all container domains. Like AppArmor, SELinux hooks into the kernel's security_socket_create() LSM callback, blocking AF_ALG regardless of whether the socket was created via socket(2) or socketcall(2), without disrupting other socketcall usage by 32-bit binaries. This is shipped as a standalone CIL file for packaging repos to install via semodule. It is not loaded by moby itself. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Seccomp cannot filter socketcall(2) arguments because the address family is behind a userspace pointer that BPF cannot dereference. Only an LSM (AppArmor or SELinux) can deny AF_ALG via the security_socket_create hook in the socketcall path. Skip the socketcall_int80 subtest when neither AppArmor nor SELinux is reported by the daemon, since the test would always fail without an LSM to enforce the deny rule. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Add "deny network alg," to the default AppArmor profile. Unlike seccomp, which can only filter arguments of the direct socket(2) syscall, AppArmor hooks into the kernel's security_socket_create() LSM callback, which fires regardless of the syscall entry point. This means AppArmor also blocks AF_ALG sockets created via the legacy socketcall(2) multiplexer (used by 32-bit binaries), which seccomp cannot inspect because the address family is behind a userspace pointer that BPF cannot dereference. Crucially, AppArmor can deny AF_ALG selectively without blocking socketcall entirely. A blanket seccomp socketcall deny broke all 32-bit networking since glibc on i386 routes every socket operation through socketcall. AppArmor operates at the socket layer, not the syscall layer, so it blocks only the specific address family while leaving all other socketcall usage intact. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
With the apparmor based block, it will now fail with EPERM Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
We now rely on the LSM-based solution for the hardening. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
thaJeztah
approved these changes
May 6, 2026
Member
|
@vvoland Would you be interested in porting this to containerd as well? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seccomp cannot filter socketcall(2) arguments because the address family is behind a userspace pointer that BPF cannot dereference. Only an LSM (AppArmor or SELinux) can deny AF_ALG via the security_socket_create hook in the socketcall path.
CVE-2026-31431: Replace the socketcall(2) seccomp deny that broke 32-bit programs with targeted AppArmor (deny network alg) and SELinux (alg_socket) rules that block AF_ALG at the LSM layer, covering both socket(2) and socketcall(2) paths without disrupting legitimate 32-bit workloads.