]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: sockmap, fix double page_put on ENOMEM error in redirect path
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 23 Apr 2018 22:39:33 +0000 (15:39 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 23 Apr 2018 22:49:45 +0000 (00:49 +0200)
commitfa7327c288f1c6d276f91f9ce046e77903ccb029
tree55c8684910f6c98ff7f47e8d3de239c20882e98e
parent4884356c487f62fe342c99e65f122ade500d9691
bpf: sockmap, fix double page_put on ENOMEM error in redirect path

In the case where the socket memory boundary is hit the redirect
path returns an ENOMEM error. However, before checking for this
condition the redirect scatterlist buffer is setup with a valid
page and length. This is never unwound so when the buffers are
released latter in the error path we do a put_page() and clear
the scatterlist fields. But, because the initial error happens
before completing the scatterlist buffer we end up with both the
original buffer and the redirect buffer pointing to the same page
resulting in duplicate put_page() calls.

To fix this simply move the initial configuration of the redirect
scatterlist buffer below the sock memory check.

Found this while running TCP_STREAM test with netperf using Cilium.

Fixes: c02997b1c148 ("bpf: sockmap, BPF_F_INGRESS flag for BPF_SK_SKB_STREAM_VERDICT")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/sockmap.c