|
|
b48781 |
From 5338636cd9ae7f53ed73f1a7909db03189ea2ff3 Mon Sep 17 00:00:00 2001
|
|
|
b48781 |
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
|
b48781 |
Date: Mon, 4 Jul 2022 12:29:22 +0200
|
|
|
b48781 |
Subject: [PATCH] tests/bpf: fix sloppy low FD number usage
|
|
|
b48781 |
MIME-Version: 1.0
|
|
|
b48781 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b48781 |
Content-Transfer-Encoding: 8bit
|
|
|
b48781 |
|
|
|
b48781 |
FD 42 can already be opened, so close it. Otherwise, it may lead
|
|
|
b48781 |
to the following test failure:
|
|
|
b48781 |
|
|
|
b48781 |
-bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}], iter_info_len=5}}, 28) = 841540765612359407 (INJECTED)
|
|
|
b48781 |
+bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}], iter_info_len=5}}, 28) = 841540765612359407 (INJECTED)
|
|
|
b48781 |
bpf(BPF_LINK_CREATE, 0x3ff95574fe5, 28) = 841540765612359407 (INJECTED)
|
|
|
b48781 |
-bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}, ... /* 0x3ff9555d000 */], iter_info_len=6}}, 28) = 841540765612359407 (INJECTED)
|
|
|
b48781 |
+bpf(BPF_LINK_CREATE, {link_create={prog_fd=0</dev/full>, target_fd=0</dev/full>, attach_type=BPF_TRACE_ITER, flags=0, iter_info=[{map={map_fd=0</dev/full>}}, {map={map_fd=42}}, {map={map_fd=314159265}}, {map={map_fd=-1159983635}}, {map={map_fd=-1}}, ... /* 0x3ff9555d000 */], iter_info_len=6}}, 28) = 841540765612359407 (INJECTED)
|
|
|
b48781 |
[...]
|
|
|
b48781 |
FAIL bpf-success-long-y.test (exit status: 1)
|
|
|
b48781 |
|
|
|
b48781 |
* tests/bpf.c (init_BPF_LINK_CREATE_attr7): Close iter_info_data[1] fd.
|
|
|
b48781 |
|
|
|
b48781 |
Fixes: v5.18~18 "bpf: improve bpf(BPF_LINK_CREATE) decoding"
|
|
|
b48781 |
Reported-by: Lenka Špačková <lkuprova@redhat.com>
|
|
|
b48781 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103137
|
|
|
b48781 |
---
|
|
|
b48781 |
tests/bpf.c | 2 ++
|
|
|
b48781 |
1 file changed, 2 insertions(+)
|
|
|
b48781 |
|
|
|
b48781 |
diff --git a/tests/bpf.c b/tests/bpf.c
|
|
|
b48781 |
index 82d870e..6c1ffd4 100644
|
|
|
b48781 |
--- a/tests/bpf.c
|
|
|
b48781 |
+++ b/tests/bpf.c
|
|
|
b48781 |
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
|
|
|
b48781 |
{
|
|
|
b48781 |
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
|
|
|
b48781 |
|
|
|
b48781 |
+ close(iter_info_data[1]);
|
|
|
b48781 |
+
|
|
|
b48781 |
if (!iter_info_data_p) {
|
|
|
b48781 |
iter_info_data_p = tail_memdup(iter_info_data,
|
|
|
b48781 |
sizeof(iter_info_data));
|
|
|
b48781 |
diff --git a/tests-m32/bpf.c b/tests-m32/bpf.c
|
|
|
b48781 |
index 82d870e..6c1ffd4 100644
|
|
|
b48781 |
--- a/tests-m32/bpf.c
|
|
|
b48781 |
+++ b/tests-m32/bpf.c
|
|
|
b48781 |
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
|
|
|
b48781 |
{
|
|
|
b48781 |
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
|
|
|
b48781 |
|
|
|
b48781 |
+ close(iter_info_data[1]);
|
|
|
b48781 |
+
|
|
|
b48781 |
if (!iter_info_data_p) {
|
|
|
b48781 |
iter_info_data_p = tail_memdup(iter_info_data,
|
|
|
b48781 |
sizeof(iter_info_data));
|
|
|
b48781 |
diff --git a/tests-mx32/bpf.c b/tests-mx32/bpf.c
|
|
|
b48781 |
index 82d870e..6c1ffd4 100644
|
|
|
b48781 |
--- a/tests-mx32/bpf.c
|
|
|
b48781 |
+++ b/tests-mx32/bpf.c
|
|
|
b48781 |
@@ -1557,6 +1557,8 @@ init_BPF_LINK_CREATE_attr7(struct bpf_attr_check *check, size_t idx)
|
|
|
b48781 |
{
|
|
|
b48781 |
struct BPF_LINK_CREATE_struct *attr = &check->data.BPF_LINK_CREATE_data;
|
|
|
b48781 |
|
|
|
b48781 |
+ close(iter_info_data[1]);
|
|
|
b48781 |
+
|
|
|
b48781 |
if (!iter_info_data_p) {
|
|
|
b48781 |
iter_info_data_p = tail_memdup(iter_info_data,
|
|
|
b48781 |
sizeof(iter_info_data));
|
|
|
b48781 |
--
|
|
|
b48781 |
2.1.4
|
|
|
b48781 |
|