]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/xsk: Avoid use-after-free on ctx
authorIan Rogers <irogers@google.com>
Thu, 1 Sep 2022 20:26:45 +0000 (13:26 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 2 Sep 2022 13:57:18 +0000 (15:57 +0200)
commit73b93fcd7eed985d70d3f7f773611a51e73fafcb
treecbf2995ac174c0303f65551e312734c3cf1e1219
parent0213486b983947a5da73dc6ec9d177b96ec3adc2
selftests/xsk: Avoid use-after-free on ctx

The put lowers the reference count to 0 and frees ctx, reading it
afterwards is invalid. Move the put after the uses and determine the
last use by the reference count being 1.

Fixes: 57561f54eb88 ("selftests/xsk: Destroy BPF resources only when ctx refcount drops to 0")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20220901202645.1463552-1-irogers@google.com
tools/testing/selftests/bpf/xsk.c