bpf: fix struct htab_elem layout
authorAlexei Starovoitov <[email protected]>
Wed, 8 Mar 2017 04:00:12 +0000 (20:00 -0800)
committerDavid S. Miller <[email protected]>
Thu, 9 Mar 2017 21:27:17 +0000 (13:27 -0800)
commit9f691549f76d488a0c74397b3e51e943865ea01f
treec73054636fa049cf4eee1b15a0eac5191b926e6f
parent745cb7f8a5de0805cade3de3991b7a95317c7c73
bpf: fix struct htab_elem layout

when htab_elem is removed from the bucket list the htab_elem.hash_node.next
field should not be overridden too early otherwise we have a tiny race window
between lookup and delete.
The bug was discovered by manual code analysis and reproducible
only with explicit udelay() in lookup_elem_raw().

Fixes: 6c9059817432 ("bpf: pre-allocate hash map elements")
Reported-by: Jonathan Perry <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
kernel/bpf/hashtab.c