linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/7] landlock: Add UDP access control support
@ 2024-09-16 12:22 Matthieu Buffet
  2024-09-16 12:22 ` [RFC PATCH v1 1/7] samples/landlock: Fix port parsing in sandboxer Matthieu Buffet
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Matthieu Buffet @ 2024-09-16 12:22 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Günther Noack, Paul Moore, James Morris, Serge E . Hallyn,
	linux-security-module, linux-kernel, netdev, Matthieu Buffet

Landlocked processes can freely use UDP sockets. This may allow them to
escape their sandbox if they can reach UDP sockets of other vulnerable
processes on the same host, or allow them to send/receive to/from unwanted
hosts.

This is a first attempt to add access control around UDP usage, based on
https://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git
Linux 6.11-rc1 (8400291e289e).

The first two commits fix what I interpret as a bug in landlock's sample's
options parsing, in order to allow testing the actual patch contents.
These two are finished afaict and could be merged separately, but are
bundled here to have a working base-commit and allow the actual patch to
get a first round of feedback.

Add two new access rights in the same bind/connect hooks as used for
TCP, with the same semantics.

Also add two new hooks in recvmsg/sendmsg and two additional rights,
because:
- UDP allows processes to send traffic to anyone without any `bind()` nor
  `connect()` by specifying an arbitrary address in `sendmsg()`, so
  simply using existing hooks cannot prevent sending that traffic;
- UDP allows processes to receive traffic on ephemeral ports without any
  `bind()` (e.g. just `sendmsg()` to 127.0.0.1 to get a port assigned, then
  you can `recv()` on that port).

When benchmarking `iperf3 --udp` with and without sendmsg/recvmsg
sandboxing, the difference appears negligible on my laptop, which makes
me think I'm looking at a completely unrelated bottleneck somewhere else.
Advice or tests from someone with non-potato hardware and benchmarking
knowledge would be appreciated.

Selftests updated for UDP, coverage should encompass all non-critical-error
paths.

This is a first kernel patch attempt, any feedback appreciated.

Link: https://github.com/landlock-lsm/linux/issues/10

Matthieu Buffet (7):
  samples/landlock: Fix port parsing in sandboxer
  samples/landlock: Clarify option parsing behaviour
  landlock: Add UDP bind+connect access control
  landlock: Add UDP send+recv access control
  samples/landlock: Add sandboxer UDP access control
  selftests/landlock: Adapt existing tests for UDP
  selftests/landlock: Add UDP sendmsg/recvmsg tests

 include/uapi/linux/landlock.h                |  58 ++-
 samples/landlock/sandboxer.c                 | 181 +++++--
 security/landlock/limits.h                   |   2 +-
 security/landlock/net.c                      | 255 +++++++--
 security/landlock/syscalls.c                 |   2 +-
 tools/testing/selftests/landlock/base_test.c |   2 +-
 tools/testing/selftests/landlock/net_test.c  | 518 +++++++++++++++++--
 7 files changed, 886 insertions(+), 132 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-10-21  9:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 12:22 [RFC PATCH v1 0/7] landlock: Add UDP access control support Matthieu Buffet
2024-09-16 12:22 ` [RFC PATCH v1 1/7] samples/landlock: Fix port parsing in sandboxer Matthieu Buffet
2024-09-20 13:38   ` Mickaël Salaün
2024-09-23 15:24   ` Mikhail Ivanov
2024-09-16 12:22 ` [RFC PATCH v1 2/7] samples/landlock: Clarify option parsing behaviour Matthieu Buffet
2024-09-20 13:38   ` Mickaël Salaün
2024-09-16 12:22 ` [RFC PATCH v1 3/7] landlock: Add UDP bind+connect access control Matthieu Buffet
2024-09-20 13:39   ` Mickaël Salaün
2024-09-16 12:22 ` [RFC PATCH v1 4/7] landlock: Add UDP send+recv " Matthieu Buffet
2024-09-21 10:23   ` Mickaël Salaün
2024-10-19 12:47     ` Matthieu Buffet
2024-10-21  9:57       ` Mickaël Salaün
2024-09-16 12:22 ` [RFC PATCH v1 5/7] samples/landlock: Add sandboxer UDP " Matthieu Buffet
2024-10-04 15:04   ` Mickaël Salaün
2024-09-16 12:22 ` [RFC PATCH v1 6/7] selftests/landlock: Adapt existing tests for UDP Matthieu Buffet
2024-09-16 12:22 ` [RFC PATCH v1 7/7] selftests/landlock: Add UDP sendmsg/recvmsg tests Matthieu Buffet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).