Commit 0ad67ad
bpf: Enable BPF_LINK_UPDATE for fentry/fexit/fmod_ret links
Implement program update for other link types supported by
bpf_tracing_link_lops (fentry, fexit, fmod_ret, ...). I wanted to make
the implementation generic so that no architecture-specific support
would be required, but couldn't think of a good way to do this:
* I considered updating link.prog before calling bpf_trampoline_update
and reverting it back to the old prog if the update fails, but this
could create inconsistencies with concurrent operations that read
links where they see the uncommitted program associated with the link.
* I considered making a deep copy of the link whose program is being
updated and putting a pointer to that copy into tlinks when calling
bpf_trampoline_get_progs where the copy references the new program
instead of the current program. This would avoid updating the original
link.prog before the update was committed; however, this seemed
slightly hacky and I wasn't sure if this was better than just making
the architecture-specific layer aware of the intent to update one of
the link programs.
This patch sets up the scaffolding for trampoline program updates while
subsequent patches enable this for various architectures. For now, only
x86, arm64, and s390 are implemented since that's what I could test in
CI.
Add update_link and update_prog to bpf_tramp_links. When these are
set, arch_bpf_trampoline_size() and arch_prepare_bpf_trampoline() use
update_prog in place of update_link->link.prog when calculating the
trampoline size and constructing a new trampoline image. link.prog is
only updated after the trampoline update is successfully committed. If
the current architecture does not support program updates (i.e.
bpf_trampoline_supports_update_prog() is not implemented) then the
BPF_LINK_UPDATE operation will return -ENOTSUPP.
Signed-off-by: Jordan Rife <[email protected]>1 parent e4f4b92 commit 0ad67ad
2 files changed
+39
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1215 | 1215 | | |
1216 | 1216 | | |
1217 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
1218 | 1220 | | |
1219 | 1221 | | |
1220 | 1222 | | |
| |||
1245 | 1247 | | |
1246 | 1248 | | |
1247 | 1249 | | |
| 1250 | + | |
1248 | 1251 | | |
1249 | 1252 | | |
1250 | 1253 | | |
| |||
1840 | 1843 | | |
1841 | 1844 | | |
1842 | 1845 | | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
1843 | 1853 | | |
1844 | 1854 | | |
1845 | 1855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
236 | 239 | | |
237 | 240 | | |
238 | 241 | | |
| |||
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
255 | 263 | | |
256 | 264 | | |
257 | 265 | | |
| |||
397 | 405 | | |
398 | 406 | | |
399 | 407 | | |
400 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
401 | 412 | | |
402 | 413 | | |
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
406 | 417 | | |
407 | 418 | | |
408 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
| |||
503 | 518 | | |
504 | 519 | | |
505 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
506 | 526 | | |
507 | 527 | | |
508 | 528 | | |
| |||
626 | 646 | | |
627 | 647 | | |
628 | 648 | | |
629 | | - | |
| 649 | + | |
630 | 650 | | |
631 | 651 | | |
632 | 652 | | |
| |||
1136 | 1156 | | |
1137 | 1157 | | |
1138 | 1158 | | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1139 | 1164 | | |
1140 | 1165 | | |
1141 | 1166 | | |
| |||
0 commit comments