Re: [PATCH bpf-next 04/17] xdp: add proper __rcu annotations to redirect map entries
From: Toke Høiland-Jørgensen <hidden>
Date: 2021-06-10 23:41:24
Also in:
bpf
From: Toke Høiland-Jørgensen <hidden>
Date: 2021-06-10 23:41:24
Also in:
bpf
Martin KaFai Lau [off-list ref] writes:
On Fri, Jun 11, 2021 at 01:19:04AM +0200, Toke Høiland-Jørgensen wrote:quoted
quoted
quoted
@@ -149,7 +152,8 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, u64 map_flags) { struct xsk_map *m = container_of(map, struct xsk_map, map); - struct xdp_sock *xs, *old_xs, **map_entry; + struct xdp_sock __rcu **map_entry; + struct xdp_sock *xs, *old_xs; u32 i = *(u32 *)key, fd = *(u32 *)value; struct xsk_map_node *node; struct socket *sock;@@ -179,7 +183,7 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, } spin_lock_bh(&m->lock); - old_xs = READ_ONCE(*map_entry); + old_xs = rcu_dereference_check(*map_entry, rcu_read_lock_bh_held());Is it actually protected by the m->lock at this point?True, can just add that to the check.this should be enough rcu_dereference_protected(*map_entry, lockdep_is_held(&m->lock));
Right, that's what I had in mind as well :) -Toke