Page MenuHomeFreeBSD

inpcb: Fix some bugs in _in_pcbinshash_wild()
AbandonedPublic

Authored by markj on Apr 23 2023, 3:12 PM.
Tags
None
Referenced Files
F132469018: D39771.diff
Fri, Oct 17, 4:50 AM
Unknown Object (File)
Tue, Oct 14, 9:39 AM
Unknown Object (File)
Thu, Oct 9, 7:09 PM
Unknown Object (File)
Wed, Oct 8, 5:31 PM
Unknown Object (File)
Sat, Oct 4, 2:56 AM
Unknown Object (File)
Aug 20 2025, 2:08 AM
Unknown Object (File)
Aug 14 2025, 10:49 PM
Unknown Object (File)
Jul 5 2025, 7:30 PM

Details

Reviewers
glebius
karels
Group Reviewers
network
Summary
  • In _in_pcbinshash_wild(), we should avoid returning v6 sockets unless no other matches are available. This preserves pre-existing semantics.
  • Fix an inverted test: when inserting a non-jailed PCB, we want to search for the first non-jailed PCB in the hash chain.
  • Test the right PCB when searching for a non-jailed PCB.

While here, add a required locking assertion.

Fixes: 7b92493ab1d4 ("inpcb: Avoid inp_cred dereferences in SMR-protected lookup")

Test Plan

The second bug broke ntpd, and with this patch the problem is gone.

I'm working on some regression tests for the PCB matching logic.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 51141
Build 48032: arc lint + arc unit