Commit b2d8ef1
bpf: Cleanup check_refcount_ok
Discussion around a recently-submitted patch provided historical
context for check_refcount_ok [0]. Specifically, the function and its
helpers - may_be_acquire_function and arg_type_may_be_refcounted -
predate the OBJ_RELEASE type flag and the addition of many more helpers
with acquire/release semantics.
The purpose of check_refcount_ok is to ensure:
1) Helper doesn't have multiple uses of return reg's ref_obj_id
2) Helper with release semantics only has one arg needing to be
released, since that's tracked using meta->ref_obj_id
With current verifier, it's safe to remove check_refcount_ok and its
helpers. Since addition of OBJ_RELEASE type flag, case 2) has been
handled by the arg_type_is_release check in check_func_arg. To ensure
case 1) won't result in verifier silently prioritizing one use of
ref_obj_id, this patch adds a helper_multiple_ref_obj_use check which
fails loudly if a helper passes > 1 test for use of ref_obj_id.
[0]: lore.kernel.org/bpf/20220713234529.4154673-1-davemarchevsky@fb.com
Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20220808171559.3251090-1-davemarchevsky@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent 6e11628 commit b2d8ef1
1 file changed
+29
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | 470 | | |
476 | 471 | | |
477 | 472 | | |
478 | 473 | | |
479 | 474 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | 475 | | |
490 | 476 | | |
491 | 477 | | |
| |||
518 | 504 | | |
519 | 505 | | |
520 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
521 | 527 | | |
522 | 528 | | |
523 | 529 | | |
| |||
6453 | 6459 | | |
6454 | 6460 | | |
6455 | 6461 | | |
6456 | | - | |
6457 | | - | |
6458 | | - | |
6459 | | - | |
6460 | | - | |
6461 | | - | |
6462 | | - | |
6463 | | - | |
6464 | | - | |
6465 | | - | |
6466 | | - | |
6467 | | - | |
6468 | | - | |
6469 | | - | |
6470 | | - | |
6471 | | - | |
6472 | | - | |
6473 | | - | |
6474 | | - | |
6475 | | - | |
6476 | | - | |
6477 | | - | |
6478 | | - | |
6479 | | - | |
6480 | | - | |
6481 | | - | |
6482 | | - | |
6483 | 6462 | | |
6484 | 6463 | | |
6485 | 6464 | | |
| |||
6502 | 6481 | | |
6503 | 6482 | | |
6504 | 6483 | | |
6505 | | - | |
6506 | | - | |
| 6484 | + | |
6507 | 6485 | | |
6508 | 6486 | | |
6509 | 6487 | | |
| |||
7473 | 7451 | | |
7474 | 7452 | | |
7475 | 7453 | | |
| 7454 | + | |
| 7455 | + | |
| 7456 | + | |
| 7457 | + | |
| 7458 | + | |
| 7459 | + | |
7476 | 7460 | | |
7477 | 7461 | | |
7478 | 7462 | | |
| |||
7485 | 7469 | | |
7486 | 7470 | | |
7487 | 7471 | | |
7488 | | - | |
| 7472 | + | |
7489 | 7473 | | |
7490 | 7474 | | |
7491 | | - | |
| 7475 | + | |
7492 | 7476 | | |
7493 | 7477 | | |
7494 | 7478 | | |
| |||
0 commit comments