linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ebpf: BPF_ALU32 | BPF_ARSH on BE arches
@ 2019-06-25  9:00 Yauheni Kaliuta
  2019-06-25 10:20 ` Jiong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Yauheni Kaliuta @ 2019-06-25  9:00 UTC (permalink / raw)
  To: Jiong Wang; +Cc: linux-kernel, Jiri Olsa, Jiri Benc

Hi!

Looks like the code:

       ALU_ARSH_X:
               DST = (u64) (u32) ((*(s32 *) &DST) >> SRC);
               CONT;
       ALU_ARSH_K:
               DST = (u64) (u32) ((*(s32 *) &DST) >> IMM);
               CONT;

works incorrectly on BE arches since it must operate on lower
parts of 64bit registers.

See failure of test_verifier test 'arsh32 on imm 2' (#23 on
5.2-rc6).


-- 
WBR,
Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ebpf: BPF_ALU32 | BPF_ARSH on BE arches
  2019-06-25  9:00 ebpf: BPF_ALU32 | BPF_ARSH on BE arches Yauheni Kaliuta
@ 2019-06-25 10:20 ` Jiong Wang
  2019-06-25 10:41   ` Yauheni Kaliuta
  0 siblings, 1 reply; 3+ messages in thread
From: Jiong Wang @ 2019-06-25 10:20 UTC (permalink / raw)
  To: Yauheni Kaliuta; +Cc: Jiong Wang, linux-kernel, Jiri Olsa, Jiri Benc


Yauheni Kaliuta writes:

> Hi!
>
> Looks like the code:
>
>        ALU_ARSH_X:
>                DST = (u64) (u32) ((*(s32 *) &DST) >> SRC);
>                CONT;
>        ALU_ARSH_K:
>                DST = (u64) (u32) ((*(s32 *) &DST) >> IMM);
>                CONT;
>
> works incorrectly on BE arches since it must operate on lower
> parts of 64bit registers.
>
> See failure of test_verifier test 'arsh32 on imm 2' (#23 on
> 5.2-rc6).

Ah, thanks for reporting this.

Should not taken the address directly, does the following fix resolved the
failure?

        ALU_ARSH_X:
                DST = (u64) (u32) ((s32) DST) >> SRC);
                CONT;
        ALU_ARSH_K:
                DST = (u64) (u32) ((s32) DST) >> IMM);
                CONT;

Regards,
Jiong

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ebpf: BPF_ALU32 | BPF_ARSH on BE arches
  2019-06-25 10:20 ` Jiong Wang
@ 2019-06-25 10:41   ` Yauheni Kaliuta
  0 siblings, 0 replies; 3+ messages in thread
From: Yauheni Kaliuta @ 2019-06-25 10:41 UTC (permalink / raw)
  To: Jiong Wang; +Cc: linux-kernel, Jiri Olsa, Jiri Benc, bpf

Hi, Jiong!

>>>>> On Tue, 25 Jun 2019 11:20:07 +0100, Jiong Wang  wrote:

 > Yauheni Kaliuta writes:

 >> Hi!
 >> 
 >> Looks like the code:
 >> 
 >> ALU_ARSH_X:
 >> DST = (u64) (u32) ((*(s32 *) &DST) >> SRC);
 >> CONT;
 >> ALU_ARSH_K:
 >> DST = (u64) (u32) ((*(s32 *) &DST) >> IMM);
 >> CONT;
 >> 
 >> works incorrectly on BE arches since it must operate on lower
 >> parts of 64bit registers.
 >> 
 >> See failure of test_verifier test 'arsh32 on imm 2' (#23 on
 >> 5.2-rc6).

 > Ah, thanks for reporting this.

 > Should not taken the address directly, does the following fix resolved the
 > failure?

 >         ALU_ARSH_X:
 >                 DST = (u64) (u32) ((s32) DST) >> SRC);
 >                 CONT;
 >         ALU_ARSH_K:
 >                 DST = (u64) (u32) ((s32) DST) >> IMM);
 >                 CONT;

Yes, thanks (just add the missing braces).

-- 
WBR,
Yauheni Kaliuta

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-25 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25  9:00 ebpf: BPF_ALU32 | BPF_ARSH on BE arches Yauheni Kaliuta
2019-06-25 10:20 ` Jiong Wang
2019-06-25 10:41   ` Yauheni Kaliuta

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).