Commit 7d0d673
bpf: Fix theoretical prog_array UAF in __uprobe_perf_func()
Currently, the pointer stored in call->prog_array is loaded in
__uprobe_perf_func(), with no RCU annotation and no immediately visible
RCU protection, so it looks as if the loaded pointer can immediately be
dangling.
Later, bpf_prog_run_array_uprobe() starts a RCU-trace read-side critical
section, but this is too late. It then uses rcu_dereference_check(), but
this use of rcu_dereference_check() does not actually dereference anything.
Fix it by aligning the semantics to bpf_prog_run_array(): Let the caller
provide rcu_read_lock_trace() protection and then load call->prog_array
with rcu_dereference_check().
This issue seems to be theoretical: I don't know of any way to reach this
code without having handle_swbp() further up the stack, which is already
holding a rcu_read_lock_trace() lock, so where we take
rcu_read_lock_trace() in __uprobe_perf_func()/bpf_prog_run_array_uprobe()
doesn't actually have any effect.
Fixes: 8c7dcb8 ("bpf: implement sleepable uprobes by chaining gps")
Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241210-bpf-fix-uprobe-uaf-v4-1-5fc8959b2b74@google.com1 parent c4441ca commit 7d0d673
2 files changed
+10
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2194 | 2194 | | |
2195 | 2195 | | |
2196 | 2196 | | |
2197 | | - | |
| 2197 | + | |
2198 | 2198 | | |
2199 | 2199 | | |
2200 | 2200 | | |
2201 | 2201 | | |
2202 | | - | |
2203 | 2202 | | |
2204 | 2203 | | |
2205 | 2204 | | |
2206 | 2205 | | |
2207 | 2206 | | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
2208 | 2211 | | |
2209 | | - | |
2210 | 2212 | | |
2211 | 2213 | | |
2212 | 2214 | | |
2213 | 2215 | | |
2214 | | - | |
2215 | | - | |
2216 | | - | |
2217 | 2216 | | |
2218 | 2217 | | |
2219 | 2218 | | |
| |||
2228 | 2227 | | |
2229 | 2228 | | |
2230 | 2229 | | |
2231 | | - | |
2232 | 2230 | | |
2233 | | - | |
2234 | 2231 | | |
2235 | 2232 | | |
2236 | 2233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1402 | 1402 | | |
1403 | 1403 | | |
1404 | 1404 | | |
| 1405 | + | |
1405 | 1406 | | |
1406 | 1407 | | |
1407 | | - | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1408 | 1412 | | |
1409 | 1413 | | |
1410 | 1414 | | |
| |||
0 commit comments