Commit e71ad5a
bpf: Fall back to nospec for sanitization-failures
ALU sanitization was introduced to ensure that a subsequent ptr access
can never go OOB, even under speculation. This is required because we
currently allow speculative scalar confusion. Spec. scalar confusion is
possible because Spectre v4 sanitization only adds a nospec after
critical stores (e.g., scalar overwritten with a pointer).
If we add a nospec before the ALU op, none of the operands can be
subject to scalar confusion. As an ADD/SUB can not introduce scalar
confusion itself, the result will also not be subject to scalar
confusion. Therefore, the subsequent ptr access is always safe.
We directly fall back to nospec for the sanitization errors
REASON_BOUNDS, _TYPE, _PATHS, and _LIMIT, even if we are not on a
speculative path.
For REASON_STACK, we return the error -ENOMEM directly now. Previously,
sanitize_err() returned -EACCES for this case but we change it to
-ENOMEM because doing so prevents do_check() from falling back to a
nospec if we are on a speculative path. This would not be a serious
issue (the verifier would probably run into the -ENOMEM again shortly on
the next non-speculative path and still abort verification), but -ENOMEM
is more fitting here anyway. An alternative would be -EFAULT, which is
also returned for some of the other cases where push_stack() fails, but
this is more frequently used for verifier-internal bugs.
Signed-off-by: Luis Gerhorst <[email protected]>
Acked-by: Henriette Herzog <[email protected]>
Cc: Maximilian Ott <[email protected]>
Cc: Milan Stephan <[email protected]>1 parent 468b483 commit e71ad5a
File tree
5 files changed
+156
-96
lines changed- kernel/bpf
- tools/testing/selftests/bpf/progs
5 files changed
+156
-96
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13967 | 13967 | | |
13968 | 13968 | | |
13969 | 13969 | | |
13970 | | - | |
13971 | | - | |
13972 | | - | |
13973 | | - | |
13974 | | - | |
13975 | | - | |
13976 | | - | |
13977 | | - | |
13978 | 13970 | | |
13979 | 13971 | | |
13980 | 13972 | | |
| |||
13997 | 13989 | | |
13998 | 13990 | | |
13999 | 13991 | | |
14000 | | - | |
| 13992 | + | |
| 13993 | + | |
14001 | 13994 | | |
14002 | 13995 | | |
| 13996 | + | |
14003 | 13997 | | |
14004 | | - | |
| 13998 | + | |
14005 | 13999 | | |
14006 | 14000 | | |
14007 | 14001 | | |
| |||
14022 | 14016 | | |
14023 | 14017 | | |
14024 | 14018 | | |
14025 | | - | |
14026 | | - | |
| 14019 | + | |
| 14020 | + | |
| 14021 | + | |
| 14022 | + | |
| 14023 | + | |
| 14024 | + | |
14027 | 14025 | | |
14028 | 14026 | | |
14029 | 14027 | | |
| |||
14104 | 14102 | | |
14105 | 14103 | | |
14106 | 14104 | | |
14107 | | - | |
14108 | | - | |
| 14105 | + | |
| 14106 | + | |
| 14107 | + | |
| 14108 | + | |
| 14109 | + | |
| 14110 | + | |
14109 | 14111 | | |
14110 | 14112 | | |
14111 | 14113 | | |
14112 | 14114 | | |
14113 | 14115 | | |
14114 | 14116 | | |
14115 | | - | |
14116 | | - | |
| 14117 | + | |
| 14118 | + | |
| 14119 | + | |
| 14120 | + | |
| 14121 | + | |
| 14122 | + | |
14117 | 14123 | | |
14118 | 14124 | | |
14119 | 14125 | | |
| |||
14166 | 14172 | | |
14167 | 14173 | | |
14168 | 14174 | | |
14169 | | - | |
| 14175 | + | |
14170 | 14176 | | |
14171 | 14177 | | |
14172 | 14178 | | |
| |||
14182 | 14188 | | |
14183 | 14189 | | |
14184 | 14190 | | |
14185 | | - | |
14186 | | - | |
14187 | | - | |
14188 | | - | |
14189 | | - | |
14190 | | - | |
14191 | | - | |
14192 | | - | |
14193 | | - | |
14194 | | - | |
14195 | | - | |
14196 | | - | |
14197 | | - | |
14198 | | - | |
14199 | | - | |
14200 | | - | |
14201 | | - | |
14202 | | - | |
14203 | | - | |
14204 | | - | |
14205 | | - | |
14206 | | - | |
14207 | | - | |
14208 | | - | |
14209 | | - | |
14210 | | - | |
14211 | | - | |
14212 | | - | |
14213 | | - | |
14214 | | - | |
14215 | | - | |
14216 | | - | |
14217 | | - | |
14218 | | - | |
14219 | | - | |
14220 | | - | |
14221 | | - | |
14222 | | - | |
14223 | | - | |
14224 | 14191 | | |
14225 | 14192 | | |
14226 | 14193 | | |
| |||
14386 | 14353 | | |
14387 | 14354 | | |
14388 | 14355 | | |
14389 | | - | |
| 14356 | + | |
14390 | 14357 | | |
14391 | 14358 | | |
14392 | 14359 | | |
| |||
14514 | 14481 | | |
14515 | 14482 | | |
14516 | 14483 | | |
14517 | | - | |
| 14484 | + | |
14518 | 14485 | | |
14519 | 14486 | | |
14520 | 14487 | | |
| |||
15108 | 15075 | | |
15109 | 15076 | | |
15110 | 15077 | | |
15111 | | - | |
| 15078 | + | |
15112 | 15079 | | |
15113 | 15080 | | |
15114 | 15081 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
Lines changed: 29 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
57 | | - | |
| 61 | + | |
58 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | | - | |
| 84 | + | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
| |||
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
90 | | - | |
| 99 | + | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
97 | | - | |
| 106 | + | |
| 107 | + | |
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
104 | 114 | | |
105 | | - | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
112 | | - | |
| 122 | + | |
| 123 | + | |
113 | 124 | | |
114 | 125 | | |
115 | 126 | | |
| |||
121 | 132 | | |
122 | 133 | | |
123 | 134 | | |
124 | | - | |
| 135 | + | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
129 | 140 | | |
130 | 141 | | |
| 142 | + | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
| |||
140 | 152 | | |
141 | 153 | | |
142 | 154 | | |
143 | | - | |
| 155 | + | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
149 | | - | |
| 161 | + | |
| 162 | + | |
150 | 163 | | |
151 | 164 | | |
152 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
115 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
| |||
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
137 | | - | |
138 | | - | |
| 145 | + | |
139 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
140 | 152 | | |
141 | 153 | | |
142 | 154 | | |
| |||
0 commit comments