Avoid possible recursion on BPF_LOCK() in bpfwrite().
Release BPF_LOCK() before invoking if_output() and if_input(). Also enter epoch section before releasing lock, this should prevent access to ifnet that may be freed on interface detach. Reported by: markj
This commit is contained in:
parent
e8e1f0b420
commit
82d7bf6b1b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347549
@ -1257,6 +1257,9 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
ro.ro_flags = RT_HAS_HEADER;
|
||||
}
|
||||
|
||||
/* Avoid possible recursion on BPFD_LOCK(). */
|
||||
NET_EPOCH_ENTER(et);
|
||||
BPFD_UNLOCK(d);
|
||||
error = (*ifp->if_output)(ifp, m, &dst, &ro);
|
||||
if (error)
|
||||
counter_u64_add(d->bd_wdcount, 1);
|
||||
@ -1267,8 +1270,8 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
else
|
||||
m_freem(mc);
|
||||
}
|
||||
NET_EPOCH_EXIT(et);
|
||||
CURVNET_RESTORE();
|
||||
BPFD_UNLOCK(d);
|
||||
bpfd_rele(d);
|
||||
return (error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user