netfilter: egress: silence egress hook lockdep splats
Florian Westphal
maintainerPATCH 1/1 netfilter: egress: silence egress hook lockdep splats
Netfilter assumes its called with rcu_read_lock held, but in egress hook case it may be called with BH readlock.
This triggers lockdep splat.
In order to avoid to change all rcu_dereference() to rcu_dereference_check(..., rcu_read_lock_bh_held()), wrap nf_hook_slow with read lock/unlock pair.
Reported-by Eric Dumazet <[email protected]>
Signed-off-by Florian Westphal <[email protected]>
--- include/linux/netfilter_netdev.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/netfilter_netdev.h +4 -0
@@ -101,7 +101,11 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc,nf_hook_state_init (&state,NF_NETDEV_EGRESS ,NFPROTO_NETDEV , dev,NULL ,NULL ,dev_net (dev),NULL ); + +/* nf assumes rcu_read_lock, not just read_lock_bh */ +rcu_read_lock (); ret =nf_hook_slow (skb, &state, e,0 ); +rcu_read_unlock ();if (ret ==1 ) {return skb;
Signature · 1 line
2.34.1
Quoted 8 lines · Florian Westphal
Netfilter assumes its called with
rcu_read_lockheld, but in egress hook case it may be called with BH readlock.This triggers lockdep splat.
In order to avoid to change all
rcu_dereference()torcu_dereference_check(..., rcu_read_lock_bh_held()), wrapnf_hook_slowwith read lock/unlock pair.
Applied, thanks