From: Alejandro Colomar <alx+linux-man@kernel.org>
To: "Günther Noack" <gnoack3000@gmail.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
linux-man@vger.kernel.org,
Michael Kerrisk <mtk.manpages@gmail.com>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH v2 4/8] man/man7/unix.7: SCM_SECURITY: Generalize to other LSMs, not just SELinux
Date: Fri, 20 Nov 2026 15:41:10 +0100 [thread overview]
Message-ID: <awBavx8g4q9pCZpZ@devuan> (raw)
In-Reply-To: <20261120.790f70cab7b5@gnoack.org>
[-- Attachment #1: Type: text/plain, Size: 5901 bytes --]
Hi Günther,
> Date: 2026-11-20 15:17:46+0100
> From: Günther Noack <gnoack3000@gmail.com>
>
> 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 <gnoack3000@gmail.com>
> > >
> > > 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] <https://lore.kernel.org/all/auZcwYWv0NeiIR8d@google.com/>
> > > Fixes: ffad6a017f91 (2018-07-28; "unix.7: Document SCM_SECURITY ancillary data")
> > > Cc: Michael Kerrisk <mtk.manpages@gmail.com>
> > > Cc: Kuniyuki Iwashima <kuniyu@google.com>
> > > Cc: Eric Dumazet <edumazet@kernel.org>
> > > Cc: Paolo Abeni <pabeni@redhat.com>
> > > Cc: Willem de Bruijn <willemb@google.com>
> > > Assisted-by: LLM
> > > Signed-off-by: Günther Noack <gnoack3000@gmail.com>
> > > ---
> > >
> > > 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
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-11-20 14:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 20:22 [PATCH v2 0/8] unix.7: Socket Options and SCM_* fixes Günther Noack
2026-11-03 20:22 ` [PATCH v2 1/8] man/man7/unix.7: ERRORS: ETOOMANYREFS: Fix the conditions Günther Noack
2026-11-06 13:00 ` Alejandro Colomar
2026-11-03 20:22 ` [PATCH v2 2/8] man/man7/unix.7: Multiple same-typed SCM_* messages may be sent in one message Günther Noack
2026-11-16 0:52 ` Kuniyuki Iwashima
2026-11-18 0:59 ` Alejandro Colomar
2026-11-03 20:22 ` [PATCH v2 3/8] man/man7/unix.7: Autobind: Clarify when it happens, and mention SO_PASSPIDFD Günther Noack
2026-11-16 0:53 ` Kuniyuki Iwashima
2026-11-18 1:06 ` Alejandro Colomar
2026-11-03 20:22 ` [PATCH v2 4/8] man/man7/unix.7: SCM_SECURITY: Generalize to other LSMs, not just SELinux Günther Noack
2026-11-16 0:55 ` Kuniyuki Iwashima
2026-11-16 7:35 ` Günther Noack
2026-11-18 1:15 ` Alejandro Colomar
2026-11-18 1:13 ` Alejandro Colomar
2026-11-20 14:17 ` Günther Noack
2026-11-20 14:41 ` Alejandro Colomar [this message]
2026-11-20 14:42 ` Alejandro Colomar
2026-11-03 20:22 ` [PATCH v2 5/8] man/man7/unix.7: SO_PASSSEC: wfix Günther Noack
2026-11-03 20:22 ` [PATCH v2 6/8] man/man7/unix.7: Document SO_PASSPIDFD, SO_PEERPIDFD, and SCM_PIDFD Günther Noack
2026-11-16 1:03 ` Kuniyuki Iwashima
2026-11-18 16:24 ` Christian Brauner
2026-11-20 15:59 ` Günther Noack
2026-11-03 20:22 ` [PATCH v2 7/8] man/man7/unix.7: Document SO_PASSRIGHTS Günther Noack
2026-11-16 1:02 ` Kuniyuki Iwashima
2026-11-03 20:22 ` [PATCH v2 8/8] man/man7/unix.7: Remove mentions of "namespace" in the general sense Günther Noack
2026-11-16 0:59 ` Kuniyuki Iwashima
2026-11-19 23:37 ` [PATCH v2 0/8] unix.7: Socket Options and SCM_* fixes Alejandro Colomar
2026-11-20 16:02 ` Günther Noack
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=awBavx8g4q9pCZpZ@devuan \
--to=alx+linux-man@kernel.org \
--cc=edumazet@kernel.org \
--cc=gnoack3000@gmail.com \
--cc=kuniyu@google.com \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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