Skip to content

Fix LSM mediation of PR_SET_SECUREBITS

Mickaël Salaün bpf linux-security-module lkml selinux stable 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 0 repliesNew
  2. v22 patches 0 repliesSuperseded
  3. v12 patches 1 replySuperseded

Changes in v3 from the cover letter

https://patch.msgid.link/[email protected]
- Apply on top of series 1 v3.
- Use ASSERT_EQ() in the test before checking errno (suggested by Günther Noack).
- Shorten the commit message of patch 2.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2capabilities: Check PR_SET_SECUREBITS with ns_capable()security/commoncap.c+23 -220 replies
2/2selftests/landlock: Test PR_SET_SECUREBITS mediationtools/testing/selftests/landlock/cap_test.c+69 -00 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchSerge Hallyn (AMD)
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] Fix LSM mediation of PR_SET_SECUREBITS

Hi,

This is series 2 of 3:

1. fix Landlock mediation of commoncap's capability checks;
* 2. fix PR_SET_SECUREBITS mediation and add focused Landlock tests;
3. fix Landlock mediation of capabilities guarding LSM policies.

This series applies on top of series 1:
https://patch.msgid.link/[email protected]

Since per-process securebits were introduced, PR_SET_SECUREBITS checks CAP_SETPCAP with cap_capable() instead of ns_capable(), so LSMs restricting capabilities through the capable hook (SELinux, AppArmor, Landlock and BPF LSM programs) cannot deny it. A task with CAP_SETPCAP can therefore change privileged securebits, and thus how its capabilities evolve across UID changes and execve(), without the expected denial or audit record.

Patch 1 uses ns_capable(), as PR_CAPBSET_DROP already does, for the changes that require CAP_SETPCAP; changes limited to the unprivileged securebits still do not check a capability. It applies cleanly to the 6.18 and 7.2 stable branches; older ones need a simpler adapted backport. Patch 2 adds a Landlock audit test that fails without patch
1. It shares cap_test.c with series 1, which is the only reason for the ordering.

Paul, John, Stephen, KP and Matt, please check the AppArmor, SELinux and BPF LSM implications of exposing this CAP_SETPCAP check to the capable hook.

Changes since v2:
https://patch.msgid.link/[email protected]
- Apply on top of series 1 v3.
- Use ASSERT_EQ() in the test before checking errno (suggested by Günther Noack).
- Shorten the commit message of patch 2.

Changes since v1:
https://patch.msgid.link/[email protected]
- Shorten the commit message of patch 1 and check the non-change case separately (suggested by Serge Hallyn).
- Add Serge Hallyn's Reviewed-by.

Regards,

Mickaël Salaün (2):
capabilities: Check PR_SET_SECUREBITS with ns_capable() selftests/landlock: Test PR_SET_SECUREBITS mediation

 security/commoncap.c                        | 45 +++++++-------
 tools/testing/selftests/landlock/cap_test.c | 69 +++++++++++++++++++++
 2 files changed, 92 insertions(+), 22 deletions(-)

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
prerequisite-patch-id: 365071039dd2be439f67707944d12edbe1422d60
prerequisite-patch-id: 021705fb5147cdc8edcac9dbe53c06b854cf976a
prerequisite-patch-id: ddc6687ae87f8f782ed8ad5b005834f242aec2fb
prerequisite-patch-id: 0bf745b08b99168d266461ef5b0b943a2b71eceb
prerequisite-patch-id: 03ec09be2416d4cc932b07dfb0e7450f15c22804
prerequisite-patch-id: 383fa2ce8a4ed44e4b5c828c99c5be5ee75048af

Signature · 1 line
2.56.0