From: Alejandro Colomar <alx@kernel.org>
To: Alexey Tikhonov <atikhono@redhat.com>
Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org,
netdev@vger.kernel.org
Subject: Re: UNIX(7)
Date: Fri, 1 Dec 2023 13:54:39 +0100 [thread overview]
Message-ID: <ZWnXlcsVJfPO1Qsb@debian> (raw)
In-Reply-To: <CABPeg3a9L0142gmdZZ+0hoD+Q3Vgv0BQ21g8Z+gf2kznWouErA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]
Hello Alexey,
On Fri, Dec 01, 2023 at 01:16:27PM +0100, Alexey Tikhonov wrote:
> Hello.
>
> There is a discrepancy between the man page description of
> 'SO_PEERCRED' and real behavior.
>
> `man 7 unix` states:
> ```
> SO_PEERCRED
> This read-only socket option returns the credentials of
> the peer process connected to this socket. The returned
> credentials are those that were in effect at the time of
> the call to connect(2) or socketpair(2).
> ```
>
> This doesn't match real behavior in following situation (just an example):
> - process starts with uid=0, gid=0
> - process creates UNIX socket, binds it, listens on it
> - process changes to uid=uid1, git=gid1 (using `setresuid()`, `setresgid()`)
> - another process connects to the listening socket and requests
> peer's credentials using `getsockopt(... SOL_SOCKET, SO_PEERCRED ...)`
>
> According to the man page: SO_PEERCRED should report (uid1, gid1),
> because peer process was running under (uid1, gid1) "at the time of
> the call to connect(2)"
> In reality SO_PEERCRED reports (0, 0)
> Reproducing code is available in
> https://bugzilla.redhat.com/show_bug.cgi?id=2247682
>
> I'm not entirely sure if this is a real bug or rather a poor
> description in the man page, but I tend to think that it's the latter.
I've CCed netdev@, since they probably know better.
Thanks,
Alex
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-12-01 12:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 12:16 UNIX(7) Alexey Tikhonov
2023-12-01 12:54 ` Alejandro Colomar [this message]
2023-12-01 22:07 ` UNIX(7) Kuniyuki Iwashima
2023-12-04 10:11 ` UNIX(7) Alexey Tikhonov
2023-12-20 18:05 ` [patch] unix.7: SO_PEERCRED: Mention listen(2) Alexey Tikhonov
2023-12-21 1:49 ` [PATCH] " Kuniyuki Iwashima
2023-12-21 12:15 ` Alejandro Colomar
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=ZWnXlcsVJfPO1Qsb@debian \
--to=alx@kernel.org \
--cc=atikhono@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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