Commit 7dc484f
Martin KaFai Lau
Merge branch 'support-non-linear-skbs-for-bpf_prog_test_run'
Paul Chaignon says:
====================
Support non-linear skbs for BPF_PROG_TEST_RUN
This patchset adds support for non-linear skbs when running tc programs
with BPF_PROG_TEST_RUN.
We've had multiple bugs in the past few years in Cilium caused by
missing calls to bpf_skb_pull_data(). Daniel suggested to support
non linear skb in BPF_PROG_TEST_RUN to uncover these bugs in
our BPF tests.
Changes in v8:
- Fix uninitialized data pointer spotted by Martin.
- Error out in test_loader if __linear_size tag is used on unsupported
program types.
Changes in v7:
- Refactor use of 'size' variable as suggested by Martin.
- Support copying back the non-linear area to data_out.
- Minor code changes for readability, suggested by Martin.
Changes in v6:
- Disallow non-linear skb in prog_run_skb only for LWT programs
instead of all non-L2 program types, on suggestion from Martin.
- Reject non-null ctx->data and ctx->data_meta, as suggested by Amery.
- Bound linear_size to 'PAGE_SIZE - headroom - tailroom' to be
consistent with prog_run_xdp, as suggested by Martin.
- Allocate exactly linear_size bytes in bpf_test_init, spotted by
Martin.
- Fix wrong conflict resolution on double-free fix, spotted by Amery.
- Rebased.
Changes in v5:
- Fix double free on data in first patch.
Changes in v4:
- Per Martin's suggestion, follow the XDP code pattern and use
bpf_test_init only to initialize the linear area. That way data is
directly copied to the right areas and we avoid the call to
__pskb_pull_tail.
- Fixed outdated commit descriptions.
- Rebased.
Changes in v3:
- Dropped BPF_F_TEST_SKB_NON_LINEAR and used the ctx->data_end to
determine if the user wants non-linear skb, as suggested by Amery.
- Introduced a second commit with a bit of refactoring to allow for
the above requested change.
- Fix bug found by syzkaller on third commit.
- Rebased.
Changes in v2:
- Made the linear size configurable via ctx->data_end, as suggested
by Amery.
- Reworked the selftests to allow testing the configurable linear
size.
- Fix warnings reported by kernel test robot on first commit.
- Rebased.
====================
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>File tree
4 files changed
+193
-42
lines changed- net/bpf
- tools/testing/selftests/bpf
- progs
4 files changed
+193
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
450 | | - | |
| 450 | + | |
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
913 | 919 | | |
914 | 920 | | |
915 | 921 | | |
| |||
984 | 990 | | |
985 | 991 | | |
986 | 992 | | |
987 | | - | |
| 993 | + | |
| 994 | + | |
988 | 995 | | |
989 | 996 | | |
990 | | - | |
| 997 | + | |
| 998 | + | |
991 | 999 | | |
992 | 1000 | | |
| 1001 | + | |
| 1002 | + | |
993 | 1003 | | |
994 | 1004 | | |
995 | | - | |
996 | | - | |
997 | | - | |
| 1005 | + | |
998 | 1006 | | |
999 | 1007 | | |
1000 | 1008 | | |
1001 | 1009 | | |
1002 | 1010 | | |
1003 | 1011 | | |
1004 | | - | |
| 1012 | + | |
1005 | 1013 | | |
1006 | 1014 | | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | 1015 | | |
1020 | 1016 | | |
1021 | 1017 | | |
| 1018 | + | |
1022 | 1019 | | |
1023 | | - | |
| 1020 | + | |
1024 | 1021 | | |
1025 | 1022 | | |
1026 | 1023 | | |
| 1024 | + | |
| 1025 | + | |
1027 | 1026 | | |
1028 | 1027 | | |
1029 | 1028 | | |
1030 | 1029 | | |
1031 | 1030 | | |
1032 | 1031 | | |
1033 | 1032 | | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1034 | 1061 | | |
1035 | 1062 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
| 1063 | + | |
| 1064 | + | |
1039 | 1065 | | |
1040 | 1066 | | |
1041 | 1067 | | |
1042 | 1068 | | |
1043 | 1069 | | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
| 1070 | + | |
| 1071 | + | |
1048 | 1072 | | |
1049 | 1073 | | |
1050 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
1051 | 1077 | | |
1052 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1053 | 1115 | | |
1054 | 1116 | | |
1055 | 1117 | | |
| |||
1129 | 1191 | | |
1130 | 1192 | | |
1131 | 1193 | | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1138 | 1199 | | |
1139 | 1200 | | |
1140 | 1201 | | |
1141 | 1202 | | |
1142 | 1203 | | |
1143 | 1204 | | |
1144 | 1205 | | |
1145 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1146 | 1209 | | |
1147 | 1210 | | |
1148 | 1211 | | |
| |||
1340 | 1403 | | |
1341 | 1404 | | |
1342 | 1405 | | |
1343 | | - | |
| 1406 | + | |
1344 | 1407 | | |
1345 | 1408 | | |
1346 | 1409 | | |
| |||
1431 | 1494 | | |
1432 | 1495 | | |
1433 | 1496 | | |
1434 | | - | |
| 1497 | + | |
1435 | 1498 | | |
1436 | 1499 | | |
1437 | 1500 | | |
| |||
1532 | 1595 | | |
1533 | 1596 | | |
1534 | 1597 | | |
1535 | | - | |
| 1598 | + | |
1536 | 1599 | | |
1537 | 1600 | | |
1538 | 1601 | | |
| |||
1732 | 1795 | | |
1733 | 1796 | | |
1734 | 1797 | | |
1735 | | - | |
| 1798 | + | |
1736 | 1799 | | |
1737 | 1800 | | |
1738 | 1801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
| 165 | + | |
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
800 | 801 | | |
801 | 802 | | |
802 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
803 | 862 | | |
0 commit comments