Commit 0c9e8b3
usbip: usbip_host: fix BUG: sleeping function called from invalid context
stub_probe() and stub_disconnect() call functions which could call
sleeping function in invalid context whil holding busid_lock.
Fix the problem by refining the lock holds to short critical sections
to change the busid_priv fields. This fix restructures the code to
limit the lock holds in stub_probe() and stub_disconnect().
stub_probe():
[15217.927028] BUG: sleeping function called from invalid context at mm/slab.h:418
[15217.927038] in_atomic(): 1, irqs_disabled(): 0, pid: 29087, name: usbip
[15217.927044] 5 locks held by usbip/29087:
[15217.927047] #0: 0000000091647f28 (sb_writers#6){....}, at: vfs_write+0x191/0x1c0
[15217.927062] #1: 000000008f9ba75b (&of->mutex){....}, at: kernfs_fop_write+0xf7/0x1b0
[15217.927072] #2: 00000000872e5b4b (&dev->mutex){....}, at: __device_driver_lock+0x3b/0x50
[15217.927082] #3: 00000000e74ececc (&dev->mutex){....}, at: __device_driver_lock+0x46/0x50
[15217.927090] #4: 00000000b20abbe0 (&(&busid_table[i].busid_lock)->rlock){....}, at: get_busid_priv+0x48/0x60 [usbip_host]
[15217.927103] CPU: 3 PID: 29087 Comm: usbip Tainted: G W 5.1.0-rc6+ #40
[15217.927106] Hardware name: Dell Inc. OptiPlex 790/0HY9JP, BIOS A18 09/24/2013
[15217.927109] Call Trace:
[15217.927118] dump_stack+0x63/0x85
[15217.927127] ___might_sleep+0xff/0x120
[15217.927133] __might_sleep+0x4a/0x80
[15217.927143] kmem_cache_alloc_trace+0x1aa/0x210
[15217.927156] stub_probe+0xe8/0x440 [usbip_host]
[15217.927171] usb_probe_device+0x34/0x70
stub_disconnect():
[15279.182478] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:908
[15279.182487] in_atomic(): 1, irqs_disabled(): 0, pid: 29114, name: usbip
[15279.182492] 5 locks held by usbip/29114:
[15279.182494] #0: 0000000091647f28 (sb_writers#6){....}, at: vfs_write+0x191/0x1c0
[15279.182506] #1: 00000000702cf0f3 (&of->mutex){....}, at: kernfs_fop_write+0xf7/0x1b0
[15279.182514] #2: 00000000872e5b4b (&dev->mutex){....}, at: __device_driver_lock+0x3b/0x50
[15279.182522] #3: 00000000e74ececc (&dev->mutex){....}, at: __device_driver_lock+0x46/0x50
[15279.182529] #4: 00000000b20abbe0 (&(&busid_table[i].busid_lock)->rlock){....}, at: get_busid_priv+0x48/0x60 [usbip_host]
[15279.182541] CPU: 0 PID: 29114 Comm: usbip Tainted: G W 5.1.0-rc6+ #40
[15279.182543] Hardware name: Dell Inc. OptiPlex 790/0HY9JP, BIOS A18 09/24/2013
[15279.182546] Call Trace:
[15279.182554] dump_stack+0x63/0x85
[15279.182561] ___might_sleep+0xff/0x120
[15279.182566] __might_sleep+0x4a/0x80
[15279.182574] __mutex_lock+0x55/0x950
[15279.182582] ? get_busid_priv+0x48/0x60 [usbip_host]
[15279.182587] ? reacquire_held_locks+0xec/0x1a0
[15279.182591] ? get_busid_priv+0x48/0x60 [usbip_host]
[15279.182597] ? find_held_lock+0x94/0xa0
[15279.182609] mutex_lock_nested+0x1b/0x20
[15279.182614] ? mutex_lock_nested+0x1b/0x20
[15279.182618] kernfs_remove_by_name_ns+0x2a/0x90
[15279.182625] sysfs_remove_file_ns+0x15/0x20
[15279.182629] device_remove_file+0x19/0x20
[15279.182634] stub_disconnect+0x6d/0x180 [usbip_host]
[15279.182643] usb_unbind_device+0x27/0x60
Signed-off-by: Shuah Khan <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 9a5729f commit 0c9e8b3
1 file changed
+43
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
307 | 315 | | |
308 | 316 | | |
309 | 317 | | |
| |||
318 | 326 | | |
319 | 327 | | |
320 | 328 | | |
321 | | - | |
| 329 | + | |
322 | 330 | | |
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
326 | 334 | | |
327 | 335 | | |
328 | | - | |
| 336 | + | |
329 | 337 | | |
330 | 338 | | |
331 | 339 | | |
| |||
334 | 342 | | |
335 | 343 | | |
336 | 344 | | |
337 | | - | |
| 345 | + | |
338 | 346 | | |
339 | 347 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
| |||
352 | 354 | | |
353 | 355 | | |
354 | 356 | | |
| 357 | + | |
355 | 358 | | |
356 | 359 | | |
357 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
| |||
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
370 | 379 | | |
371 | 380 | | |
372 | 381 | | |
373 | 382 | | |
374 | 383 | | |
375 | | - | |
376 | 384 | | |
377 | | - | |
378 | | - | |
| 385 | + | |
379 | 386 | | |
380 | 387 | | |
381 | 388 | | |
| |||
384 | 391 | | |
385 | 392 | | |
386 | 393 | | |
| 394 | + | |
| 395 | + | |
387 | 396 | | |
| 397 | + | |
| 398 | + | |
388 | 399 | | |
389 | | - | |
390 | | - | |
| 400 | + | |
391 | 401 | | |
| 402 | + | |
392 | 403 | | |
393 | 404 | | |
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
397 | | - | |
398 | | - | |
399 | | - | |
| 408 | + | |
400 | 409 | | |
401 | | - | |
402 | | - | |
403 | | - | |
| 410 | + | |
| 411 | + | |
404 | 412 | | |
405 | 413 | | |
406 | 414 | | |
| |||
432 | 440 | | |
433 | 441 | | |
434 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
435 | 446 | | |
436 | 447 | | |
437 | 448 | | |
| |||
442 | 453 | | |
443 | 454 | | |
444 | 455 | | |
445 | | - | |
| 456 | + | |
446 | 457 | | |
447 | 458 | | |
448 | 459 | | |
449 | 460 | | |
450 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
451 | 469 | | |
452 | 470 | | |
453 | 471 | | |
454 | 472 | | |
455 | 473 | | |
456 | 474 | | |
| 475 | + | |
| 476 | + | |
457 | 477 | | |
458 | 478 | | |
459 | 479 | | |
| |||
462 | 482 | | |
463 | 483 | | |
464 | 484 | | |
| 485 | + | |
465 | 486 | | |
466 | 487 | | |
467 | 488 | | |
| |||
0 commit comments