Commit 4b3786a
bpf: Zero former ARG_PTR_TO_{LONG,INT} args in case of error
For all non-tracing helpers which formerly had ARG_PTR_TO_{LONG,INT} as input
arguments, zero the value for the case of an error as otherwise it could leak
memory. For tracing, it is not needed given CAP_PERFMON can already read all
kernel memory anyway hence bpf_get_func_arg() and bpf_get_func_ret() is skipped
in here.
Also, the MTU helpers mtu_len pointer value is being written but also read.
Technically, the MEM_UNINIT should not be there in order to always force init.
Removing MEM_UNINIT needs more verifier rework though: MEM_UNINIT right now
implies two things actually: i) write into memory, ii) memory does not have
to be initialized. If we lift MEM_UNINIT, it then becomes: i) read into memory,
ii) memory must be initialized. This means that for bpf_*_check_mtu() we're
readding the issue we're trying to fix, that is, it would then be able to
write back into things like .rodata BPF maps. Follow-up work will rework the
MEM_UNINIT semantics such that the intent can be better expressed. For now
just clear the *mtu_len on error path which can be lifted later again.
Fixes: 8a67f2d ("bpf: expose bpf_strtol and bpf_strtoul to all program types")
Fixes: d7a4cb9 ("bpf: Introduce bpf_strtol and bpf_strtoul helpers")
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 parent 18752d7 commit 4b3786a
3 files changed
+26
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| 526 | + | |
526 | 527 | | |
527 | 528 | | |
528 | 529 | | |
| |||
548 | 549 | | |
549 | 550 | | |
550 | 551 | | |
| 552 | + | |
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5934 | 5934 | | |
5935 | 5935 | | |
5936 | 5936 | | |
| 5937 | + | |
5937 | 5938 | | |
5938 | 5939 | | |
5939 | 5940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6262 | 6262 | | |
6263 | 6263 | | |
6264 | 6264 | | |
6265 | | - | |
| 6265 | + | |
6266 | 6266 | | |
6267 | | - | |
6268 | | - | |
| 6267 | + | |
| 6268 | + | |
| 6269 | + | |
| 6270 | + | |
6269 | 6271 | | |
6270 | | - | |
6271 | | - | |
| 6272 | + | |
| 6273 | + | |
| 6274 | + | |
| 6275 | + | |
6272 | 6276 | | |
6273 | 6277 | | |
6274 | | - | |
6275 | | - | |
| 6278 | + | |
| 6279 | + | |
| 6280 | + | |
| 6281 | + | |
6276 | 6282 | | |
6277 | 6283 | | |
6278 | | - | |
6279 | 6284 | | |
6280 | 6285 | | |
6281 | 6286 | | |
| |||
6293 | 6298 | | |
6294 | 6299 | | |
6295 | 6300 | | |
6296 | | - | |
6297 | 6301 | | |
6298 | 6302 | | |
6299 | 6303 | | |
6300 | 6304 | | |
6301 | 6305 | | |
6302 | | - | |
6303 | 6306 | | |
6304 | | - | |
6305 | 6307 | | |
6306 | 6308 | | |
6307 | 6309 | | |
| |||
6311 | 6313 | | |
6312 | 6314 | | |
6313 | 6315 | | |
6314 | | - | |
| 6316 | + | |
6315 | 6317 | | |
6316 | 6318 | | |
6317 | | - | |
6318 | | - | |
| 6319 | + | |
| 6320 | + | |
| 6321 | + | |
| 6322 | + | |
6319 | 6323 | | |
6320 | 6324 | | |
6321 | | - | |
6322 | | - | |
| 6325 | + | |
| 6326 | + | |
| 6327 | + | |
| 6328 | + | |
6323 | 6329 | | |
6324 | 6330 | | |
6325 | | - | |
6326 | | - | |
6327 | 6331 | | |
6328 | 6332 | | |
6329 | 6333 | | |
| |||
6333 | 6337 | | |
6334 | 6338 | | |
6335 | 6339 | | |
6336 | | - | |
6337 | | - | |
| 6340 | + | |
6338 | 6341 | | |
6339 | | - | |
6340 | 6342 | | |
6341 | 6343 | | |
6342 | 6344 | | |
| |||
0 commit comments