HomeFreeBSD

Don't read if_counters with if_addr_lock held

Description

Don't read if_counters with if_addr_lock held

Calling into an ifnet implementation with the if_addr_lock already
held can cause a LOR and potentially a deadlock, as ifnet
implementations typically can take the if_addr_lock after their
own locks during configuration. Refactor a sysctl handler that
was violating this to read if_counter data in a temporary buffer
before the if_addr_lock is taken, and then copying the data
in its final location later, when the if_addr_lock is held.

PR: 194109
Reported by: Jean-Sebastien Pedron
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D8498
Reviewed by: sbruno

Details

Provenance
rstoneAuthored on
Reviewer
sbruno
Differential Revision
D8498: Don't read if_counters with if_addr_lock held
Parents
rS308579: Do not report error on close even if we have no paths left.
Branches
Unknown
Tags
Unknown