All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH bpf-next 1/3] selftests/bpf: Fix endianness issue in test_sockopt_sk
Date: Thu, 10 Sep 2020 01:24:41 +0200	[thread overview]
Message-ID: <20200909232443.3099637-2-iii@linux.ibm.com> (raw)
In-Reply-To: <20200909232443.3099637-1-iii@linux.ibm.com>

getsetsockopt() calls getsockopt() with optlen == 1, but then checks
the resulting int. It is ok on little endian, but not on big endian.

Fix by checking char instead.

Fixes: 8a027dc0 ("selftests/bpf: add sockopt test that exercises sk helpers")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
index 5f54c6aec7f0..ba4da50987d6 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
@@ -45,7 +45,7 @@ static int getsetsockopt(void)
 		goto err;
 	}
 
-	if (*(int *)big_buf != 0x08) {
+	if (*big_buf != 0x08) {
 		log_err("Unexpected getsockopt(IP_TOS) optval 0x%x != 0x08",
 			*(int *)big_buf);
 		goto err;
-- 
2.25.4


  reply	other threads:[~2020-09-10  2:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 23:24 [PATCH bpf-next 0/3] Fix three endianness issues in test_progs Ilya Leoshkevich
2020-09-09 23:24 ` Ilya Leoshkevich [this message]
2020-09-10 16:49   ` [PATCH bpf-next 1/3] selftests/bpf: Fix endianness issue in test_sockopt_sk Andrii Nakryiko
2020-09-09 23:24 ` [PATCH bpf-next 2/3] selftests/bpf: Fix endianness issues in sk_lookup/ctx_narrow_access Ilya Leoshkevich
2020-09-10 16:55   ` Andrii Nakryiko
2020-09-23 21:12     ` Ilya Leoshkevich
2020-09-24  7:49       ` Jakub Sitnicki
2020-09-24  9:24   ` Jakub Sitnicki
2020-09-09 23:24 ` [PATCH bpf-next 3/3] selftests/bpf: Fix endianness issue in sk_assign Ilya Leoshkevich
2020-09-10 16:56   ` Andrii Nakryiko
2020-09-10 16:58 ` [PATCH bpf-next 0/3] Fix three endianness issues in test_progs Andrii Nakryiko
2020-09-10 21:55   ` Ilya Leoshkevich

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=20200909232443.3099637-2-iii@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=hca@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.