Hi Günther, > Date: 2026-11-20 15:17:46+0100 > From: Günther Noack > > On Wed, Nov 18, 2026 at 02:13:40AM +0100, Alejandro Colomar wrote: > > Hi Günther, > > > > > Date: 2026-11-03 21:22:06+0100 > > > From: Günther Noack > > > > > > Reword the description of SCM_SECURITY to not be specific to SELinux. > > > > > > The security context is populated in scm_passec() in linux.git > > > net/core/scm.c, through the security_secid_to_secctx() LSM hook, which > > > is currently implemented by SELinux, Smack and AppArmor. > > > > > > As clarified in [1], the returned security context is in the general > > > case a byte buffer, not a null-terminated string. The only LSM that > > > returns a buffer with trailing null byte is SELinux, but even that is > > > not guaranteed in case that the message is truncated. > > > > > > Link: [1] > > > Fixes: ffad6a017f91 (2018-07-28; "unix.7: Document SCM_SECURITY ancillary data") > > > Cc: Michael Kerrisk > > > Cc: Kuniyuki Iwashima > > > Cc: Eric Dumazet > > > Cc: Paolo Abeni > > > Cc: Willem de Bruijn > > > Assisted-by: LLM > > > Signed-off-by: Günther Noack > > > --- > > > > > > Notes: > > > This feature is also available in other LSMs. Unfortunately, they > > > implemented it inconsistently and that complicates the description of > > > how string boundaries are handled. Linux does indeed neither > > > guarantee that this terminates with a NUL byte, nor that NAME_MAX is > > > large enough to hold it. > > > > > > After confirmation from Kuniyuki Iwashima, this documents it as > > > returning a byte buffer. > > > > > > I prefer this variant over the previous longer one, also because it > > > refers to the individual LSMs for the exact format. A reader of the > > > security context will require LSM-specific documentation anyway to > > > interpret the security context. > > > > > > This patch is still LLM-assisted, but at this point, since everything > > > is rewritten now, the only LLM-assisted part is the discovery that > > > this part of the documentation could be improved. > > > > You may use 'Reported-by: LLM' for distinguishing such cases. > > Thanks, done. > > (Minor remark, btw; I have carried the Assisted-by: LLM convention > over from the Linux kernel, but they have phased that practice out now > and removed that convention from the guidelines.) Yup; I'm aware. We should still disclose it here. I personally would prefer distinguishing Suggested-by from Co-authored-by, FWIW, but at the same time I refuse to say that an LLM has authored anything (rather, it has stolen it from someone else), so Assisted-by might be more appropriate. Perhaps, I'd distinguish Reported-by, Suggested-by, and then use Assisted-by for what a human would get Co-authored-by. Have a lovely day! Alex > > > > > man/man7/unix.7 | 19 +++++++++++-------- > > > 1 file changed, 11 insertions(+), 8 deletions(-) > > > > > > diff --git a/man/man7/unix.7 b/man/man7/unix.7 > > > index 61f06a74359b..c0e2bdbacdd8 100644 > > > --- a/man/man7/unix.7 > > > +++ b/man/man7/unix.7 > > > @@ -312,7 +312,7 @@ .SS Socket options > > > is an integer boolean flag. > > > .TP > > > .B SO_PASSSEC > > > -Enables receiving of the SELinux security label of the peer socket > > > +Enables receiving of the security label of the peer socket > > > in an ancillary message of type > > > .B SCM_SECURITY > > > (see below). > > > @@ -538,13 +538,16 @@ .SS Ancillary messages > > > option must be enabled on the socket. > > > .TP > > > .B SCM_SECURITY > > > -Receive the SELinux security context (the security label) > > > -of the peer socket. > > > -The received ancillary data is a null-terminated string containing > > > -the security context. > > > -The receiver should allocate at least > > > -.B NAME_MAX > > > -bytes in the data portion of the ancillary message for this data. > > > +Receive the security context (the security label) > > > +of the peer socket, > > > +as provided by the active Linux Security Module (LSM). > > > +The received ancillary data is a byte buffer. > > > +.IP > > > +The exact format of the security context buffer > > > +is defined by the active major LSM. > > > +For example, > > > +SELinux returns a SELinux label as a string > > > +(including a terminating null byte). > > > > Considering that the interface doesn't promise to respect the null byte > > written by SELinux, I think I'd entirely remove this example, and > > instead focus on disclaiming that regardless of the format, the buffer > > is truncated in a way that destroys the format. > > > > I'm not an expert of this feature (actually, never used it at all), so > > maybe some silly question: > > > > How is a user supposed to know how much space to provide to prevent this > > problematic truncation? Is there a buffer size that will guarantee no > > truncation? If so, we should instruct programmers to use it. And if > > there's no possible size that fits all, we should probably warn about > > it. > > The required space for the buffers is again dependent on LSM; in some > LSMs, the buffer can (theoretically) be unbounded, but it's possible > that you can calculate a maximum size if you understand how these LSMs > are configured... > > I removed the example and will point out that truncation may happen in > a buffer-unaware format, if the caller-nprovided buffer is not large > enough. > > Thanks for the review! > –Günther > --