Commit a578b54
Alexei Starovoitov
Merge branch 'bpf-report-arena-faults-to-bpf-streams'
Puranjay Mohan says:
====================
bpf: report arena faults to BPF streams
Changes in v6->v7:
v6: https://lore.kernel.org/all/[email protected]/
- Added comments about the usage of arena_reg in x86 and arm64 jits. (Alexei)
- Used clear_lo32() for clearing the lower 32-bits of user_vm_start. (Alexei)
- Moved update of the old tests to use __stderr to a separate commit (Eduard)
- Used test__skip() in prog_tests/stream.c (Eduard)
- Start a sub-test for read / write
Changes in v5->v6:
v5: https://lore.kernel.org/all/[email protected]/
- Introduces __stderr and __stdout for easy testing of bpf streams
(Eduard)
- Add more test cases for arena fault reporting (subprog and callback)
- Fix main_prog_aux usage and return main_prog from find_from_stack_cb
(Kumar)
- Properly fix the build issue reported by kernel test robot
Changes in v4->v5:
v4: https://lore.kernel.org/all/[email protected]/
- Added patch 2 to introducing main_prog_aux for easier access to
streams.
- Fixed bug in fault handlers when arena_reg == dst_reg
- Updated selftest to check test above edge case.
- Added comments about the usage of barrier_var() in code and commit
message.
Changes in v3->v4:
v3: https://lore.kernel.org/all/[email protected]/
- Fixed a build issue when CONFIG_BPF_JIT=y and # CONFIG_BPF_SYSCALL is
not set
Changes in v2->v3:
v2: https://lore.kernel.org/all/[email protected]/
- Improved the selftest to check the exact fault address
- Dropped BPF_NO_KFUNC_PROTOTYPES and bpf_arena_alloc/free_pages() usage
- Rebased on bpf-next/master
Changes in v1->v2:
v1: https://lore.kernel.org/all/[email protected]/
- Changed variable and mask names for consistency (Yonghong)
- Added Acked-by: Yonghong Song <[email protected]> on two patches
This set adds the support of reporting page faults inside arena to BPF
stderr stream. The reported address is the one that a user would expect
to see if they pass it to bpf_printk();
Here is an example output from the stderr stream and bpf_printk()
ERROR: Arena WRITE access at unmapped address 0xdeaddead0000
CPU: 9 UID: 0 PID: 502 Comm: test_progs
Call trace:
bpf_stream_stage_dump_stack+0xc0/0x150
bpf_prog_report_arena_violation+0x98/0xf0
ex_handler_bpf+0x5c/0x78
fixup_exception+0xf8/0x160
__do_kernel_fault+0x40/0x188
do_bad_area+0x70/0x88
do_translation_fault+0x54/0x98
do_mem_abort+0x4c/0xa8
el1_abort+0x44/0x70
el1h_64_sync_handler+0x50/0x108
el1h_64_sync+0x6c/0x70
bpf_prog_a64a9778d31b8e88_stream_arena_write_fault+0x84/0xc8
*(page) = 1; @ stream.c:100
bpf_prog_test_run_syscall+0x100/0x328
__sys_bpf+0x508/0xb98
__arm64_sys_bpf+0x2c/0x48
invoke_syscall+0x50/0x120
el0_svc_common.constprop.0+0x48/0xf8
do_el0_svc+0x28/0x40
el0_svc+0x48/0xf8
el0t_64_sync_handler+0xa0/0xe8
el0t_64_sync+0x198/0x1a0
Same address is printed by bpf_printk():
1389.078831: bpf_trace_printk: Read Address: 0xdeaddead0000
To make this possible, some extra metadata has to be passed to the bpf
exception handler, so the bpf exception handling mechanism for both
x86-64 and arm64 have been improved in this set.
The streams selftest has been updated to test this new feature.
====================
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>File tree
10 files changed
+491
-112
lines changed- arch
- arm64/net
- x86/net
- include/linux
- kernel/bpf
- tools/testing/selftests/bpf
- prog_tests
- progs
10 files changed
+491
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | | - | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
1070 | 1093 | | |
1071 | 1094 | | |
1072 | 1095 | | |
1073 | 1096 | | |
1074 | 1097 | | |
1075 | 1098 | | |
1076 | | - | |
1077 | 1099 | | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
1078 | 1110 | | |
1079 | 1111 | | |
1080 | 1112 | | |
1081 | | - | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
1082 | 1116 | | |
1083 | 1117 | | |
1084 | 1118 | | |
| |||
1088 | 1122 | | |
1089 | 1123 | | |
1090 | 1124 | | |
1091 | | - | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1092 | 1128 | | |
1093 | 1129 | | |
1094 | 1130 | | |
| |||
1102 | 1138 | | |
1103 | 1139 | | |
1104 | 1140 | | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
1105 | 1144 | | |
1106 | 1145 | | |
1107 | 1146 | | |
| |||
1119 | 1158 | | |
1120 | 1159 | | |
1121 | 1160 | | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | 1161 | | |
1139 | 1162 | | |
1140 | 1163 | | |
| |||
1147 | 1170 | | |
1148 | 1171 | | |
1149 | 1172 | | |
1150 | | - | |
1151 | | - | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1152 | 1193 | | |
1153 | 1194 | | |
1154 | 1195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
1388 | 1389 | | |
1389 | 1390 | | |
1390 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
1391 | 1424 | | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
1392 | 1430 | | |
1393 | 1431 | | |
1394 | 1432 | | |
1395 | | - | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
1396 | 1447 | | |
1397 | 1448 | | |
1398 | 1449 | | |
1399 | 1450 | | |
1400 | | - | |
| 1451 | + | |
| 1452 | + | |
1401 | 1453 | | |
1402 | 1454 | | |
1403 | 1455 | | |
| |||
2070 | 2122 | | |
2071 | 2123 | | |
2072 | 2124 | | |
| 2125 | + | |
2073 | 2126 | | |
2074 | 2127 | | |
2075 | 2128 | | |
| |||
2089 | 2142 | | |
2090 | 2143 | | |
2091 | 2144 | | |
2092 | | - | |
2093 | | - | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
2094 | 2168 | | |
2095 | 2169 | | |
2096 | 2170 | | |
| |||
2208 | 2282 | | |
2209 | 2283 | | |
2210 | 2284 | | |
2211 | | - | |
| 2285 | + | |
| 2286 | + | |
2212 | 2287 | | |
2213 | 2288 | | |
2214 | 2289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1633 | 1633 | | |
1634 | 1634 | | |
1635 | 1635 | | |
| 1636 | + | |
1636 | 1637 | | |
1637 | 1638 | | |
1638 | 1639 | | |
| |||
2880 | 2881 | | |
2881 | 2882 | | |
2882 | 2883 | | |
| 2884 | + | |
2883 | 2885 | | |
2884 | 2886 | | |
2885 | 2887 | | |
| |||
3167 | 3169 | | |
3168 | 3170 | | |
3169 | 3171 | | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
3170 | 3177 | | |
3171 | 3178 | | |
3172 | 3179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
3297 | 3298 | | |
3298 | 3299 | | |
3299 | 3300 | | |
3300 | | - | |
3301 | | - | |
3302 | | - | |
| 3301 | + | |
| 3302 | + | |
3303 | 3303 | | |
3304 | 3304 | | |
3305 | 3305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21601 | 21601 | | |
21602 | 21602 | | |
21603 | 21603 | | |
| 21604 | + | |
21604 | 21605 | | |
21605 | 21606 | | |
21606 | 21607 | | |
| |||
0 commit comments