Page MenuHomeFreeBSD

bpf: Fix ifpromisc() locking
ClosedPublic

Authored by markj on Aug 4 2022, 5:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 1:34 AM
Unknown Object (File)
Sun, Oct 12, 1:34 AM
Unknown Object (File)
Sun, Oct 12, 1:34 AM
Unknown Object (File)
Sat, Oct 11, 4:02 PM
Unknown Object (File)
Sat, Sep 27, 10:38 PM
Unknown Object (File)
Thu, Sep 18, 10:38 PM
Unknown Object (File)
Mon, Sep 15, 1:48 AM
Unknown Object (File)
Sun, Sep 14, 1:29 PM

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.