Skip to contentSkip to conversation

netfilter: nft_inner: release local_lock before re-enabling softirqs

PATCH In review Florian Westphal 2 participants 2 messages May 12

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_inner: release local_lock before re-enabling softirqs

Quoting sashiko:
In the error path, local_bh_enable() is called before local_unlock_nested_bh().

Fixes ba36fada9ab4 ("netfilter: nft_inner: Use nested-BH locking for nft_pcpu_tun_ctx")
---
 net/netfilter/nft_inner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_inner.c +1 -1
index 03ffb1159fc1..85164369b924 100644
@@ -247,8 +247,8 @@ static bool nft_inner_restore_tun_ctx(const struct nft_pktinfo *pkt,
 	local_lock_nested_bh(&nft_pcpu_tun_ctx.bh_lock);
 	this_cpu_tun_ctx = this_cpu_ptr(&nft_pcpu_tun_ctx.ctx);
 	if (this_cpu_tun_ctx->cookie != (unsigned long)pkt->skb) {
-		local_bh_enable();
 		local_unlock_nested_bh(&nft_pcpu_tun_ctx.bh_lock);
+		local_bh_enable();
 		return false;
 	}
 	*tun_ctx = *this_cpu_tun_ctx;
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Florian Westphal

Quoting sashiko:
In the error path, local_bh_enable() is called before local_unlock_nested_bh().

Fixes ba36fada9ab4 ("netfilter: nft_inner: Use nested-BH locking for nft_pcpu_tun_ctx")
---
  net/netfilter/nft_inner.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_inner.c +0 -0
index 03ffb1159fc1..85164369b924 100644

net/netfilter/nft_inner.c static bool nft_inner_restore_tun_ctx(const struct nft_pktinfo *pkt, · line 254

Quoted 9 lines
net/netfilter/nft_inner.c +1 -1
@@ -247,8 +247,8 @@ static bool nft_inner_restore_tun_ctx(const struct nft_pktinfo *pkt,
  	local_lock_nested_bh(&nft_pcpu_tun_ctx.bh_lock);
  	this_cpu_tun_ctx = this_cpu_ptr(&nft_pcpu_tun_ctx.ctx);
  	if (this_cpu_tun_ctx->cookie != (unsigned long)pkt->skb) {
-		local_bh_enable();
  		local_unlock_nested_bh(&nft_pcpu_tun_ctx.bh_lock);
+		local_bh_enable();
  		return false;
  	}
  	*tun_ctx = *this_cpu_tun_ctx;

Thanks!