Commit 8c13a73
xhci: sideband: Fix race condition in sideband unregister
Uttkarsh Aggarwal observed a kernel panic during sideband un-register
and found it was caused by a race condition between sideband unregister,
and creating sideband interrupters.
The issue occurrs when thread T1 runs uaudio_disconnect() and released
sb->xhci via sideband_unregister, while thread T2 simultaneously accessed
the now-NULL sb->xhci in xhci_sideband_create_interrupter() resulting in
a crash.
Ensure new endpoints or interrupter can't be added to a sidenband after
xhci_sideband_unregister() cleared the existing ones, and unlocked the
sideband mutex.
Reorganize code so that mutex is only taken and released once in
xhci_sideband_unregister(), and clear sb->vdev while mutex is taken.
Use mutex guards to reduce human unlock errors in code
Refuse to add endpoints or interrupter if sb->vdev is not set.
sb->vdev is set when sideband is created and registered.
Reported-by: Uttkarsh Aggarwal <uttkarsh.aggarwal@oss.qualcomm.com>
Closes: https://lore.kernel.org/linux-usb/20251028080043.27760-1-uttkarsh.aggarwal@oss.qualcomm.com
Fixes: de66754 ("xhci: sideband: add initial api to register a secondary interrupter entity")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20251107162819.1362579-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent f6bb3b6 commit 8c13a73
1 file changed
Lines changed: 58 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
89 | 111 | | |
90 | 112 | | |
91 | 113 | | |
| |||
131 | 153 | | |
132 | 154 | | |
133 | 155 | | |
134 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
135 | 161 | | |
136 | 162 | | |
137 | 163 | | |
138 | | - | |
139 | | - | |
| 164 | + | |
140 | 165 | | |
141 | | - | |
142 | 166 | | |
143 | 167 | | |
144 | 168 | | |
| |||
148 | 172 | | |
149 | 173 | | |
150 | 174 | | |
151 | | - | |
152 | | - | |
| 175 | + | |
153 | 176 | | |
154 | | - | |
155 | 177 | | |
156 | 178 | | |
157 | 179 | | |
158 | | - | |
159 | 180 | | |
160 | 181 | | |
161 | 182 | | |
| |||
180 | 201 | | |
181 | 202 | | |
182 | 203 | | |
183 | | - | |
| 204 | + | |
| 205 | + | |
184 | 206 | | |
185 | 207 | | |
186 | 208 | | |
187 | | - | |
188 | | - | |
| 209 | + | |
189 | 210 | | |
190 | | - | |
191 | 211 | | |
192 | 212 | | |
193 | 213 | | |
194 | | - | |
195 | 214 | | |
196 | 215 | | |
197 | 216 | | |
| |||
316 | 335 | | |
317 | 336 | | |
318 | 337 | | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
324 | 345 | | |
325 | 346 | | |
326 | 347 | | |
327 | 348 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
| 349 | + | |
| 350 | + | |
332 | 351 | | |
333 | 352 | | |
334 | 353 | | |
335 | 354 | | |
336 | 355 | | |
337 | 356 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | 357 | | |
342 | 358 | | |
343 | 359 | | |
| |||
352 | 368 | | |
353 | 369 | | |
354 | 370 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 371 | + | |
358 | 372 | | |
359 | 373 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 374 | + | |
365 | 375 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 376 | + | |
370 | 377 | | |
371 | 378 | | |
372 | 379 | | |
| |||
465 | 472 | | |
466 | 473 | | |
467 | 474 | | |
| 475 | + | |
468 | 476 | | |
469 | 477 | | |
470 | 478 | | |
| |||
473 | 481 | | |
474 | 482 | | |
475 | 483 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
481 | 492 | | |
482 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
483 | 497 | | |
484 | 498 | | |
485 | 499 | | |
486 | | - | |
| 500 | + | |
487 | 501 | | |
488 | 502 | | |
489 | 503 | | |
| |||
0 commit comments