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] [thread-next>] [day] [month] [year] [list]
Message-ID: <903108df-161e-515b-da3d-bff4fb49de39@iogearbox.net>
Date:   Mon, 25 Apr 2022 16:26:50 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Mat Martineau <mathew.j.martineau@...ux.intel.com>,
        netdev@...r.kernel.org, bpf@...r.kernel.org
Cc:     Geliang Tang <geliang.tang@...e.com>, ast@...nel.org,
        andrii@...nel.org, mptcp@...ts.linux.dev,
        Nicolas Rybowski <nicolas.rybowski@...sares.net>,
        Matthieu Baerts <matthieu.baerts@...sares.net>
Subject: Re: [PATCH bpf-next 2/7] bpf: add bpf_skc_to_mptcp_sock_proto

On 4/21/22 12:24 AM, Mat Martineau wrote:
[...]
>   static const struct bpf_func_proto *
>   bpf_sk_base_func_proto(enum bpf_func_id func_id);
> @@ -11279,6 +11280,19 @@ const struct bpf_func_proto bpf_skc_to_unix_sock_proto = {
>   	.ret_btf_id		= &btf_sock_ids[BTF_SOCK_TYPE_UNIX],
>   };
>   
> +BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk)
> +{
> +	return (unsigned long)bpf_mptcp_sock_from_subflow(sk);
> +}
> +
> +static const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {
> +	.func		= bpf_skc_to_mptcp_sock,
> +	.gpl_only	= false,
> +	.ret_type	= RET_PTR_TO_BTF_ID_OR_NULL,
> +	.arg1_type	= ARG_PTR_TO_SOCK_COMMON,
> +	.ret_btf_id	= &btf_sock_ids[BTF_SOCK_TYPE_MPTCP],
> +};

BPF CI (https://github.com/kernel-patches/bpf/runs/6136052684?check_suite_focus=true) fails with:

   #7   base:FAIL
   libbpf: prog '_sockops': BPF program load failed: Invalid argument
   libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
   0: R1=ctx(off=0,imm=0) R10=fp0
   ; int op = (int)ctx->op;
   0: (61) r2 = *(u32 *)(r1 +0)          ; R1=ctx(off=0,imm=0) R2_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff))
   ; if (op != BPF_SOCK_OPS_TCP_CONNECT_CB)
   1: (56) if w2 != 0x3 goto pc+50       ; R2_w=3
   ; sk = ctx->sk;
   2: (79) r6 = *(u64 *)(r1 +184)        ; R1=ctx(off=0,imm=0) R6_w=sock_or_null(id=1,off=0,imm=0)
   ; if (!sk)
   3: (15) if r6 == 0x0 goto pc+48       ; R6_w=sock(off=0,imm=0)
   ; tcp_sk = bpf_tcp_sock(sk);
   4: (bf) r1 = r6                       ; R1_w=sock(off=0,imm=0) R6_w=sock(off=0,imm=0)
   5: (85) call bpf_tcp_sock#96          ; R0_w=tcp_sock_or_null(id=2,off=0,imm=0)
   6: (bf) r7 = r0                       ; R0=tcp_sock_or_null(id=2,off=0,imm=0) R7=tcp_sock_or_null(id=2,off=0,imm=0)
   ; if (!tcp_sk)
   7: (15) if r7 == 0x0 goto pc+44       ; R7=tcp_sock(off=0,imm=0)
   ; if (!tcp_sk->is_mptcp) {
   8: (61) r1 = *(u32 *)(r7 +112)        ; R1_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff)) R7=tcp_sock(off=0,imm=0)
   ; if (!tcp_sk->is_mptcp) {
   9: (56) if w1 != 0x0 goto pc+14 24: R0=tcp_sock(off=0,imm=0) R1_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff)) R6=sock(off=0,imm=0) R7=tcp_sock(off=0,imm=0) R10=fp0
   ; msk = bpf_skc_to_mptcp_sock(sk);
   24: (bf) r1 = r6                      ; R1_w=sock(off=0,imm=0) R6=sock(off=0,imm=0)
   25: (85) call bpf_skc_to_mptcp_sock#194
   invalid return type 8 of func bpf_skc_to_mptcp_sock#194
   processed 34 insns (limit 1000000) max_states_per_insn 0 total_states 3 peak_states 3 mark_read 1
   -- END PROG LOAD LOG --
   libbpf: failed to load program '_sockops'
   libbpf: failed to load object './mptcp_sock.o'
   run_test:FAIL:165
   test_base:FAIL:227
   (network_helpers.c:88: errno: Protocol not supported) Failed to create server socket
   test_base:FAIL:241
   RTNETLINK answers: No such file or directory
   Error talking to the kernel
[...]

Looking at bpf_skc_to_tcp6_sock(), do we similarly need a BTF_TYPE_EMIT() here?

Thanks,
Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ