Page MenuHomeFreeBSD

inpcb: Fix reuseport lbgroup array resizing
Needs ReviewPublic

Authored by markj on Fri, Feb 21, 9:30 PM.
Tags
None
Referenced Files
F110749521: D49100.diff
Sat, Feb 22, 2:57 PM
F110749443: D49100.diff
Sat, Feb 22, 2:56 PM
F110734156: D49100.diff
Sat, Feb 22, 11:33 AM
Unknown Object (File)
Fri, Feb 21, 9:32 PM

Details

Reviewers
glebius
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 62577
Build 59461: arc lint + arc unit

Event Timeline

markj requested review of this revision.Fri, Feb 21, 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.Sat, Feb 22, 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.Sat, Feb 22, 2:39 PM