Commit 5fda864
committed
libbpf: Fix event name too long error
JIRA: https://issues.redhat.com/browse/RHEL-110274
commit 4dde20b
Author: Feng Yang <[email protected]>
Date: Thu Apr 17 09:48:46 2025 +0800
libbpf: Fix event name too long error
When the binary path is excessively long, the generated probe_name in libbpf
exceeds the kernel's MAX_EVENT_NAME_LEN limit (64 bytes).
This causes legacy uprobe event attachment to fail with error code -22.
The fix reorders the fields to place the unique ID before the name.
This ensures that even if truncation occurs via snprintf, the unique ID
remains intact, preserving event name uniqueness. Additionally, explicit
checks with MAX_EVENT_NAME_LEN are added to enforce length constraints.
Before Fix:
./test_progs -t attach_probe/kprobe-long_name
......
libbpf: failed to add legacy kprobe event for 'bpf_testmod_looooooooooooooooooooooooooooooong_name+0x0': -EINVAL
libbpf: prog 'handle_kprobe': failed to create kprobe 'bpf_testmod_looooooooooooooooooooooooooooooong_name+0x0' perf event: -EINVAL
test_attach_kprobe_long_event_name:FAIL:attach_kprobe_long_event_name unexpected error: -22
test_attach_probe:PASS:uprobe_ref_ctr_cleanup 0 nsec
#13/11 attach_probe/kprobe-long_name:FAIL
#13 attach_probe:FAIL
./test_progs -t attach_probe/uprobe-long_name
......
libbpf: failed to add legacy uprobe event for /root/linux-bpf/bpf-next/tools/testing/selftests/bpf/test_progs:0x13efd9: -EINVAL
libbpf: prog 'handle_uprobe': failed to create uprobe '/root/linux-bpf/bpf-next/tools/testing/selftests/bpf/test_progs:0x13efd9' perf event: -EINVAL
test_attach_uprobe_long_event_name:FAIL:attach_uprobe_long_event_name unexpected error: -22
#13/10 attach_probe/uprobe-long_name:FAIL
#13 attach_probe:FAIL
After Fix:
./test_progs -t attach_probe/uprobe-long_name
#13/10 attach_probe/uprobe-long_name:OK
#13 attach_probe:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
./test_progs -t attach_probe/kprobe-long_name
#13/11 attach_probe/kprobe-long_name:OK
#13 attach_probe:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
Fixes: 46ed5fc ("libbpf: Refactor and simplify legacy kprobe code")
Fixes: cc10623 ("libbpf: Add legacy uprobe attaching support")
Signed-off-by: Hengqi Chen <[email protected]>
Signed-off-by: Feng Yang <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Viktor Malik <[email protected]>1 parent f767593 commit 5fda864
1 file changed
+16
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
11039 | 11041 | | |
11040 | 11042 | | |
11041 | 11043 | | |
11042 | | - | |
11043 | | - | |
| 11044 | + | |
| 11045 | + | |
11044 | 11046 | | |
11045 | 11047 | | |
11046 | 11048 | | |
11047 | 11049 | | |
11048 | | - | |
11049 | | - | |
| 11050 | + | |
| 11051 | + | |
11050 | 11052 | | |
11051 | | - | |
| 11053 | + | |
11052 | 11054 | | |
11053 | 11055 | | |
11054 | 11056 | | |
| |||
11174 | 11176 | | |
11175 | 11177 | | |
11176 | 11178 | | |
11177 | | - | |
| 11179 | + | |
11178 | 11180 | | |
11179 | | - | |
| 11181 | + | |
11180 | 11182 | | |
11181 | 11183 | | |
11182 | 11184 | | |
| |||
11233 | 11235 | | |
11234 | 11236 | | |
11235 | 11237 | | |
11236 | | - | |
| 11238 | + | |
11237 | 11239 | | |
11238 | | - | |
11239 | | - | |
| 11240 | + | |
| 11241 | + | |
11240 | 11242 | | |
11241 | 11243 | | |
11242 | 11244 | | |
| |||
11744 | 11746 | | |
11745 | 11747 | | |
11746 | 11748 | | |
11747 | | - | |
11748 | | - | |
11749 | | - | |
11750 | | - | |
11751 | | - | |
11752 | | - | |
11753 | | - | |
11754 | | - | |
11755 | | - | |
11756 | | - | |
11757 | | - | |
11758 | | - | |
11759 | | - | |
11760 | | - | |
11761 | 11749 | | |
11762 | 11750 | | |
11763 | 11751 | | |
| |||
12173 | 12161 | | |
12174 | 12162 | | |
12175 | 12163 | | |
12176 | | - | |
| 12164 | + | |
12177 | 12165 | | |
12178 | 12166 | | |
12179 | 12167 | | |
12180 | 12168 | | |
12181 | | - | |
12182 | | - | |
| 12169 | + | |
| 12170 | + | |
| 12171 | + | |
12183 | 12172 | | |
12184 | 12173 | | |
12185 | 12174 | | |
| |||
0 commit comments