Page MenuHomeFreeBSD

inpcb: Fix reuseport lbgroup array resizing
ClosedPublic

Authored by markj on Feb 21 2025, 9:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 9, 4:54 PM
Unknown Object (File)
Wed, Apr 9, 3:02 PM
Unknown Object (File)
Mar 17 2025, 8:36 PM
Unknown Object (File)
Mar 17 2025, 2:41 PM
Unknown Object (File)
Mar 15 2025, 5:16 PM
Unknown Object (File)
Mar 9 2025, 8:05 AM
Unknown Object (File)
Mar 6 2025, 1:56 PM
Unknown Object (File)
Feb 27 2025, 10:28 AM

Details

Summary

in_pcblisten() moves an inpcb from the per-group list into the array, at
which point it becomes visible to inpcb lookups in the datapath. It
assumes that there is space in the array for this, but that's not
guaranteed, since in_pcbinslbgrouphash() doesn't reserve space in the
array if the inpcb isn't associated with a listening socket.

We could resize the array in in_pcblisten(), but that would introduce a
failure case where there currently is none. Instead, keep track of the
number of pending inpcbs as well, and modify in_pcbinslbgrouphash() to
reserve space for each pending (i.e., not-yet-listening) inpcb.

Reported by: netchild
Fixes: 7cbb6b6e28db ("inpcb: Close some SO_REUSEPORT_LB races, part 2")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Feb 21 2025, 9:30 PM

How does this manifests self? It writes beyond array, I guess. Could this be the fix to the syzkaller panic reported today?

This revision is now accepted and ready to land.Feb 22 2025, 1:54 AM

In my case I got
panic: invalid local group size 16 and count 16

How does this manifests self? It writes beyond array, I guess. Could this be the fix to the syzkaller panic reported today?

Yes, or it's caught by the KASSERT check in in_pcblbgroup_insert().

I don't think it's related to the syzkaller panic: we would see this assertion failure instead, and in the logs for those panics I see no use of SO_REUSEPORT_LB.

Add a regression test case which triggers the bug.

This revision now requires review to proceed.Feb 22 2025, 2:39 PM
This revision is now accepted and ready to land.Feb 23 2025, 5:05 AM
This revision was automatically updated to reflect the committed changes.