Commit 956cfef
bpf: Add dynptr data slices
This patch adds a new helper function
void *bpf_dynptr_data(struct bpf_dynptr *ptr, u32 offset, u32 len);
which returns a pointer to the underlying data of a dynptr. *len*
must be a statically known value. The bpf program may access the returned
data slice as a normal buffer (eg can do direct reads and writes), since
the verifier associates the length with the returned pointer, and
enforces that no out of bounds accesses occur.
This requires a few additions to the verifier. For every
referenced-tracked dynptr that is initialized, we associate an id with
it and attach any data slices to that id. When a release function is
called on a dynptr (eg bpf_free), we invalidate all slices that
correspond to that dynptr. This ensures the slice can't be used after
its dynptr has been invalidated.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>1 parent 1576cfc commit 956cfef
File tree
5 files changed
+122
-2
lines changed- include
- linux
- uapi/linux
- kernel/bpf
- tools/include/uapi/linux
5 files changed
+122
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5191 | 5191 | | |
5192 | 5192 | | |
5193 | 5193 | | |
| 5194 | + | |
| 5195 | + | |
| 5196 | + | |
| 5197 | + | |
| 5198 | + | |
| 5199 | + | |
| 5200 | + | |
| 5201 | + | |
| 5202 | + | |
| 5203 | + | |
| 5204 | + | |
5194 | 5205 | | |
5195 | 5206 | | |
5196 | 5207 | | |
| |||
5392 | 5403 | | |
5393 | 5404 | | |
5394 | 5405 | | |
| 5406 | + | |
5395 | 5407 | | |
5396 | 5408 | | |
5397 | 5409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1412 | 1412 | | |
1413 | 1413 | | |
1414 | 1414 | | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1415 | 1441 | | |
1416 | 1442 | | |
1417 | 1443 | | |
| |||
1570 | 1596 | | |
1571 | 1597 | | |
1572 | 1598 | | |
| 1599 | + | |
| 1600 | + | |
1573 | 1601 | | |
1574 | 1602 | | |
1575 | 1603 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| |||
523 | 528 | | |
524 | 529 | | |
525 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
526 | 536 | | |
527 | 537 | | |
528 | 538 | | |
| |||
700 | 710 | | |
701 | 711 | | |
702 | 712 | | |
703 | | - | |
| 713 | + | |
704 | 714 | | |
705 | 715 | | |
706 | 716 | | |
| |||
721 | 731 | | |
722 | 732 | | |
723 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
724 | 747 | | |
725 | 748 | | |
726 | 749 | | |
727 | 750 | | |
728 | 751 | | |
| 752 | + | |
729 | 753 | | |
| 754 | + | |
730 | 755 | | |
731 | 756 | | |
732 | 757 | | |
733 | 758 | | |
734 | 759 | | |
735 | 760 | | |
736 | 761 | | |
| 762 | + | |
| 763 | + | |
737 | 764 | | |
738 | 765 | | |
739 | 766 | | |
| |||
743 | 770 | | |
744 | 771 | | |
745 | 772 | | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
746 | 782 | | |
747 | 783 | | |
748 | 784 | | |
| |||
780 | 816 | | |
781 | 817 | | |
782 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
783 | 832 | | |
784 | 833 | | |
785 | 834 | | |
| |||
5585 | 5634 | | |
5586 | 5635 | | |
5587 | 5636 | | |
| 5637 | + | |
| 5638 | + | |
| 5639 | + | |
| 5640 | + | |
| 5641 | + | |
| 5642 | + | |
| 5643 | + | |
| 5644 | + | |
5588 | 5645 | | |
5589 | 5646 | | |
5590 | 5647 | | |
| |||
7114 | 7171 | | |
7115 | 7172 | | |
7116 | 7173 | | |
| 7174 | + | |
| 7175 | + | |
| 7176 | + | |
| 7177 | + | |
| 7178 | + | |
| 7179 | + | |
| 7180 | + | |
| 7181 | + | |
7117 | 7182 | | |
7118 | 7183 | | |
7119 | 7184 | | |
| |||
9545 | 9610 | | |
9546 | 9611 | | |
9547 | 9612 | | |
9548 | | - | |
| 9613 | + | |
| 9614 | + | |
9549 | 9615 | | |
9550 | 9616 | | |
9551 | 9617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5191 | 5191 | | |
5192 | 5192 | | |
5193 | 5193 | | |
| 5194 | + | |
| 5195 | + | |
| 5196 | + | |
| 5197 | + | |
| 5198 | + | |
| 5199 | + | |
| 5200 | + | |
| 5201 | + | |
| 5202 | + | |
| 5203 | + | |
| 5204 | + | |
5194 | 5205 | | |
5195 | 5206 | | |
5196 | 5207 | | |
| |||
5392 | 5403 | | |
5393 | 5404 | | |
5394 | 5405 | | |
| 5406 | + | |
5395 | 5407 | | |
5396 | 5408 | | |
5397 | 5409 | | |
| |||
0 commit comments