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: <CAH3MdRWXcGVeo30KDy6r3s-cxFB69SJ3mFh5Ds1CiGthVP4Lzw@mail.gmail.com>
Date:   Wed, 3 Jul 2019 16:11:42 -0700
From:   Y Song <ys114321@...il.com>
To:     Ilya Leoshkevich <iii@...ux.ibm.com>
Cc:     bpf <bpf@...r.kernel.org>, netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: fix "alu with different scalars
 1" on s390

On Wed, Jul 3, 2019 at 9:06 AM Ilya Leoshkevich <iii@...ux.ibm.com> wrote:
>
> BPF_LDX_MEM is used to load the least significant byte of the retrieved
> test_val.index, however, on big-endian machines it ends up retrieving
> the most significant byte.
>
> Use the correct least significant byte offset on big-endian machines.
>
> Signed-off-by: Ilya Leoshkevich <iii@...ux.ibm.com>
> ---
>  tools/testing/selftests/bpf/verifier/value_ptr_arith.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/verifier/value_ptr_arith.c b/tools/testing/selftests/bpf/verifier/value_ptr_arith.c
> index c3de1a2c9dc5..3b221bb4b317 100644
> --- a/tools/testing/selftests/bpf/verifier/value_ptr_arith.c
> +++ b/tools/testing/selftests/bpf/verifier/value_ptr_arith.c
> @@ -183,7 +183,11 @@
>         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>         BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
>         BPF_EXIT_INSN(),
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>         BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
> +#else
> +       BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, sizeof(int) - 1),
> +#endif
>         BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3),
>         BPF_MOV64_IMM(BPF_REG_2, 0),
>         BPF_MOV64_IMM(BPF_REG_3, 0x100000),
> --
> 2.21.0
>

In verifier directory, we mostly use __BYTE_ORDER macros.

-bash-4.4$ pwd
/home/yhs/work/net-next/tools/testing/selftests/bpf/verifier
-bash-4.4$ grep __BYTE_ORDER *
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
ctx_skb.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
lwt.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
perf_event_sample_period.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
perf_event_sample_period.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
perf_event_sample_period.c:#if __BYTE_ORDER == __LITTLE_ENDIAN
-bash-4.4$

Your code above should also work (it requires gcc 4.6 and later, but
we require newer gcc compiler anyway).
Maybe if the above __BYTE_ORDER works for s360, maybe using that is
better for consistency?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ