Fix Landlock mediation of commoncap's capability checks
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 0 repliesNew
- v26 patches 10 repliesSuperseded
- v16 patches 2 repliesApplied
Changes in v3 from the cover letter
https://patch.msgid.link/[email protected]
- Use ASSERT_*() in the tests where later checks depend on the result, and rename a test helper parameter (suggested by Günther Noack).
- Describe the capset hook's condition from cap_capset()'s point of view (suggested by Günther Noack).
- Shorten the commit messages (suggested by Günther Noack).
- Reword the capability permission's UAPI description (suggested by Günther Noack).
- Add Günther Noack's Reviewed-by.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | landlock: Factor out capability denial checkssecurity/ | +27 | 0 replies | |
| 2/6 | landlock: Mediate CAP_SYS_RAWIO for mappings below mmap_min_addrsecurity/ | +22 | 0 replies | |
| 3/6 | landlock: Mediate CAP_SETPCAP for inheritable capabilitiessecurity/ | +31 | 0 replies | |
| 4/6 | landlock: Mediate CAP_SYS_ADMIN for the admin memory reservesecurity/ | +22 | 0 replies | |
| 5/6 | selftests/landlock: Test capability checks outside the capable hooktools/ tools/ | +331 | 0 replies | |
| 6/6 | landlock: Fix capability restriction documentationDocumentation/ Documentation/ include/ | +11 | 0 replies |
Reviews trailers per patch
All 6 patches have a Reviewed-by or Acked-by.
| Patch | Serge Hallyn (AMD) | Günther Noack |
|---|---|---|
| 1/6 | A-b | R-b |
| 2/6 | A-b | R-b |
| 3/6 | A-b | R-b |
| 4/6 | A-b | R-b |
| 5/6 | A-b | |
| 6/6 | A-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/6] Fix Landlock mediation of commoncap's capability checks
Hi,
This is series 1 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.
LANDLOCK_PERMISSION_CAPABILITY_USE, merged for v7.4, denies capabilities through the LSM capable hook, but commoncap's mmap_addr, capset and vm_enough_memory hooks call cap_capable() directly. A domain that denies a capability can therefore still:
- map memory below vm.mmap_min_addr (CAP_SYS_RAWIO), which defeats a mitigation for kernel NULL pointer dereferences;
- add inheritable capabilities outside of its inheritable and permitted sets (CAP_SETPCAP), which lets a privileged sandbox without no_new_privs gain capabilities through execve(), although the domain still restricts their use;
- use the admin memory reserve with vm.overcommit_memory=2 (CAP_SYS_ADMIN).
As SELinux does, patches 2 to 4 add Landlock's own check to these hooks, with commoncap's conditions, so they only deny what commoncap granted because of the capability. Patch 1 factors out the shared check. Patch 5 adds tests, including audit tests, that fail without the mmap_addr and capset fixes; testing the admin reserve would require changing system-wide overcommit settings. Patch 6 fixes the documentation, which overstated what the permission restricts and how its denials show.
Two other direct capability-set checks are fixed separately:
- PSI triggers (CAP_SYS_RESOURCE):
https://patch.msgid.link/[email protected]
- user namespace uid 0 mapping (CAP_SETFCAP):
https://patch.msgid.link/[email protected]
Changes since v2:
https://patch.msgid.link/[email protected]
- Use ASSERT_*() in the tests where later checks depend on the result, and rename a test helper parameter (suggested by Günther Noack).
- Describe the capset hook's condition from cap_capset()'s point of view (suggested by Günther Noack).
- Shorten the commit messages (suggested by Günther Noack).
- Reword the capability permission's UAPI description (suggested by Günther Noack).
- Add Günther Noack's Reviewed-by.
Changes since v1:
https://patch.msgid.link/[email protected]
- Replace the admin reserve test, which changed system-wide overcommit settings and was racy, with a comment, and fix the mmap_addr tests on 32-bit ARM (reported by Sashiko).
- Add Serge Hallyn's Acked-by.
Regards,
Mickaël Salaün (6):
landlock: Factor out capability denial checks
landlock: Mediate CAP_SYS_RAWIO for mappings below mmap_min_addr
landlock: Mediate CAP_SETPCAP for inheritable capabilities
landlock: Mediate CAP_SYS_ADMIN for the admin memory reserve selftests/landlock: Test capability checks outside the capable hook
landlock: Fix capability restriction documentation
Documentation/security/landlock.rst | 8 +- Documentation/userspace-api/landlock.rst | 8 +- include/uapi/linux/landlock.h | 7 +- security/landlock/cap.c | 111 ++++++- tools/testing/selftests/landlock/cap_test.c | 328 ++++++++++++++++++++ tools/testing/selftests/landlock/common.h | 4 +- 6 files changed, 444 insertions(+), 22 deletions(-)
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
Signature · 1 line
2.56.0