Skip to contentSkip to conversation

bpf/devmap: convert remaining READ_ONCE() to rcu_dereference_check()

PATCH Applied Toke Høiland-Jørgensen 3 participants 3 messages Jun 29, 2021 – Jul 1, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bpf/devmap: convert remaining READ_ONCE() to rcu_dereference_check()

There were a couple of READ_ONCE()-invocations left-over by the devmap RCU conversion. Convert these to rcu_dereference_check() as well to avoid complaints from sparse.

v2:
- Use rcu_dereference_check()

Fixes 782347b6bcad ("xdp: Add proper __rcu annotations to redirect map entries")
---
 kernel/bpf/devmap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/devmap.c +4 -2
index 2f6bd75cd682..e4ebe70cf201 100644
@@ -558,7 +558,8 @@ int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx,
 
 	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
 		for (i = 0; i < map->max_entries; i++) {
-			dst = READ_ONCE(dtab->netdev_map[i]);
+			dst = rcu_dereference_check(dtab->netdev_map[i],
+						    rcu_read_lock_bh_held());
 			if (!is_valid_dst(dst, xdp, exclude_ifindex))
 				continue;
 
@@ -654,7 +655,8 @@ int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
 
 	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
 		for (i = 0; i < map->max_entries; i++) {
-			dst = READ_ONCE(dtab->netdev_map[i]);
+			dst = rcu_dereference_check(dtab->netdev_map[i],
+						    rcu_read_lock_bh_held());
 			if (!dst || dst->dev->ifindex == exclude_ifindex)
 				continue;
 
Signature · 1 line
2.32.0
Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines · Toke Høiland-Jørgensen

There were a couple of READ_ONCE()-invocations left-over by the devmap RCU conversion. Convert these to rcu_dereference_check() as well to avoid complaints from sparse.

v2:
- Use rcu_dereference_check()

#2 lore raw
In reply to Toke Høiland-Jørgensen
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

Quoted 8 lines · On Tue, 29 Jun 2021 11:39:07 +0200 you wrote:

There were a couple of READ_ONCE()-invocations left-over by the devmap RCU conversion. Convert these to rcu_dereference_check() as well to avoid complaints from sparse.

v2:
- Use rcu_dereference_check()

[...]

Here is the summary with links:
- [bpf-next,v2] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference_check()

    https://git.kernel.org/bpf/bpf/c/0fc4dcc13f09

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html