netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: alexei.starovoitov@gmail.com
Cc: john.fastabend@gmail.com, davejwatson@fb.com,
	netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH bpf-next 1/8] tcp, ulp: enforce sock_owned_by_me upon ulp init and cleanup
Date: Thu, 11 Oct 2018 02:45:40 +0200	[thread overview]
Message-ID: <20181011004547.16662-2-daniel@iogearbox.net> (raw)
In-Reply-To: <20181011004547.16662-1-daniel@iogearbox.net>

Whenever the ULP data on the socket is mangled, enforce that the
caller has the socket lock held as otherwise things may race with
initialization and cleanup callbacks from ulp ops as both would
mangle internal socket state.

Joint work with John.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/ipv4/tcp_ulp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index a5995bb..34e9635 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -123,6 +123,8 @@ void tcp_cleanup_ulp(struct sock *sk)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
 
+	sock_owned_by_me(sk);
+
 	if (!icsk->icsk_ulp_ops)
 		return;
 
@@ -140,6 +142,7 @@ int tcp_set_ulp(struct sock *sk, const char *name)
 	const struct tcp_ulp_ops *ulp_ops;
 	int err = 0;
 
+	sock_owned_by_me(sk);
 	if (icsk->icsk_ulp_ops)
 		return -EEXIST;
 
@@ -168,6 +171,7 @@ int tcp_set_ulp_id(struct sock *sk, int ulp)
 	const struct tcp_ulp_ops *ulp_ops;
 	int err;
 
+	sock_owned_by_me(sk);
 	if (icsk->icsk_ulp_ops)
 		return -EEXIST;
 
-- 
2.9.5

  reply	other threads:[~2018-10-11  8:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11  0:45 [PATCH bpf-next 0/8] sockmap integration for ktls Daniel Borkmann
2018-10-11  0:45 ` Daniel Borkmann [this message]
2018-10-11  0:45 ` [PATCH bpf-next 2/8] tcp, ulp: remove ulp bits from sockmap Daniel Borkmann
2018-10-11  0:45 ` [PATCH bpf-next 3/8] bpf, sockmap: convert to generic sk_msg interface Daniel Borkmann
2018-10-11 22:57   ` Alexei Starovoitov
2018-10-12  4:56     ` John Fastabend
2018-10-11  0:45 ` [PATCH bpf-next 4/8] tls: " Daniel Borkmann
2018-10-12 20:16   ` Dave Watson
2018-10-12 21:51     ` Daniel Borkmann
2018-10-11  0:45 ` [PATCH bpf-next 5/8] tls: replace poll implementation with read hook Daniel Borkmann
2018-10-11  0:45 ` [PATCH bpf-next 6/8] tls: add bpf support to sk_msg handling Daniel Borkmann
2018-10-11  0:45 ` [PATCH bpf-next 7/8] bpf: add tls support for testing in test_sockmap Daniel Borkmann
2018-10-11  0:45 ` [PATCH bpf-next 8/8] bpf, doc: add maintainers entry to related files Daniel Borkmann

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=20181011004547.16662-2-daniel@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=davejwatson@fb.com \
    --cc=john.fastabend@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).