mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Jiri Benc <jbenc@redhat.com>
Subject: Re: bpf: test_verifier: sanitation: alu with different scalars
Date: Tue, 25 Jun 2019 11:39:24 +0200	[thread overview]
Message-ID: <f703360d-57c5-4858-e308-1e378a9cc0dc@iogearbox.net> (raw)
In-Reply-To: <xunytvceoyob.fsf@redhat.com>

On 06/25/2019 10:29 AM, Yauheni Kaliuta wrote:
> Hi!
> 
> I'm wondering, how the sanitaion tests (#903 5.2-rc6 for example)
> are supposed to work on BE arches:
> 
> {
> 	"sanitation: alu with different scalars 1",
> 	.insns = {
> 	BPF_MOV64_IMM(BPF_REG_0, 1),
> 	BPF_LD_MAP_FD(BPF_REG_ARG1, 0),
> 	BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP),
> 	BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16),
> 	BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0),
> 	BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
> 	BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
> 	BPF_EXIT_INSN(),
> 	BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0),
> 
> reads one byte 0 on BE and 28 on LE (from ->index) since
> 
> 	struct test_val {
> 		unsigned int index;
> 		int foo[MAX_ENTRIES];
> 	};
> 
>         struct test_val value = {
> 		.index = (6 + 1) * sizeof(int),
> 		.foo[6] = 0xabcdef12,
> 	};
> 
> 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3),
> 
> So different branches are taken depending of the endianness.
> 
> 	BPF_MOV64_IMM(BPF_REG_2, 0),
> 	BPF_MOV64_IMM(BPF_REG_3, 0x100000),
> 	BPF_JMP_A(2),
> 	BPF_MOV64_IMM(BPF_REG_2, 42),
> 	BPF_MOV64_IMM(BPF_REG_3, 0x100001),
> 	BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
> 	BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
> 	BPF_EXIT_INSN(),
> 	},
> 	.fixup_map_array_48b = { 1 },
> 	.result = ACCEPT,
> 	.retval = 0x100000,
> },

Let me get my hands on a s390x box later today and get back to you.

Thanks,
Daniel

  reply	other threads:[~2019-06-25  9:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25  8:29 Yauheni Kaliuta
2019-06-25  9:39 ` Daniel Borkmann [this message]
2019-07-26 10:41   ` Yauheni Kaliuta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f703360d-57c5-4858-e308-1e378a9cc0dc@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=jbenc@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yauheni.kaliuta@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®