From: John Fastabend <john.fastabend@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: [bpf-next PATCH 2/4] bpf: sockmap, duplicates release calls may NULL sk_prot
Date: Sun, 01 Apr 2018 08:00:59 -0700 [thread overview]
Message-ID: <20180401150059.24727.21318.stgit@john-Precision-Tower-5810> (raw)
In-Reply-To: <20180401145728.24727.706.stgit@john-Precision-Tower-5810>
It is possible to have multiple ULP tcp_release call paths in flight
if a sock is closed and simultaneously being removed from the sockmap
control path. The result would be setting the sk_prot to the saved
values on the first iteration and then on the second iteration setting
the value to NULL.
This patch resolves this by ensuring we only reset the sk_prot pointer
if we have a valid saved state to set.
Fixes: 4f738adba30a7 ("bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
kernel/bpf/sockmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 8ddf326..8dd9210 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -182,8 +182,10 @@ static void bpf_tcp_release(struct sock *sk)
psock->cork = NULL;
}
- sk->sk_prot = psock->sk_proto;
- psock->sk_proto = NULL;
+ if (psock->sk_proto) {
+ sk->sk_prot = psock->sk_proto;
+ psock->sk_proto = NULL;
+ }
out:
rcu_read_unlock();
}
next prev parent reply other threads:[~2018-04-01 15:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-01 15:00 [bpf-next PATCH 0/4] Sockmap Updates John Fastabend
2018-04-01 15:00 ` [bpf-next PATCH 1/4] bpf: sockmap, free memory on sock close with cork data John Fastabend
2018-04-12 13:13 ` Simon Horman
2018-04-01 15:00 ` John Fastabend [this message]
2018-04-01 15:01 ` [bpf-next PATCH 3/4] bpf: sockmap, refactor sockmap routines to work with hashmap John Fastabend
2018-04-23 6:32 ` [lkp-robot] [bpf] 4f7b25baf0: kernel_selftests.bpf.test_maps.fail kernel test robot
2018-04-23 9:41 ` Daniel Borkmann
2018-04-01 15:01 ` [bpf-next PATCH 4/4] bpf: sockmap, add hash map support John Fastabend
2018-04-02 15:54 ` Alexei Starovoitov
2018-04-02 17:53 ` John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180401150059.24727.21318.stgit@john-Precision-Tower-5810 \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox