public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luis Gerhorst <gerhorst@amazon.de>
To: <alexei.starovoitov@gmail.com>
Cc: <andrii@kernel.org>, <ast@kernel.org>, <bpf@vger.kernel.org>,
	<daniel@iogearbox.net>, <haoluo@google.com>,
	<john.fastabend@gmail.com>, <jolsa@kernel.org>,
	<kpsingh@kernel.org>, <laoar.shao@gmail.com>,
	<martin.lau@linux.dev>, <sdf@google.com>, <song@kernel.org>,
	<yonghong.song@linux.dev>, <mykolal@fb.com>, <shuah@kernel.org>,
	<gerhorst@amazon.de>, <iii@linux.ibm.com>,
	<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Luis Gerhorst <gerhorst@cs.fau.de>
Subject: [PATCH 1/3] Revert "selftests/bpf: Add selftest for allow_ptr_leaks"
Date: Wed, 13 Sep 2023 12:25:15 +0000	[thread overview]
Message-ID: <20230913122514.89078-1-gerhorst@amazon.de> (raw)
In-Reply-To: <CAADnVQLid7QvukhnqRoY2VVFi1tCfkPFsMGUUeHDtCgf0SAJCg@mail.gmail.com>

This reverts commit 0072e3624b463636c842ad8e261f1dc91deb8c78.

The test tests behavior which can not be permitted because of Spectre
v1. See the following commit

  Revert "bpf: Fix issue in verifying allow_ptr_leaks"

which reverts commit d75e30dddf73449bc2d10bb8e2f1a2c446bc67a2 for a
detailed description of the issue.

Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Luis Gerhorst <gerhorst@amazon.de>
Signed-off-by: Luis Gerhorst <gerhorst@cs.fau.de>
---
 .../testing/selftests/bpf/prog_tests/tc_bpf.c | 36 +------------------
 .../testing/selftests/bpf/progs/test_tc_bpf.c | 13 -------
 2 files changed, 1 insertion(+), 48 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/tc_bpf.c b/tools/testing/selftests/bpf/prog_tests/tc_bpf.c
index 48b55539331e..e873766276d1 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_bpf.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_bpf.c
@@ -3,7 +3,6 @@
 #include <test_progs.h>
 #include <linux/pkt_cls.h>
 
-#include "cap_helpers.h"
 #include "test_tc_bpf.skel.h"
 
 #define LO_IFINDEX 1
@@ -328,7 +327,7 @@ static int test_tc_bpf_api(struct bpf_tc_hook *hook, int fd)
 	return 0;
 }
 
-void tc_bpf_root(void)
+void test_tc_bpf(void)
 {
 	DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook, .ifindex = LO_IFINDEX,
 			    .attach_point = BPF_TC_INGRESS);
@@ -394,36 +393,3 @@ void tc_bpf_root(void)
 	}
 	test_tc_bpf__destroy(skel);
 }
-
-void tc_bpf_non_root(void)
-{
-	struct test_tc_bpf *skel = NULL;
-	__u64 caps = 0;
-	int ret;
-
-	/* In case CAP_BPF and CAP_PERFMON is not set */
-	ret = cap_enable_effective(1ULL << CAP_BPF | 1ULL << CAP_NET_ADMIN, &caps);
-	if (!ASSERT_OK(ret, "set_cap_bpf_cap_net_admin"))
-		return;
-	ret = cap_disable_effective(1ULL << CAP_SYS_ADMIN | 1ULL << CAP_PERFMON, NULL);
-	if (!ASSERT_OK(ret, "disable_cap_sys_admin"))
-		goto restore_cap;
-
-	skel = test_tc_bpf__open_and_load();
-	if (!ASSERT_OK_PTR(skel, "test_tc_bpf__open_and_load"))
-		goto restore_cap;
-
-	test_tc_bpf__destroy(skel);
-
-restore_cap:
-	if (caps)
-		cap_enable_effective(caps, NULL);
-}
-
-void test_tc_bpf(void)
-{
-	if (test__start_subtest("tc_bpf_root"))
-		tc_bpf_root();
-	if (test__start_subtest("tc_bpf_non_root"))
-		tc_bpf_non_root();
-}
diff --git a/tools/testing/selftests/bpf/progs/test_tc_bpf.c b/tools/testing/selftests/bpf/progs/test_tc_bpf.c
index ef7da419632a..d28ca8d1f3d0 100644
--- a/tools/testing/selftests/bpf/progs/test_tc_bpf.c
+++ b/tools/testing/selftests/bpf/progs/test_tc_bpf.c
@@ -2,8 +2,6 @@
 
 #include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
-#include <linux/if_ether.h>
-#include <linux/ip.h>
 
 /* Dummy prog to test TC-BPF API */
 
@@ -12,14 +10,3 @@ int cls(struct __sk_buff *skb)
 {
 	return 0;
 }
-
-/* Prog to verify tc-bpf without cap_sys_admin and cap_perfmon */
-SEC("tcx/ingress")
-int pkt_ptr(struct __sk_buff *skb)
-{
-	struct iphdr *iph = (void *)(long)skb->data + sizeof(struct ethhdr);
-
-	if ((long)(iph + 1) > (long)skb->data_end)
-		return 1;
-	return 0;
-}
-- 
2.40.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




       reply	other threads:[~2023-09-13 12:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAADnVQLid7QvukhnqRoY2VVFi1tCfkPFsMGUUeHDtCgf0SAJCg@mail.gmail.com>
2023-09-13 12:25 ` Luis Gerhorst [this message]
2023-09-14 12:50   ` [PATCH 1/3] Revert "selftests/bpf: Add selftest for allow_ptr_leaks" patchwork-bot+netdevbpf
2023-09-13 12:28 ` [PATCH 2/3] Revert "bpf: Fix issue in verifying allow_ptr_leaks" Luis Gerhorst
2023-09-14 16:20   ` Alexei Starovoitov
2023-09-14 17:24     ` Daniel Borkmann
2023-09-14 19:47       ` Alexei Starovoitov
2023-09-18 11:25         ` Luis Gerhorst
2023-09-19  8:57           ` Alexei Starovoitov
2023-09-28 11:09             ` Luis Gerhorst
2023-09-15  2:26   ` Yafang Shao
2023-09-18 11:52     ` Luis Gerhorst
2023-09-19  3:43       ` Yafang Shao
2023-09-19  6:43         ` Daniel Borkmann
2023-09-13 12:31 ` [PATCH 3/3] selftests/bpf: Add selftest for packet-pointer Spectre v1 gadget Luis Gerhorst

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=20230913122514.89078-1-gerhorst@amazon.de \
    --to=gerhorst@amazon.de \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gerhorst@cs.fau.de \
    --cc=haoluo@google.com \
    --cc=iii@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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