Page MenuHomeFreeBSD

bpf: Detach descriptors on interface vmove event
ClosedPublic

Authored by zlei on Jun 25 2024, 9:08 AM.
Tags
None
Referenced Files
F109748831: D45727.id.diff
Sun, Feb 9, 1:26 AM
Unknown Object (File)
Wed, Feb 5, 1:15 PM
Unknown Object (File)
Tue, Feb 4, 3:16 PM
Unknown Object (File)
Tue, Jan 28, 10:02 PM
Unknown Object (File)
Mon, Jan 27, 10:38 AM
Unknown Object (File)
Sat, Jan 25, 4:36 PM
Unknown Object (File)
Jan 9 2025, 12:04 PM
Unknown Object (File)
Jan 2 2025, 10:24 PM

Details

Summary

When an interface is moving to/from jail, it is still attached to bpf
and the consumers, tcpdump(1) e.g., do not get noticed. That is
counterintuitive and may leak informations ( sniffer traffic in parent
jail/vnet ).

MFC after: 1 week

Test Plan

One session:

# tcpdump -nvi cxl0
tcpdump: listening on cxl0, link-type EN10MB (Ethernet), snapshot length 262144 bytes

Another session:

# jail -ic vnet persist
1
# ifconfig cxl0 vnet 1

On first session

tcpdump: pcap_loop: The interface disappeared
0 packets captured
0 packets received by filter
0 packets dropped by kernel

Diff Detail

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

Event Timeline

zlei requested review of this revision.Jun 25 2024, 9:08 AM

You probably can directly call similar to bpf_ifdetach() function from if_vmove(). It is called from ioctl context, so you can make detaching synchronously.

In D45727#1066919, @ae wrote:

You probably can directly call similar to bpf_ifdetach() function from if_vmove(). It is called from ioctl context, so you can make detaching synchronously.

I've ever considered that approach, and finally chose this, the even handler. The latter is self constrained and loosely coupled, although with a little overhead of brainpower.

I'd like to push this to main and MFC to stable/14. Any objections ?

cy added inline comments.
sys/net/bpf.c
3146

Shouldn't whitespace adjustments be their own commit?

zlei marked an inline comment as done.Oct 21 2024, 2:59 AM
zlei added inline comments.
sys/net/bpf.c
3146

Yeah, actually this drives me to do 1baf6164e4d6 (bpf: Some style and white space cleanup), which includes this whitespace adjustment.

zlei marked an inline comment as done.

Rebased onto latest main.

zlei retitled this revision from bpf: Detach descriptors on interface departure event to bpf: Detach descriptors on interface vmove event.
zlei edited the summary of this revision. (Show Details)

Think it twice, it is straight forward to synchronously detach the BPF descriptors. The logic is also simpler.

I thought too much on this. @ae Are you OK with this revision ?

This revision is now accepted and ready to land.Tue, Feb 4, 9:28 AM