public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* UNIX(7)
@ 2023-12-01 12:16 Alexey Tikhonov
  2023-12-01 12:54 ` UNIX(7) Alejandro Colomar
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Tikhonov @ 2023-12-01 12:16 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man, libc-alpha

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-21 12:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01 12:16 UNIX(7) Alexey Tikhonov
2023-12-01 12:54 ` UNIX(7) Alejandro Colomar
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).