[CC += Branden] Hi Matthieu, > Date: 2026-11-15 21:55:50+0100 > From: Matthieu Buffet > > Hi Günther, Alejandro, > > On 11/6/26 11:02 PM, Günther Noack wrote: > > On Tue, Nov 03, 2026 at 12:39:32AM +0100, Matthieu Buffet wrote: > >> 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 on port 0 > >> +(explicitly, or implicitly > >> +for instance by sending a datagram on an unbound UDP socket) > >> +is allowed > >> +and it will automatically translate to binding on a kernel-assigned > ephemeral port. > > > > With the caveat of not being a native speaker either, the commas in > > this sentence feel wrong to me. > > I was trying to make the comma match the fact that the example only applies > to the implicit case, but if it sounds wrong let's use your suggestion. Perhaps you could use two levels of separation, with ';': (explicitly; or implicitly, for instance, by sending a datagram ...) But this is a bit beyond my expertise. I've CCd Branden, which will surely be able to help. Have a lovely night! Alex > > >> +To allow this if > >> +.B LANDLOCK_ACCESS_NET_BIND_UDP > >> +is handled > >> +(even if > >> +.B LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP > >> +is not), > > > > This phrasing is different to the kernel documentation, where it says: > > > > To allow this if both LANDLOCK_ACCESS_NET_BIND_UDP and > > LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP are handled, [...] > > > > (see https://docs.kernel.org/userspace-api/landlock.html) > > > > Is this intentional? > > Absolutely, it's bullet point #1 (the most important imho) in the three > divergences I listed in the patch description. My current text in the kernel > docs is not technically wrong, but it does not highlight the most > non-trivial case (connect+send not handled, but bind handled, causing > connect+send denials). > > >> +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. > >> +On IPv6 UDP sockets, if > >> +.B LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP > >> +is handled, > >> +sending datagrams to > >> +.B AF_UNSPEC > >> +addresses is not supported > >> +and will always result 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. > > > > This second "note" discussion seems to deviate in its meaning from > > what the second "note" box said in the kernel documentation. > > > > https://docs.kernel.org/userspace-api/landlock.html#network-flags > > > > Is this intentional? > > Yes that's bullet point #2, a better description ("always result in a > denial, as if the policy rejected it" instead of just "not supported") of > this deviation from normal network stack behavior. > > > I admittedly have trouble following the documentation in this > > rewritten note (and also the kernel documentation). What does > > "sending datagrams to AF_UNSPEC" mean in the context of IPv6? > > You are correct about connect(AF_UNSPEC) semantics, and here I meant > sendto()/sendmsg()/etc. on an IPv6 UDP socket with a msg_name whose family > is AF_UNSPEC (which is interpreted as "no address" by the network stack). I > changed this to a hopefully more explicit wording in v3. > > > Is the new man page phrasing one that you'd also like to carry over > > into the kernel documentation? > > Absolutely, tell me what you think about v3, and once we agree on the > changes I will send a patch to sync them into the docs. > > Have a nice day! > > Matthieu --