Page MenuHomeFreeBSD

bpf: Fix ifpromisc() locking
ClosedPublic

Authored by markj on Aug 4 2022, 5:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 19, 4:44 AM
Unknown Object (File)
Dec 22 2023, 9:46 PM
Unknown Object (File)
Aug 26 2023, 1:43 AM
Unknown Object (File)
Aug 8 2023, 3:28 AM
Unknown Object (File)
Aug 8 2023, 3:27 AM
Unknown Object (File)
Aug 8 2023, 3:18 AM
Unknown Object (File)
May 11 2023, 9:01 PM
Unknown Object (File)
Apr 8 2023, 11:03 AM

Details

Summary

BPF might put an interface in promiscuous mode when handling the
BIOCSDLT ioctl. When this happens, a flag is set in the BPF descriptor
so that the old interface can be restored when the BPF descriptor is
destroyed.

The BIOCPROMISC ioctl can also be used to put a BPF descriptor's
interface into promiscuous mode, but there was nothing synchronizing the
flag. Fix this by modifying the ioctl handler to acquire the global BPF
mutex.

Diff Detail

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

Event Timeline

markj requested review of this revision.Aug 4 2022, 5:16 PM
This revision is now accepted and ready to land.Aug 5 2022, 6:05 AM
melifaro added inline comments.
sys/net/bpf.c
1529

Nit: maybe set error to 0 initially to avoid an additional condition?

markj marked an inline comment as done.Aug 5 2022, 8:24 PM
markj added inline comments.
sys/net/bpf.c
1529

This branch is redundant, we can assume that error is already initialized to zero. That's what this handler did before, and others make the same assumption. So I'll just remove this bit.

This revision was automatically updated to reflect the committed changes.
markj marked an inline comment as done.