Commit b0966c7
bpf: Support bpf_kptr_xchg into local kptr
Currently, users can only stash kptr into map values with bpf_kptr_xchg().
This patch further supports stashing kptr into local kptr by adding local
kptr as a valid destination type.
When stashing into local kptr, btf_record in program BTF is used instead
of btf_record in map to search for the btf_field of the local kptr.
The local kptr specific checks in check_reg_type() only apply when the
source argument of bpf_kptr_xchg() is local kptr. Therefore, we make the
scope of the check explicit as the destination now can also be local kptr.
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Amery Hung <amery.hung@bytedance.com>
Link: https://lore.kernel.org/r/20240813212424.2871455-5-amery.hung@bytedance.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent d59232a commit b0966c7
3 files changed
Lines changed: 37 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5519 | 5519 | | |
5520 | 5520 | | |
5521 | 5521 | | |
5522 | | - | |
| 5522 | + | |
5523 | 5523 | | |
5524 | | - | |
5525 | | - | |
5526 | | - | |
| 5524 | + | |
| 5525 | + | |
| 5526 | + | |
| 5527 | + | |
5527 | 5528 | | |
5528 | 5529 | | |
5529 | 5530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1619 | 1619 | | |
1620 | 1620 | | |
1621 | 1621 | | |
1622 | | - | |
| 1622 | + | |
1623 | 1623 | | |
1624 | | - | |
| 1624 | + | |
1625 | 1625 | | |
1626 | 1626 | | |
1627 | 1627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7803 | 7803 | | |
7804 | 7804 | | |
7805 | 7805 | | |
7806 | | - | |
7807 | 7806 | | |
| 7807 | + | |
| 7808 | + | |
7808 | 7809 | | |
7809 | 7810 | | |
| 7811 | + | |
| 7812 | + | |
| 7813 | + | |
| 7814 | + | |
| 7815 | + | |
| 7816 | + | |
| 7817 | + | |
| 7818 | + | |
| 7819 | + | |
| 7820 | + | |
| 7821 | + | |
| 7822 | + | |
| 7823 | + | |
7810 | 7824 | | |
7811 | 7825 | | |
7812 | 7826 | | |
7813 | 7827 | | |
7814 | 7828 | | |
7815 | 7829 | | |
7816 | | - | |
7817 | | - | |
7818 | | - | |
7819 | | - | |
7820 | | - | |
7821 | | - | |
7822 | | - | |
| 7830 | + | |
| 7831 | + | |
| 7832 | + | |
7823 | 7833 | | |
7824 | 7834 | | |
7825 | 7835 | | |
7826 | | - | |
7827 | 7836 | | |
7828 | | - | |
| 7837 | + | |
7829 | 7838 | | |
7830 | 7839 | | |
7831 | 7840 | | |
| |||
8412 | 8421 | | |
8413 | 8422 | | |
8414 | 8423 | | |
8415 | | - | |
| 8424 | + | |
| 8425 | + | |
| 8426 | + | |
| 8427 | + | |
| 8428 | + | |
| 8429 | + | |
8416 | 8430 | | |
8417 | 8431 | | |
8418 | 8432 | | |
| |||
8483 | 8497 | | |
8484 | 8498 | | |
8485 | 8499 | | |
8486 | | - | |
| 8500 | + | |
| 8501 | + | |
8487 | 8502 | | |
8488 | 8503 | | |
8489 | 8504 | | |
| |||
8576 | 8591 | | |
8577 | 8592 | | |
8578 | 8593 | | |
8579 | | - | |
| 8594 | + | |
| 8595 | + | |
8580 | 8596 | | |
8581 | 8597 | | |
8582 | 8598 | | |
| |||
8887 | 8903 | | |
8888 | 8904 | | |
8889 | 8905 | | |
8890 | | - | |
| 8906 | + | |
8891 | 8907 | | |
8892 | 8908 | | |
8893 | 8909 | | |
| |||
0 commit comments