forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd053a87
committed
Fix timing-dependent failure in GSSAPI data transmission.
When using GSSAPI encryption in non-blocking mode, libpq sometimesfailed with "GSSAPI caller failed to retransmit all data needingto be retried". The cause is that pqPutMsgEnd rounds its transmitrequest down to an even multiple of 8K, and sometimes that can leadto not requesting a write of data that was requested to be written(but reported as not written) earlier. That can upset pg_GSS_write'slogic for dealing with not-yet-written data, since it's possiblethe data in question had already been incorporated into an encryptedpacket that we weren't able to send during the previous call.We could fix this with a one-or-two-line hack to disable pqPutMsgEnd'sround-down behavior, but that seems like making the caller work arounda behavior that pg_GSS_write shouldn't expose in this way. Instead,adjust pg_GSS_write to never report a partial write: it eitherreports a complete write, or reflects the failure of the lower-levelpqsecure_raw_write call. The requirement still exists for the callerto present at least as much data as on the previous call, but withthe caller-visible write start point not moving there is no temptationfor it to present less. We lose some ability to reclaim buffer spaceearly, but I doubt that that will make much difference in practice.This also gets rid of a rather dubious assumption that "anyinteresting failure condition (from pqsecure_raw_write) will recuron the next try". We've not seen failure reports traceable to that,but I've never trusted it particularly and am glad to remove it.Make the same adjustments to the equivalent backend routinebe_gssapi_write(). It is probable that there's no bug on the backendside, since we don't have a notion of nonblock mode there; but weshould keep the logic the same to ease future maintenance.Per bug #18210 from Lars Kanis. Back-patch to all supported branches.Discussion:https://postgr.es/m/18210-4c6d0b14627f2eb8@postgresql.org1 parent50c67c2 commitd053a87
File tree
3 files changed
+56
-60
lines changed- src
- backend/libpq
- interfaces/libpq
3 files changed
+56
-60
lines changedLines changed: 30 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
63 |
| - | |
64 |
| - | |
| 63 | + | |
| 64 | + | |
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
86 |
| - | |
87 |
| - | |
| 86 | + | |
| 87 | + | |
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| |||
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
101 |
| - | |
102 | 101 |
| |
103 | 102 |
| |
104 | 103 |
| |
105 | 104 |
| |
106 | 105 |
| |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
112 | 112 |
| |
113 | 113 |
| |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
114 | 120 |
| |
115 | 121 |
| |
116 | 122 |
| |
117 | 123 |
| |
118 | 124 |
| |
119 | 125 |
| |
120 | 126 |
| |
| 127 | + | |
121 | 128 |
| |
122 | 129 |
| |
123 | 130 |
| |
| |||
146 | 153 |
| |
147 | 154 |
| |
148 | 155 |
| |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 | 156 |
| |
159 |
| - | |
160 | 157 |
| |
161 | 158 |
| |
162 | 159 |
| |
163 | 160 |
| |
164 | 161 |
| |
165 |
| - | |
| 162 | + | |
166 | 163 |
| |
167 | 164 |
| |
168 | 165 |
| |
169 | 166 |
| |
170 | 167 |
| |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
| 168 | + | |
| 169 | + | |
176 | 170 |
| |
177 | 171 |
| |
178 | 172 |
| |
| |||
196 | 190 |
| |
197 | 191 |
| |
198 | 192 |
| |
199 |
| - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
200 | 197 |
| |
201 | 198 |
| |
202 | 199 |
| |
| |||
239 | 236 |
| |
240 | 237 |
| |
241 | 238 |
| |
242 |
| - | |
243 |
| - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
244 | 244 |
| |
245 |
| - | |
| 245 | + | |
246 | 246 |
| |
247 | 247 |
| |
248 | 248 |
| |
|
Lines changed: 24 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
82 |
| - | |
83 |
| - | |
| 82 | + | |
| 83 | + | |
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
93 |
| - | |
94 | 93 |
| |
95 | 94 |
| |
96 | 95 |
| |
97 | 96 |
| |
98 | 97 |
| |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
106 | 112 |
| |
107 | 113 |
| |
108 | 114 |
| |
| |||
140 | 146 |
| |
141 | 147 |
| |
142 | 148 |
| |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 | 149 |
| |
153 |
| - | |
154 | 150 |
| |
155 | 151 |
| |
156 | 152 |
| |
157 | 153 |
| |
158 | 154 |
| |
159 |
| - | |
| 155 | + | |
160 | 156 |
| |
161 | 157 |
| |
162 | 158 |
| |
163 | 159 |
| |
164 | 160 |
| |
165 |
| - | |
166 |
| - | |
167 |
| - | |
168 |
| - | |
169 |
| - | |
| 161 | + | |
| 162 | + | |
170 | 163 |
| |
171 | 164 |
| |
172 | 165 |
| |
| |||
192 | 185 |
| |
193 | 186 |
| |
194 | 187 |
| |
195 |
| - | |
| 188 | + | |
196 | 189 |
| |
197 | 190 |
| |
198 | 191 |
| |
| |||
236 | 229 |
| |
237 | 230 |
| |
238 | 231 |
| |
239 |
| - | |
240 |
| - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
241 | 237 |
| |
242 |
| - | |
| 238 | + | |
243 | 239 |
| |
244 | 240 |
| |
245 | 241 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
583 | 583 |
| |
584 | 584 |
| |
585 | 585 |
| |
586 |
| - | |
587 |
| - | |
| 586 | + | |
| 587 | + | |
588 | 588 |
| |
589 | 589 |
| |
590 | 590 |
| |
|
0 commit comments
Comments
(0)