Page MenuHomeFreeBSD

bpf: don't clear pointer from descriptor to the tap on descriptor close
ClosedPublic

Authored by glebius on Mon, Feb 2, 9:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 25, 9:43 PM
Unknown Object (File)
Fri, Feb 20, 8:35 PM
Unknown Object (File)
Tue, Feb 17, 11:16 AM
Unknown Object (File)
Tue, Feb 17, 9:34 AM
Unknown Object (File)
Tue, Feb 17, 9:34 AM
Unknown Object (File)
Tue, Feb 10, 10:54 AM
Unknown Object (File)
Tue, Feb 10, 10:27 AM
Unknown Object (File)
Tue, Feb 10, 5:56 AM
Subscribers

Details

Summary

During packet processing the descriptor is looked up using epoch(9) and it
can be accessed after bpf_detachd(). In scenario of descriptor close the
tap point is alive (it actually produces packets) and thus the pointer can
be legitimately dereferenced. This fixes a race on a bpf(4) device close
that would otherwise result in panic.

Diff Detail

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

Event Timeline

Is bpf_chkdir() dereferencing a NULL d->bd_bif in net epoch ?

bpfwrite() is locked checking d->bd_bif == NULL and returns ENXIO incase true, and if not, will bpfwrite() then possibly reference a freed bpf_if ?

Is bpf_chkdir() dereferencing a NULL d->bd_bif in net epoch ?

Yes.

bpfwrite() is locked checking d->bd_bif == NULL and returns ENXIO incase true, and if not, will bpfwrite() then possibly reference a freed bpf_if ?

I did not test the writer descriptor case. The panic I'm fixing is about detaching bpf reader. And your question is quite orthogonal: it is not about detaching descriptor, it is a about detaching tap. I can't answer right away, except that suggested patch should neither improve nor regress a scenario with detaching tap. As you see, we still set pointer to NULL when tap is detaching.

This revision was not accepted when it landed; it landed in state Needs Review.Wed, Feb 4, 10:07 PM
This revision was automatically updated to reflect the committed changes.