HomeFreeBSD

inpcb: Further restrict binding to a port owned by a different UID

Description

inpcb: Further restrict binding to a port owned by a different UID

See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INADDR_ANY. Looking at the sdr.V2.4a7n sources (mentioned in
bugzilla PR 7713), there is a CANT_MCAST_BIND hack wherein the
application binds to INADDR_ANY instead of a multicast address, but
CANT_MCAST_BIND isn't defined for FreeBSD builds.

It seems unlikely that we still have a use-case for allowing sockets
from different UIDs to bind to the same port when binding to the
unspecified address. And, as noted in D47832, applications like sdr
would have been broken by the inverted SO_REUSEPORT check removed in
that revision, apparently without any bug reports. Let's break
compatibility and simply disallow this case outright.

Also, add some comments, remove a hack in a regression test which tests
this funtionality, and add a new regression test to exercise the
remaining checks that were added in commit 4658dc8325e03.

MFC after: 1 month
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D47870

(cherry picked from commit c9756953bded0d8428027fa3e812c9bdac069252)

Details

Provenance
markjAuthored on Dec 23 2024, 3:31 PM
Differential Revision
D47870: inpcb: Further restrict binding to a port owned by a different UID
Parents
rG1a1a1728e0be: kern_sysctl: Make name2oid() non-destructive to the name
Branches
Unknown
Tags
Unknown