From: Matthieu Buffet <matthieu@buffet.re>
To: "Alejandro Colomar" <alx@kernel.org>,
"Günther Noack" <gnoack3000@gmail.com>
Cc: "Mickaël Salaün" <mic@digikod.net>,
linux-man@vger.kernel.org, "Matthieu Buffet" <matthieu@buffet.re>
Subject: [PATCH v3] man/man?/landlock*.?: Document UDP support
Date: Sun, 15 Nov 2026 21:58:27 +0100 [thread overview]
Message-ID: <20261115205827.136147-1-matthieu@buffet.re> (raw)
In-Reply-To: <bc495b26-2e26-4fc0-934b-37d55cb423a8@buffet.re>
Landlock support for UDP-specific policy was merged in 7.2 in
linux.git 9a8ed15ce224 ("landlock: Add UDP bind() access control")
and
linux.git e61247a2e694 ("landlock: Add UDP send+connect access control")
Add documentation for new access rights, taken from the UAPI header with
minor deviations to be backported into it:
- clarify the most non-trivial behavior (auto-bind denials when sending
if BIND_UDP is handled) without restricting to the case where
CONNECT_SEND_UDP is handled
- improve description of how AF_UNSPEC destination addresses behave:
connect() is always allowed, sending is always denied (instead of just
"not supported") on IPv6 UDP sockets
- minor wording improvements, nothing else semantically different
Link: <https://github.com/landlock-lsm/linux/issues/66>
Signed-off-by: Matthieu Buffet <matthieu@buffet.re>
---
Changes v1->v2:
- Remove bind(AF_UNSPEC) behavior note, connect(AF_UNSPEC) note is
reduced to a few words merged into a single patch
- Phrasing clarification
- Man formatting and etiquette
Changes v2->v3:
- Minor ephemeral port range rewording patch has already been merged,
only one patch left
- Reword the sendto/sendmsg(AF_UNSPEC) note: we are talking about
explicit addresses of AF_UNSPEC family on a domain=IPv6&type=UDP
socket
- Punctuation+phrasing
man/man2/landlock_add_rule.2 | 15 ++++++--
man/man7/landlock.7 | 75 +++++++++++++++++++++++++++++++++++-
2 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/man/man2/landlock_add_rule.2 b/man/man2/landlock_add_rule.2
index 253498bfa2cf..9ff470a988d2 100644
--- a/man/man2/landlock_add_rule.2
+++ b/man/man2/landlock_add_rule.2
@@ -82,7 +82,7 @@ just a file.
.TP
.BR LANDLOCK_RULE_NET_PORT " (since Landlock ABI version 4)"
For these rules,
-the object is a TCP port,
+the object is a TCP or UDP port,
and the related actions are defined with
.IR "network access rights" .
.IP
@@ -120,8 +120,14 @@ with
A Landlock rule with port 0
and the
.B LANDLOCK_ACCESS_NET_BIND_TCP
-right means that requesting to bind on port 0 is allowed
-and it will automatically translate to binding on the related port range.
+or
+.B LANDLOCK_ACCESS_NET_BIND_UDP
+right means that requesting to bind to port 0
+(explicitly or implicitly,
+e.g., by sending a datagram on an unbound UDP socket)
+is allowed,
+and it will automatically translate to
+binding on a kernel-assigned ephemeral port.
.P
.I flags
is a bit mask of the following optional flags:
@@ -181,7 +187,8 @@ can fail for the following reasons:
.I rule_type
is
.BR LANDLOCK_RULE_NET_PORT ,
-but TCP is not supported by the running kernel.
+but the kernel was built without
+.BR CONFIG_INET .
.TP
.B EBADF
.I ruleset_fd
diff --git a/man/man7/landlock.7 b/man/man7/landlock.7
index 006482c94e34..7e48fc5329d7 100644
--- a/man/man7/landlock.7
+++ b/man/man7/landlock.7
@@ -53,8 +53,8 @@ For these rules, the object is a file hierarchy,
and the related filesystem actions are defined with
.IR "filesystem access rights" .
.TP
-.BR "Network rules" " (since ABI v4)"
-For these rules, the object is a TCP port,
+.BR "Network rules" " (since ABI v4 for TCP, v10 for UDP)"
+For these rules, the object is a TCP or UDP port,
and the related actions are defined with
.IR "network access rights" .
.\"
@@ -279,6 +279,75 @@ Bind a TCP socket to a local port.
.TP
.BR LANDLOCK_ACCESS_NET_CONNECT_TCP " (since Landlock ABI version 4)"
Connect an active TCP socket to a remote port.
+.P
+And similarly for UDP port numbers:
+.TP
+.BR LANDLOCK_ACCESS_NET_BIND_UDP " (since Landlock ABI version 10)"
+Bind UDP sockets to the given local port.
+.TP
+.BR LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP " (since Landlock ABI version 10)"
+Set the remote port of UDP sockets to the given port,
+or send datagrams to the given remote port
+ignoring any destination pre-set on a socket.
+.P
+Note on auto-binding:
+Setting a remote address
+or sending a first datagram
+auto-binds
+UDP sockets
+to an ephemeral local source port
+if not already bound.
+To allow this if
+.B LANDLOCK_ACCESS_NET_BIND_UDP
+is handled
+(even if
+.B LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP
+is not),
+either:
+.IP \[bu] 3
+use a socket already bound to a port
+before the ruleset started being enforced;
+.IP \[bu] 3
+grant
+.B LANDLOCK_ACCESS_NET_BIND_UDP
+on port 0, meaning
+\[lq]any port in the ephemeral port range\[rq];
+.IP \[bu] 3
+grant
+.B LANDLOCK_ACCESS_NET_BIND_UDP
+on a specific port,
+and call
+.BR bind (2)
+on that port before trying to
+.BR connect (2)
+or send datagrams.
+.P
+Note on
+.BR AF_UNSPEC :
+Calling
+.BR connect (2)
+on a TCP or UDP socket
+with an address of the
+.B AF_UNSPEC
+family
+can only dissolve existing associations,
+and as such is always allowed.
+If
+.B LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP
+is handled,
+sending datagrams to explicit addresses of the
+.B AF_UNSPEC
+family on IPv6 UDP sockets
+is not supported
+and always results in a denial,
+as if the policy rejected it:
+use a
+.I NULL
+address instead to get the same semantics
+inside and outside a Landlock domain.
+Other uses of the
+.B AF_UNSPEC
+family have unchanged semantics.
.\"
.SS Scope flags
These flags enable isolating a sandboxed process from a set of IPC actions.
@@ -534,6 +603,8 @@ _ _ _
9 7.1 LANDLOCK_ACCESS_FS_RESOLVE_UNIX
_ _ _
10 7.2 LANDLOCK_ADD_RULE_QUIET
+\^ \^ LANDLOCK_ACCESS_NET_BIND_UDP
+\^ \^ LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP
.TE
.P
Users should use the Landlock ABI version rather than the kernel version
base-commit: 9dc90054e92357bbe4c44f9c2a38c111f8ed7374
--
2.47.3
next prev parent reply other threads:[~2026-11-15 20:58 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 7:58 [PATCH 0/3] Add Landlock UDP support documentation Matthieu Buffet
2026-09-17 7:58 ` [PATCH 1/3] man/man2/landlock_add_rule.2: Clarify ephemeral port range Matthieu Buffet
2026-09-26 10:00 ` Günther Noack
2026-09-29 19:02 ` Mickaël Salaün
2026-09-17 7:58 ` [PATCH 2/3] man/man7/landlock.7: Document AF_UNSPEC behaviour and error codes Matthieu Buffet
2026-09-26 10:13 ` Günther Noack
2026-09-17 7:58 ` [PATCH 3/3] man/man7/landlock.7, man/man2/landlock_add_rule.2: Document UDP support Matthieu Buffet
2026-09-26 14:01 ` Günther Noack
2026-09-29 19:03 ` Mickaël Salaün
2026-09-29 19:02 ` [PATCH 0/3] Add Landlock UDP support documentation Mickaël Salaün
2026-10-30 19:24 ` Günther Noack
2026-11-02 23:37 ` Matthieu Buffet
2026-11-02 23:39 ` [PATCH v2 1/2] man/man2/landlock_add_rule.2: Clarify ephemeral port range Matthieu Buffet
2026-11-02 23:39 ` [PATCH v2 2/2] man/man?/landlock*.?: Document UDP support Matthieu Buffet
2026-11-06 22:02 ` Günther Noack
2026-11-07 11:15 ` Alejandro Colomar
2026-11-15 20:55 ` Matthieu Buffet
2026-11-15 20:58 ` Matthieu Buffet [this message]
2026-11-15 21:18 ` Alejandro Colomar
2026-11-15 21:53 ` G. Branden Robinson
2026-11-17 9:47 ` Alejandro Colomar
2026-11-06 21:24 ` [PATCH v2 1/2] man/man2/landlock_add_rule.2: Clarify ephemeral port range Günther Noack
2026-11-07 11:10 ` Alejandro Colomar
2026-11-03 0:24 ` [PATCH 0/3] Add Landlock UDP support documentation Alejandro Colomar
2026-11-03 9:04 ` Matthieu Buffet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261115205827.136147-1-matthieu@buffet.re \
--to=matthieu@buffet.re \
--cc=alx@kernel.org \
--cc=gnoack3000@gmail.com \
--cc=linux-man@vger.kernel.org \
--cc=mic@digikod.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox