Skip to content

Commit

Permalink
bpf: sockmap, synchronize_rcu before free'ing map
Browse files Browse the repository at this point in the history
We need to have a synchronize_rcu before free'ing the sockmap because
any outstanding psock references will have a pointer to the map and
when they use this could trigger a use after free.

Fixes: 604326b ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
John Fastabend authored and Daniel Borkmann committed Jul 22, 2019
1 parent 45a4521 commit 2bb90e5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/core/sock_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ static void sock_map_free(struct bpf_map *map)
raw_spin_unlock_bh(&stab->lock);
rcu_read_unlock();

synchronize_rcu();

bpf_map_area_free(stab->sks);
kfree(stab);
}
Expand Down

0 comments on commit 2bb90e5

Please sign in to comment.