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]
Message-ID: <CACkBjsaWfo9h7H0O4wUWJ2qrAsw0XkJSUiKOC9H_FkOivvq=5A@mail.gmail.com>
Date: Wed, 10 Jan 2024 14:30:08 +0100
From: Hao Sun <sunhao.th@...il.com>
To: bpf@...r.kernel.org
Cc: willemb@...gle.com, ast@...nel.org, linux-kernel@...r.kernel.org, 
	Eduard Zingerman <eddyz87@...il.com>
Subject: Re: [PATCH v2 2/2] selftests/bpf: Add tests for alu on PTR_TO_FLOW_KEYS

On Wed, Jan 10, 2024 at 1:53 PM Hao Sun <sunhao.th@...il.com> wrote:
>
> Add two cases for PTR_TO_FLOW_KEYS alu. One for rejecting alu with
> variable offset, another for fixed offset.
>
> Signed-off-by: Hao Sun <sunhao.th@...il.com>
> ---
>  .../bpf/progs/verifier_value_illegal_alu.c    | 37 +++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/verifier_value_illegal_aluc b/tools/testing/selftests/bpf/progs/verifier_value_illegal_alu.c
> index 71814a753216..49089361c98a 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_value_illegal_alu.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_value_illegal_alu.c
> @@ -146,4 +146,41 @@ l0_%=:     exit;                                           \
>         : __clobber_all);
>  }
>
> +SEC("flow_dissector")
> +__description("flow_keys illegal alu op with variable offset")
> +__failure
> +__msg("R7 pointer arithmetic on flow_keys prohibited")
> +__naked void flow_keys_illegal_variable_offset_alu(void)
> +{
> +       asm volatile("                                                  \
> +       r6 = r1;                                                                \
> +       r7 = *(u64*)(r6 + %[flow_keys_off]);    \
> +       r8 = 8;                                                                 \
> +       r8 /= 1;                                                                \
> +       r8 &= 8;                                                                \
> +       r7 += r8;                                                               \
> +       r0 = *(u64*)(r7 + 0);                                   \
> +       exit;                                                                   \
> +"      :
> +       : __imm_const(flow_keys_off, offsetof(struct __sk_buff, flow_keys))
> +       : __clobber_all);
> +}
> +
> +SEC("flow_dissector")
> +__description("flow_keys valid alu op with fixed offset")
> +__success
> +__naked void flow_keys_legal_fixed_offset_alu(void)
> +{
> +       asm volatile("                                                  \
> +       r6 = r1;                                                                \
> +       r7 = *(u64*)(r6 + %[flow_keys_off]);    \
> +       r8 = 8;                                                                 \
> +       r7 += r8;                                                               \
> +       r0 = *(u64*)(r7 + 0);                                   \
> +       exit;                                                                   \
> +"      :
> +       : __imm_const(flow_keys_off, offsetof(struct __sk_buff, flow_keys))
> +       : __clobber_all);
> +}
> +

The format here is strange and should be fixed later.
I'm also curious, why only fixed-off is used in check_flow_keys_access()
for validation?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ