lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 11 May 2022 14:10:42 +0800
From:   Geliang Tang <geliangtang@...il.com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc:     Martin KaFai Lau <kafai@...com>,
        Mat Martineau <mathew.j.martineau@...ux.intel.com>,
        Andrii Nakryiko <andrii@...nel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Nicolas Rybowski <nicolas.rybowski@...sares.net>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        MPTCP Upstream <mptcp@...ts.linux.dev>,
        Matthieu Baerts <matthieu.baerts@...sares.net>
Subject: Re: [PATCH bpf-next v3 1/8] bpf: expose is_mptcp flag to bpf_tcp_sock

Andrii Nakryiko <andrii.nakryiko@...il.com> 于2022年5月11日周三 13:02写道:
>
> On Tue, May 10, 2022 at 5:48 PM Martin KaFai Lau <kafai@...com> wrote:
> >
> > On Mon, May 02, 2022 at 02:12:27PM -0700, Mat Martineau wrote:
> > > From: Nicolas Rybowski <nicolas.rybowski@...sares.net>
> > >
> > > is_mptcp is a field from struct tcp_sock used to indicate that the
> > > current tcp_sock is part of the MPTCP protocol.
> > >
> > > In this protocol, a first socket (mptcp_sock) is created with
> > > sk_protocol set to IPPROTO_MPTCP (=262) for control purpose but it
> > > isn't directly on the wire. This is the role of the subflow (kernel)
> > > sockets which are classical tcp_sock with sk_protocol set to
> > > IPPROTO_TCP. The only way to differentiate such sockets from plain TCP
> > > sockets is the is_mptcp field from tcp_sock.
> > >
> > > Such an exposure in BPF is thus required to be able to differentiate
> > > plain TCP sockets from MPTCP subflow sockets in BPF_PROG_TYPE_SOCK_OPS
> > > programs.
> > >
> > > The choice has been made to silently pass the case when CONFIG_MPTCP is
> > > unset by defaulting is_mptcp to 0 in order to make BPF independent of
> > > the MPTCP configuration. Another solution is to make the verifier fail
> > > in 'bpf_tcp_sock_is_valid_ctx_access' but this will add an additional
> > > '#ifdef CONFIG_MPTCP' in the BPF code and a same injected BPF program
> > > will not run if MPTCP is not set.
> > There is already bpf_skc_to_tcp_sock() and its returned tcp_sock pointer
> > can access all fields of the "struct tcp_sock" without extending
> > the bpf_tcp_sock.
> >
> > iiuc, I believe the needs to extend bpf_tcp_sock here is to make the
> > same bpf sockops prog works for kernel with and without CONFIG_MPTCP
> > because tp->is_mptcp is not always available:
> >
> > struct tcp_sock {
> >         /* ... */
> >
> > #if IS_ENABLED(CONFIG_MPTCP)
> >         bool    is_mptcp;
> > #endif
> > };
> >
> > Andrii, do you think bpf_core_field_exists() can be used in
> > the bpf prog to test if is_mptcp is available in the running kernel
> > such that the same bpf prog can be used in kernel with and without
> > CONFIG_MPTCP?
>
> yep, absolutely:
>
> bool is_mptcp = bpf_core_field_exists(struct tcp_sock, is_mptcp) ?
> sock->is_mptcp : false;
>
> One can also directly check if CONFIG_MPTCP is set with the following
> in BPF-side code:
>
> extern bool CONFIG_MPTCP __kconfig;

Thanks Martin & Andrii, will update this in v4.

-Geliang
SUSE

>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ