Commit eaf1120
rseq: Fix segfault on registration when rseq_cs is non-zero
commit fd881d0 upstream.
The rseq_cs field is documented as being set to 0 by user-space prior to
registration, however this is not currently enforced by the kernel. This
can result in a segfault on return to user-space if the value stored in
the rseq_cs field doesn't point to a valid struct rseq_cs.
The correct solution to this would be to fail the rseq registration when
the rseq_cs field is non-zero. However, some older versions of glibc
will reuse the rseq area of previous threads without clearing the
rseq_cs field and will also terminate the process if the rseq
registration fails in a secondary thread. This wasn't caught in testing
because in this case the leftover rseq_cs does point to a valid struct
rseq_cs.
What we can do is clear the rseq_cs field on registration when it's
non-zero which will prevent segfaults on registration and won't break
the glibc versions that reuse rseq areas on thread creation.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250306211223.109455-1-mjeanson@efficios.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent f02f021 commit eaf1120
1 file changed
Lines changed: 48 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
152 | 175 | | |
153 | 176 | | |
154 | 177 | | |
| |||
157 | 180 | | |
158 | 181 | | |
159 | 182 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
167 | 188 | | |
168 | 189 | | |
169 | 190 | | |
170 | 191 | | |
| 192 | + | |
171 | 193 | | |
172 | 194 | | |
173 | 195 | | |
| |||
243 | 265 | | |
244 | 266 | | |
245 | 267 | | |
246 | | - | |
| 268 | + | |
247 | 269 | | |
248 | 270 | | |
249 | 271 | | |
| |||
254 | 276 | | |
255 | 277 | | |
256 | 278 | | |
257 | | - | |
| 279 | + | |
258 | 280 | | |
259 | | - | |
| 281 | + | |
260 | 282 | | |
261 | 283 | | |
262 | 284 | | |
| |||
288 | 310 | | |
289 | 311 | | |
290 | 312 | | |
291 | | - | |
| 313 | + | |
292 | 314 | | |
293 | 315 | | |
294 | 316 | | |
295 | | - | |
| 317 | + | |
296 | 318 | | |
297 | 319 | | |
298 | 320 | | |
| |||
366 | 388 | | |
367 | 389 | | |
368 | 390 | | |
| 391 | + | |
369 | 392 | | |
370 | 393 | | |
371 | 394 | | |
| |||
420 | 443 | | |
421 | 444 | | |
422 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
423 | 459 | | |
424 | 460 | | |
425 | 461 | | |
| |||
0 commit comments