Commit 209fd72
vsock: Fix transport_{g2h,h2g} TOCTOU
vsock_find_cid() and vsock_dev_do_ioctl() may race with module unload.
transport_{g2h,h2g} may become NULL after the NULL check.
Introduce vsock_transport_local_cid() to protect from a potential
null-ptr-deref.
KASAN: null-ptr-deref in range [0x0000000000000118-0x000000000000011f]
RIP: 0010:vsock_find_cid+0x47/0x90
Call Trace:
__vsock_bind+0x4b2/0x720
vsock_bind+0x90/0xe0
__sys_bind+0x14d/0x1e0
__x64_sys_bind+0x6e/0xc0
do_syscall_64+0x92/0x1c0
entry_SYSCALL_64_after_hwframe+0x4b/0x53
KASAN: null-ptr-deref in range [0x0000000000000118-0x000000000000011f]
RIP: 0010:vsock_dev_do_ioctl.isra.0+0x58/0xf0
Call Trace:
__x64_sys_ioctl+0x12d/0x190
do_syscall_64+0x92/0x1c0
entry_SYSCALL_64_after_hwframe+0x4b/0x53
Fixes: c0cfa2d ("vsock: add multi-transports support")
Suggested-by: Stefano Garzarella <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Michal Luczaj <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>1 parent 95a234f commit 209fd72
1 file changed
+21
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
534 | 550 | | |
535 | 551 | | |
536 | | - | |
| 552 | + | |
537 | 553 | | |
538 | 554 | | |
539 | 555 | | |
| |||
2536 | 2552 | | |
2537 | 2553 | | |
2538 | 2554 | | |
2539 | | - | |
2540 | 2555 | | |
| 2556 | + | |
2541 | 2557 | | |
2542 | 2558 | | |
2543 | 2559 | | |
2544 | 2560 | | |
2545 | 2561 | | |
2546 | 2562 | | |
2547 | | - | |
2548 | | - | |
2549 | | - | |
2550 | | - | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
2551 | 2566 | | |
2552 | 2567 | | |
2553 | 2568 | | |
| |||
0 commit comments