* [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6
@ 2024-11-08 8:18 Jiawei Ye
2024-11-08 19:29 ` Yonghong Song
2024-11-08 20:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jiawei Ye @ 2024-11-08 8:18 UTC (permalink / raw)
To: martin.lau, daniel, edumazet, kuba; +Cc: bpf, netdev, linux-kernel
In the bpf_out_neigh_v6 function, rcu_read_lock() is used to begin an RCU
read-side critical section. However, when unlocking, one branch
incorrectly uses a different RCU unlock flavour rcu_read_unlock_bh()
instead of rcu_read_unlock(). This mismatch in RCU locking flavours can
lead to unexpected behavior and potential concurrency issues.
This possible bug was identified using a static analysis tool developed
by myself, specifically designed to detect RCU-related issues.
This patch corrects the mismatched unlock flavour by replacing the
incorrect rcu_read_unlock_bh() with the appropriate rcu_read_unlock(),
ensuring that the RCU critical section is properly exited. This change
prevents potential synchronization issues and aligns with proper RCU
usage patterns.
Fixes: 09eed1192cec ("neighbour: switch to standard rcu, instead of rcu_bh")
Signed-off-by: Jiawei Ye <jiawei.ye@foxmail.com>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 64248d0ac4ad..44bbc1dbfb50 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2232,7 +2232,7 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb,
rcu_read_unlock();
return ret;
}
- rcu_read_unlock_bh();
+ rcu_read_unlock();
if (dst)
IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
out_drop:
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6
2024-11-08 8:18 [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6 Jiawei Ye
@ 2024-11-08 19:29 ` Yonghong Song
2024-11-08 20:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2024-11-08 19:29 UTC (permalink / raw)
To: Jiawei Ye, martin.lau, daniel, edumazet, kuba; +Cc: bpf, netdev, linux-kernel
On 11/8/24 12:18 AM, Jiawei Ye wrote:
> In the bpf_out_neigh_v6 function, rcu_read_lock() is used to begin an RCU
> read-side critical section. However, when unlocking, one branch
> incorrectly uses a different RCU unlock flavour rcu_read_unlock_bh()
> instead of rcu_read_unlock(). This mismatch in RCU locking flavours can
> lead to unexpected behavior and potential concurrency issues.
>
> This possible bug was identified using a static analysis tool developed
> by myself, specifically designed to detect RCU-related issues.
>
> This patch corrects the mismatched unlock flavour by replacing the
> incorrect rcu_read_unlock_bh() with the appropriate rcu_read_unlock(),
> ensuring that the RCU critical section is properly exited. This change
> prevents potential synchronization issues and aligns with proper RCU
> usage patterns.
>
> Fixes: 09eed1192cec ("neighbour: switch to standard rcu, instead of rcu_bh")
> Signed-off-by: Jiawei Ye <jiawei.ye@foxmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6
2024-11-08 8:18 [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6 Jiawei Ye
2024-11-08 19:29 ` Yonghong Song
@ 2024-11-08 20:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-08 20:50 UTC (permalink / raw)
To: Jiawei Ye; +Cc: martin.lau, daniel, edumazet, kuba, bpf, netdev, linux-kernel
Hello:
This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:
On Fri, 8 Nov 2024 08:18:52 +0000 you wrote:
> In the bpf_out_neigh_v6 function, rcu_read_lock() is used to begin an RCU
> read-side critical section. However, when unlocking, one branch
> incorrectly uses a different RCU unlock flavour rcu_read_unlock_bh()
> instead of rcu_read_unlock(). This mismatch in RCU locking flavours can
> lead to unexpected behavior and potential concurrency issues.
>
> This possible bug was identified using a static analysis tool developed
> by myself, specifically designed to detect RCU-related issues.
>
> [...]
Here is the summary with links:
- bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6
https://git.kernel.org/bpf/bpf/c/fb86c42a2a5d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-08 20:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 8:18 [PATCH] bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6 Jiawei Ye
2024-11-08 19:29 ` Yonghong Song
2024-11-08 20:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).