BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Andrey Ignatov <rdna@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH bpf] selftests/bpf: fix endianness issues in test_sysctl
Date: Fri, 16 Aug 2019 12:21:52 +0200
Message-ID: <D58F7E8E-81D3-42E7-95FB-14DFD82232D8@linux.ibm.com> (raw)
In-Reply-To: <20190815203324.GA49729@rdna-mbp>

> Am 15.08.2019 um 22:35 schrieb Andrey Ignatov <rdna@fb.com>:
> 
>> @@ -1344,20 +1379,26 @@ static size_t probe_prog_length(const struct bpf_insn *fp)
>> static int fixup_sysctl_value(const char *buf, size_t buf_len,
>> 			      struct bpf_insn *prog, size_t insn_num)
>> {
>> -	uint32_t value_num = 0;
>> +	uint64_t value_num = 0;
>> 	uint8_t c, i;
>> 
>> 	if (buf_len > sizeof(value_num)) {
>> 		log_err("Value is too big (%zd) to use in fixup", buf_len);
>> 		return -1;
>> 	}
>> +	if (prog[insn_num].code != (BPF_LD | BPF_DW | BPF_IMM)) {
>> +		log_err("Can fixup only BPF_LD_IMM64 insns");
>> +		return -1;
>> +	}
>> 
>> 	for (i = 0; i < buf_len; ++i) {
>> 		c = buf[i];
>> 		value_num |= (c << i * 8);
>> 	}
>> +	value_num = __bpf_le64_to_cpu(value_num);
>> 
>> -	prog[insn_num].imm = value_num;
>> +	prog[insn_num].imm = (__u32)value_num;
>> +	prog[insn_num + 1].imm = (__u32)(value_num >> 32);
>> 
>> 	return 0;
>> }
>> @@ -1499,6 +1540,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test)
>> 			goto err;
>> 	}
>> 
>> +	errno = 0;
> 
> Yeah, access_sysctl() can return -1 w/o affecting errno, did it cause a
> problem, or you set it just in case?

It's actually for another use case: if access_sysctl() unexpectedly
returns 0, log_err() will misleadingly print a "random" errno. With this
change, it would print "Unexpected success: errno: None", which makes
sense to me.

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 12:25 Ilya Leoshkevich
2019-08-15 20:35 ` Andrey Ignatov
2019-08-16 10:21   ` Ilya Leoshkevich [this message]
2019-08-16  0:05 ` Yonghong Song
2019-08-16 11:37   ` Ilya Leoshkevich
2019-08-17  0:06     ` Yonghong Song

Reply instructions:

You may reply publically 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=D58F7E8E-81D3-42E7-95FB-14DFD82232D8@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=rdna@fb.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

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org bpf@archiver.kernel.org
	public-inbox-index bpf


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/ public-inbox