Commit 3d84d67
committed
Merge branch 'bpf-fix-tracing-of-kfuncs-with-implicit-args'
Ihor Solodrai says:
====================
bpf: Fix tracing of kfuncs with implicit args
Tejun reported an issue where a BPF program tracing a kfunc with
KF_IMPLICIT_ARGS can crash the kernel [1]. This is caused by a bug in
bpf_check_attach_target(): the btf_func_model for such a kfunc is
computed from a wrong BTF prototype. For more details see the commit
message of patch #1.
The second patch adds a selftest that can catch this situation.
The fix is a candidate for 7.1 backport.
[1] sched-ext/scx#3687 (comment)
---
v2->v3:
* Replace btf_kfunc_accumulated_flags() with btf_kfunc_check_flag()
following a discussion with Eduard. Inlining the hook walk is a
worse option than a helper, because BTF_KFUNC_HOOK_MAX and co are
internal to btf.c and exposing them is uglier.
* remove reduntant btf_is_func check (Jiri)
* formatting nit (Eduard)
v2: https://lore.kernel.org/bpf/20260710192940.3020280-1-ihor.solodrai@linux.dev/
v1->v2:
* Take a module reference in btf_attach_func_proto() around the
btf_kfunc_accumulated_flags() call (sashiko)
v1: https://lore.kernel.org/bpf/20260710005902.2234832-1-ihor.solodrai@linux.dev/
---
====================
Link: https://patch.msgid.link/20260713235223.1639022-1-ihor.solodrai@linux.dev
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>5 files changed
Lines changed: 196 additions & 13 deletions
File tree
- include/linux
- kernel/bpf
- tools/testing/selftests/bpf
- prog_tests
- progs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9114 | 9114 | | |
9115 | 9115 | | |
9116 | 9116 | | |
| 9117 | + | |
| 9118 | + | |
| 9119 | + | |
| 9120 | + | |
| 9121 | + | |
| 9122 | + | |
| 9123 | + | |
| 9124 | + | |
| 9125 | + | |
| 9126 | + | |
| 9127 | + | |
| 9128 | + | |
| 9129 | + | |
| 9130 | + | |
| 9131 | + | |
| 9132 | + | |
| 9133 | + | |
| 9134 | + | |
| 9135 | + | |
| 9136 | + | |
| 9137 | + | |
| 9138 | + | |
| 9139 | + | |
| 9140 | + | |
| 9141 | + | |
| 9142 | + | |
| 9143 | + | |
| 9144 | + | |
| 9145 | + | |
9117 | 9146 | | |
9118 | 9147 | | |
9119 | 9148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2584 | 2584 | | |
2585 | 2585 | | |
2586 | 2586 | | |
2587 | | - | |
| 2587 | + | |
2588 | 2588 | | |
2589 | 2589 | | |
2590 | 2590 | | |
2591 | | - | |
2592 | 2591 | | |
| 2592 | + | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | 2595 | | |
2596 | | - | |
2597 | | - | |
2598 | | - | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
2599 | 2600 | | |
2600 | 2601 | | |
2601 | 2602 | | |
2602 | 2603 | | |
2603 | 2604 | | |
2604 | | - | |
| 2605 | + | |
2605 | 2606 | | |
2606 | 2607 | | |
2607 | 2608 | | |
| |||
2653 | 2654 | | |
2654 | 2655 | | |
2655 | 2656 | | |
2656 | | - | |
| 2657 | + | |
2657 | 2658 | | |
2658 | 2659 | | |
2659 | 2660 | | |
| |||
18880 | 18881 | | |
18881 | 18882 | | |
18882 | 18883 | | |
| 18884 | + | |
| 18885 | + | |
| 18886 | + | |
| 18887 | + | |
| 18888 | + | |
| 18889 | + | |
| 18890 | + | |
| 18891 | + | |
| 18892 | + | |
| 18893 | + | |
| 18894 | + | |
| 18895 | + | |
| 18896 | + | |
| 18897 | + | |
| 18898 | + | |
| 18899 | + | |
| 18900 | + | |
| 18901 | + | |
| 18902 | + | |
| 18903 | + | |
| 18904 | + | |
| 18905 | + | |
| 18906 | + | |
| 18907 | + | |
| 18908 | + | |
| 18909 | + | |
| 18910 | + | |
| 18911 | + | |
| 18912 | + | |
| 18913 | + | |
| 18914 | + | |
| 18915 | + | |
| 18916 | + | |
| 18917 | + | |
| 18918 | + | |
| 18919 | + | |
| 18920 | + | |
| 18921 | + | |
| 18922 | + | |
| 18923 | + | |
| 18924 | + | |
18883 | 18925 | | |
18884 | 18926 | | |
18885 | 18927 | | |
| |||
19128 | 19170 | | |
19129 | 19171 | | |
19130 | 19172 | | |
19131 | | - | |
19132 | | - | |
| 19173 | + | |
| 19174 | + | |
19133 | 19175 | | |
19134 | 19176 | | |
19135 | 19177 | | |
| |||
19412 | 19454 | | |
19413 | 19455 | | |
19414 | 19456 | | |
19415 | | - | |
19416 | | - | |
19417 | | - | |
19418 | | - | |
| 19457 | + | |
| 19458 | + | |
19419 | 19459 | | |
19420 | 19460 | | |
19421 | 19461 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments