Commit 2d07fba
authored
Improvements to dependency tracking (#69)
So far dependency tracking in bpfvv relied only on interpretation of
individual instructions. For example, `r1 = r6` is parsed as ALU
instruction that *reads* r6 and *writes* to r1.
BPF verifier often prints relevant values for instructions, and bpfvv
of course parses them to build an array of BpfState objects.
This change expands the dependency tracking to include information
about value changes, as reported by the verifier.
For example:
26: (bf) r6 = r0 ; R0_w=map_value_or_null(id=1,map=bpfj_pod_map,ks=4,vs=1040) R6_w=map_value_or_null(id=1,map=bpfj_pod_map,ks=4,vs=1040)
...
29: (15) if r6 == 0x0 goto pc+27 ; R6=map_value(map=bpfj_pod_map,ks=4,vs=1040)
Note that the value of r6 has changed from `map_value_or_null` to
`map_value`, even though there was no actual writes to r6 in the
instruction stream. It is correct however, because in this trace
verifier is exploring a branch where r6 is not equal to 0, and so it's
value (as interpreted by the verifier) did actually change.
In bpfvv, we can notice such value changes and take them into account
when calculating dependencies. This also has an additional benefit of
indirect stack access tracking, at least in simple cases, such as:
525: (bf) r1 = r10 ; frame2: R1_w=fp0 R10=fp0
526: (07) r1 += -24 ; frame2: R1_w=fp-24
...
529: (7b) *(u64 *)(r1 +0) = r8 ; frame2: R1_w=fp-24 R8=scalar(id=102) fp-24_w=scalar(id=102)
...
999: (79) r6 = *(u64 *)(r10 -24) ;
With this change, the user can now see the dependency of instruction
at 999 on 529, even though stack access is indirect.1 parent d0744e1 commit 2d07fba
File tree
4 files changed
+71
-23
lines changed- src
- __snapshots__
4 files changed
+71
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
286 | 290 | | |
287 | 291 | | |
288 | 292 | | |
| |||
338 | 342 | | |
339 | 343 | | |
340 | 344 | | |
341 | | - | |
| 345 | + | |
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
348 | 355 | | |
349 | 356 | | |
350 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
188 | 223 | | |
189 | 224 | | |
190 | 225 | | |
| |||
215 | 250 | | |
216 | 251 | | |
217 | 252 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 253 | + | |
222 | 254 | | |
223 | 255 | | |
224 | 256 | | |
| |||
230 | 262 | | |
231 | 263 | | |
232 | 264 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
| 265 | + | |
237 | 266 | | |
238 | 267 | | |
239 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
| |||
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
100 | | - | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
| |||
156 | 154 | | |
157 | 155 | | |
158 | 156 | | |
159 | | - | |
| 157 | + | |
160 | 158 | | |
161 | 159 | | |
162 | 160 | | |
| |||
245 | 243 | | |
246 | 244 | | |
247 | 245 | | |
248 | | - | |
| 246 | + | |
| 247 | + | |
249 | 248 | | |
250 | | - | |
251 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
409 | 415 | | |
410 | 416 | | |
411 | 417 | | |
412 | | - | |
| 418 | + | |
413 | 419 | | |
414 | 420 | | |
415 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
283 | 281 | | |
284 | 282 | | |
285 | 283 | | |
| |||
645 | 643 | | |
646 | 644 | | |
647 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
648 | 654 | | |
649 | 655 | | |
650 | 656 | | |
| |||
655 | 661 | | |
656 | 662 | | |
657 | 663 | | |
658 | | - | |
| 664 | + | |
659 | 665 | | |
660 | 666 | | |
661 | 667 | | |
| |||
0 commit comments