From: David Miller <davem@davemloft.net>
To: edumazet@google.com
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, brakmo@fb.com,
ncardwell@google.com
Subject: Re: [PATCH net] tcp: fix tcp_set_congestion_control() use from bpf hook
Date: Thu, 18 Jul 2019 20:34:56 -0700 (PDT) [thread overview]
Message-ID: <20190718.203456.202734701056640827.davem@davemloft.net> (raw)
In-Reply-To: <20190719022814.233056-1-edumazet@google.com>
From: Eric Dumazet <edumazet@google.com>
Date: Thu, 18 Jul 2019 19:28:14 -0700
> Neal reported incorrect use of ns_capable() from bpf hook.
>
> bpf_setsockopt(...TCP_CONGESTION...)
> -> tcp_set_congestion_control()
> -> ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)
> -> ns_capable_common()
> -> current_cred()
> -> rcu_dereference_protected(current->cred, 1)
>
> Accessing 'current' in bpf context makes no sense, since packets
> are processed from softirq context.
>
> As Neal stated : The capability check in tcp_set_congestion_control()
> was written assuming a system call context, and then was reused from
> a BPF call site.
>
> The fix is to add a new parameter to tcp_set_congestion_control(),
> so that the ns_capable() call is only performed under the right
> context.
>
> Fixes: 91b5b21c7c16 ("bpf: Add support for changing congestion control")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Lawrence Brakmo <brakmo@fb.com>
> Reported-by: Neal Cardwell <ncardwell@google.com>
Applied and queued up for -stable.
prev parent reply other threads:[~2019-07-19 3:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-19 2:28 [PATCH net] tcp: fix tcp_set_congestion_control() use from bpf hook Eric Dumazet
2019-07-19 2:50 ` Neal Cardwell
2019-07-19 2:55 ` Lawrence Brakmo
2019-07-19 3:34 ` David Miller [this message]
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=20190718.203456.202734701056640827.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=brakmo@fb.com \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=ncardwell@google.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).