Skip to content

Commit 65dabc9

Browse files
FedeDPirozzo-1A
authored andcommitted
fix(driver): fixed build of old bpf probe against linux 6.15-rc1.
Also, fixed modern_ebpf running against the new kernel version. Signed-off-by: Federico Di Pierro <[email protected]>
1 parent 22be249 commit 65dabc9

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+
/*
3+
4+
Copyright (C) 2025 The Falco Authors.
5+
6+
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
7+
or GPL2.txt for full copies of the license.
8+
9+
*/
10+
11+
/*
12+
* Check that kernfs_node's field `parent` exists.
13+
* See 6.15 kernel commit it is named __parent:
14+
* https://github.com/torvalds/linux/commit/633488947ef66b194377411322dc9e12aab79b65
15+
*/
16+
17+
#include "../../quirks.h"
18+
#include "../../ppm_events_public.h"
19+
#include "../../types.h"
20+
21+
// struct kernfs_node declaration
22+
#include <linux/kernfs.h>
23+
24+
BPF_PROBE("signal/", signal_deliver, signal_deliver_args) {
25+
struct kernfs_node *parent;
26+
struct kernfs_node node;
27+
28+
parent = node.parent;
29+
return 0;
30+
}
31+
32+
char __license[] __bpf_section("license") = "Dual MIT/GPL";

driver/bpf/fillers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,11 @@ static __always_inline int __bpf_append_cgroup(struct css_set *cgroups,
18101810
for(int k = 0; k < MAX_CGROUP_PATHS; ++k) {
18111811
if(kn) {
18121812
cgroup_path[k] = (char *)_READ(kn->name);
1813+
#ifdef HAS_KERNFS_NODE_PARENT
18131814
kn = _READ(kn->parent);
1815+
#else
1816+
kn = _READ(kn->__parent);
1817+
#endif
18141818
} else {
18151819
cgroup_path[k] = NULL;
18161820
}

driver/modern_bpf/definitions/struct_flavors.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ struct inode___v6_11 {
5959
uint32_t i_ctime_nsec;
6060
};
6161

62+
struct kernfs_node___v6_15 {
63+
struct kernfs_node *__parent;
64+
};
65+
6266
#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
6367
#pragma clang attribute pop
6468
#endif

driver/modern_bpf/helpers/store/auxmap_store_params.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,12 @@ static __always_inline uint16_t store_cgroup_subsys(struct auxiliary_map *auxmap
12961296
}
12971297
path_components++;
12981298
BPF_CORE_READ_INTO(&cgroup_path_pointers[k], kn, name);
1299-
BPF_CORE_READ_INTO(&kn, kn, parent);
1299+
if(bpf_core_field_exists(kn->parent)) {
1300+
BPF_CORE_READ_INTO(&kn, kn, parent);
1301+
} else {
1302+
struct kernfs_node___v6_15 *kn_v6_15 = (void *)kn;
1303+
BPF_CORE_READ_INTO(&kn, kn_v6_15, __parent);
1304+
}
13001305
}
13011306

13021307
/* Reconstruct the path in reverse, using previously collected pointers.

0 commit comments

Comments
 (0)