- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitb69aba7
committed
Improve error handling of cryptohash computations
The existing cryptohash facility was causing problems in some code pathsrelated to MD5 (frontend and backend) that relied on the fact that theonly type of error that could happen would be an OOM, as the MD5implementation used in PostgreSQL ~13 (the in-core implementation isused when compiling with or without OpenSSL in those older versions),could fail only under this circumstance.The new cryptohash facilities can fail for reasons other than OOMs, likeattempting MD5 when FIPS is enabled (upstream OpenSSL allows that up to1.0.2, Fedora and Photon patch OpenSSL 1.1.1 to allow that), so thiswould cause incorrect reports to show up.This commit extends the cryptohash APIs so as callers of those routinescan fetch more context when an error happens, by using a new routinecalled pg_cryptohash_error(). The error states are stored within eachimplementation's internal context data, so as it is possible to extendthe logic depending on what's suited for an implementation. The defaultimplementation requires few error states, but OpenSSL could reportvarious issues depending on its internal state so more is needed incryptohash_openssl.c, and the code is shaped so as we are always able tograb the necessary information.The core code is changed to adapt to the new error routine, paintingmore "const" across the call stack where the static errors are stored,particularly in authentication code paths on variables that providelog details. This way, any future changes would warn if attempting tofree these strings. The MD5 authentication code was also a bit blurryabout the handling of "logdetail" (LOG sent to the postmaster), soimprove the comments related that, while on it.The origin of the problem is87ae969, that introduced the centralizedcryptohash facility. Extra changes are done for pgcrypto in v14 for thenon-OpenSSL code path to cope with the improvements done by thiscommit.Reported-by: Michael MühlbeyerAuthor: Michael PaquierReviewed-by: Tom LaneDiscussion:https://postgr.es/m/89B7F072-5BBE-4C92-903E-D83E865D9367@trivadis.comBackpatch-through: 141 parent9ef2c65 commitb69aba7
File tree
18 files changed
+275
-77
lines changed- contrib
- passwordcheck
- uuid-ossp
- src
- backend
- commands
- libpq
- replication
- utils/adt
- common
- include
- common
- libpq
- interfaces/libpq
- tools/pgindent
18 files changed
+275
-77
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
77 |
| - | |
| 77 | + | |
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
|
Lines changed: 12 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
319 | 319 |
| |
320 | 320 |
| |
321 | 321 |
| |
322 |
| - | |
| 322 | + | |
| 323 | + | |
323 | 324 |
| |
324 | 325 |
| |
325 |
| - | |
| 326 | + | |
| 327 | + | |
326 | 328 |
| |
327 | 329 |
| |
328 | 330 |
| |
329 |
| - | |
| 331 | + | |
| 332 | + | |
330 | 333 |
| |
331 | 334 |
| |
332 | 335 |
| |
| |||
335 | 338 |
| |
336 | 339 |
| |
337 | 340 |
| |
338 |
| - | |
| 341 | + | |
| 342 | + | |
339 | 343 |
| |
340 | 344 |
| |
341 |
| - | |
| 345 | + | |
| 346 | + | |
342 | 347 |
| |
343 |
| - | |
| 348 | + | |
| 349 | + | |
344 | 350 |
| |
345 | 351 |
| |
346 | 352 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
358 |
| - | |
| 358 | + | |
359 | 359 |
| |
360 | 360 |
| |
361 | 361 |
| |
| |||
775 | 775 |
| |
776 | 776 |
| |
777 | 777 |
| |
778 |
| - | |
| 778 | + | |
779 | 779 |
| |
780 | 780 |
| |
781 | 781 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 |
| - | |
| 53 | + | |
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
111 | 111 |
| |
112 | 112 |
| |
113 | 113 |
| |
114 |
| - | |
| 114 | + | |
| 115 | + | |
115 | 116 |
| |
116 | 117 |
| |
117 | 118 |
| |
| |||
335 | 336 |
| |
336 | 337 |
| |
337 | 338 |
| |
338 |
| - | |
| 339 | + | |
339 | 340 |
| |
340 | 341 |
| |
341 | 342 |
| |
|
Lines changed: 20 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
| 48 | + | |
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 |
| - | |
58 |
| - | |
| 57 | + | |
| 58 | + | |
59 | 59 |
| |
60 |
| - | |
| 60 | + | |
| 61 | + | |
61 | 62 |
| |
62 | 63 |
| |
63 | 64 |
| |
| |||
247 | 248 |
| |
248 | 249 |
| |
249 | 250 |
| |
250 |
| - | |
| 251 | + | |
251 | 252 |
| |
252 | 253 |
| |
253 | 254 |
| |
| |||
383 | 384 |
| |
384 | 385 |
| |
385 | 386 |
| |
386 |
| - | |
| 387 | + | |
387 | 388 |
| |
388 | 389 |
| |
389 | 390 |
| |
| |||
769 | 770 |
| |
770 | 771 |
| |
771 | 772 |
| |
772 |
| - | |
| 773 | + | |
773 | 774 |
| |
774 | 775 |
| |
775 | 776 |
| |
| |||
804 | 805 |
| |
805 | 806 |
| |
806 | 807 |
| |
807 |
| - | |
| 808 | + | |
808 | 809 |
| |
809 | 810 |
| |
810 | 811 |
| |
| |||
866 | 867 |
| |
867 | 868 |
| |
868 | 869 |
| |
869 |
| - | |
| 870 | + | |
870 | 871 |
| |
871 | 872 |
| |
872 | 873 |
| |
| |||
3085 | 3086 |
| |
3086 | 3087 |
| |
3087 | 3088 |
| |
| 3089 | + | |
| 3090 | + | |
3088 | 3091 |
| |
3089 | 3092 |
| |
3090 | 3093 |
| |
| |||
3093 | 3096 |
| |
3094 | 3097 |
| |
3095 | 3098 |
| |
3096 |
| - | |
| 3099 | + | |
| 3100 | + | |
3097 | 3101 |
| |
3098 | 3102 |
| |
3099 |
| - | |
| 3103 | + | |
| 3104 | + | |
3100 | 3105 |
| |
3101 | 3106 |
| |
3102 | 3107 |
| |
| |||
3181 | 3186 |
| |
3182 | 3187 |
| |
3183 | 3188 |
| |
| 3189 | + | |
3184 | 3190 |
| |
3185 | 3191 |
| |
3186 | 3192 |
| |
| |||
3299 | 3305 |
| |
3300 | 3306 |
| |
3301 | 3307 |
| |
3302 |
| - | |
| 3308 | + | |
3303 | 3309 |
| |
3304 | 3310 |
| |
3305 |
| - | |
| 3311 | + | |
| 3312 | + | |
3306 | 3313 |
| |
3307 | 3314 |
| |
3308 | 3315 |
| |
|
Lines changed: 17 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
37 |
| - | |
| 37 | + | |
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
| 119 | + | |
119 | 120 |
| |
120 | 121 |
| |
121 | 122 |
| |
| |||
132 | 133 |
| |
133 | 134 |
| |
134 | 135 |
| |
135 |
| - | |
136 |
| - | |
| 136 | + | |
| 137 | + | |
137 | 138 |
| |
138 | 139 |
| |
139 | 140 |
| |
| |||
159 | 160 |
| |
160 | 161 |
| |
161 | 162 |
| |
162 |
| - | |
163 |
| - | |
| 163 | + | |
| 164 | + | |
164 | 165 |
| |
165 | 166 |
| |
166 | 167 |
| |
167 | 168 |
| |
168 | 169 |
| |
169 |
| - | |
| 170 | + | |
170 | 171 |
| |
171 | 172 |
| |
172 | 173 |
| |
| 174 | + | |
173 | 175 |
| |
174 | 176 |
| |
175 | 177 |
| |
| |||
183 | 185 |
| |
184 | 186 |
| |
185 | 187 |
| |
186 |
| - | |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 | 188 |
| |
191 | 189 |
| |
192 | 190 |
| |
193 | 191 |
| |
194 |
| - | |
| 192 | + | |
195 | 193 |
| |
| 194 | + | |
196 | 195 |
| |
197 | 196 |
| |
198 | 197 |
| |
| |||
215 | 214 |
| |
216 | 215 |
| |
217 | 216 |
| |
218 |
| - | |
219 |
| - | |
| 217 | + | |
| 218 | + | |
220 | 219 |
| |
221 | 220 |
| |
222 | 221 |
| |
223 | 222 |
| |
224 |
| - | |
| 223 | + | |
225 | 224 |
| |
226 | 225 |
| |
| 226 | + | |
227 | 227 |
| |
228 | 228 |
| |
229 | 229 |
| |
| |||
251 | 251 |
| |
252 | 252 |
| |
253 | 253 |
| |
254 |
| - | |
| 254 | + | |
| 255 | + | |
255 | 256 |
| |
256 |
| - | |
257 |
| - | |
258 |
| - | |
259 |
| - | |
260 |
| - | |
261 |
| - | |
| 257 | + | |
262 | 258 |
| |
263 | 259 |
| |
264 | 260 |
| |
|
Lines changed: 7 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
68 | 68 |
| |
69 | 69 |
| |
70 | 70 |
| |
71 |
| - | |
| 71 | + | |
| 72 | + | |
72 | 73 |
| |
73 | 74 |
| |
74 | 75 |
| |
| |||
311 | 312 |
| |
312 | 313 |
| |
313 | 314 |
| |
314 |
| - | |
| 315 | + | |
315 | 316 |
| |
316 | 317 |
| |
317 | 318 |
| |
| |||
334 | 335 |
| |
335 | 336 |
| |
336 | 337 |
| |
337 |
| - | |
| 338 | + | |
| 339 | + | |
338 | 340 |
| |
339 | 341 |
| |
340 | 342 |
| |
| |||
391 | 393 |
| |
392 | 394 |
| |
393 | 395 |
| |
394 |
| - | |
| 396 | + | |
| 397 | + | |
395 | 398 |
| |
396 | 399 |
| |
397 | 400 |
| |
|
0 commit comments
Comments
(0)