Skip to content

Commit

Permalink
Revert "selftests/bpf: Add selftest for allow_ptr_leaks"
Browse files Browse the repository at this point in the history
This reverts commit 0072e36.

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 d75e30d 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>
  • Loading branch information
Luis Gerhorst authored and Kernel Patches Daemon committed Sep 13, 2023
1 parent df891ba commit c7c7f1a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
36 changes: 1 addition & 35 deletions tools/testing/selftests/bpf/prog_tests/tc_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
13 changes: 0 additions & 13 deletions tools/testing/selftests/bpf/progs/test_tc_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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;
}

0 comments on commit c7c7f1a

Please sign in to comment.