Page MenuHomeFreeBSD

bpf: Fix ifpromisc() locking
ClosedPublic

Authored by markj on Thu, Aug 4, 5:16 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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

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

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

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

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.