Commit 15123f8
bpf: tail calls do not modify packet data
The bpf verifier checks whether packet data is modified within a helper
function, and if so invalidates the pointer to that data. Currently the
verifier always invalidates if the helper function called is a tail
call, as it cannot tell whether the called function does or does not
modify the packet data.
However, in this case, the fact that the packet might be modified is
irrelevant in the code following the helper call, as the tail call only
returns if there is nothing to execute, otherwise the calling
(sub)program will return directly after the tail call finished.
So it is this (sub)program for which the pointer to packet data needs to
be invalidated.
Fortunately, there are already two distinct points in the code for
invalidating packet pointers directly after a helper call, and for
entire (sub)programs. This commit assures that the pointer is only
invalidated in the relevant case.
Note that this is a regression bug: taking care of tail calls only
became necessary when subprograms were introduced, before commit
1a4607f using a packet pointer after a tail call was working fine,
as it should.
Fixes: 1a4607f ("bpf: consider that tail calls invalidate packet pointers")
Signed-off-by: Martin Teichmann <[email protected]>1 parent 6593a90 commit 15123f8
File tree
3 files changed
+18
-5
lines changed- kernel/bpf
- net/core
- tools/testing/selftests/bpf/progs
3 files changed
+18
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17827 | 17827 | | |
17828 | 17828 | | |
17829 | 17829 | | |
17830 | | - | |
| 17830 | + | |
| 17831 | + | |
17831 | 17832 | | |
17832 | 17833 | | |
17833 | 17834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8032 | 8032 | | |
8033 | 8033 | | |
8034 | 8034 | | |
8035 | | - | |
8036 | | - | |
8037 | 8035 | | |
8038 | 8036 | | |
8039 | 8037 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
| 1120 | + | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | | - | |
| 1123 | + | |
1124 | 1124 | | |
1125 | 1125 | | |
1126 | 1126 | | |
| |||
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1134 | 1148 | | |
0 commit comments