]> git.baikalelectronics.ru Git - kernel.git/commit
flow_dissector: Fix potential use-after-free on BPF_PROG_DETACH
authorJakub Sitnicki <jakub@cloudflare.com>
Wed, 21 Aug 2019 12:17:20 +0000 (14:17 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 23 Aug 2019 23:15:34 +0000 (01:15 +0200)
commit7b9594b870175304909b8ac93604e5c79ed85168
treeaf5b19557c1fda37db52a3cb3ffcee646b59fb3b
parent84a6581f0845101c70a85c4edfd3f670c7eaaf4d
flow_dissector: Fix potential use-after-free on BPF_PROG_DETACH

Call to bpf_prog_put(), with help of call_rcu(), queues an RCU-callback to
free the program once a grace period has elapsed. The callback can run
together with new RCU readers that started after the last grace period.
New RCU readers can potentially see the "old" to-be-freed or already-freed
pointer to the program object before the RCU update-side NULLs it.

Reorder the operations so that the RCU update-side resets the protected
pointer before the end of the grace period after which the program will be
freed.

Fixes: 23513a901445 ("flow_dissector: implements flow dissector BPF hook")
Reported-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: Petar Penkov <ppenkov@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/core/flow_dissector.c