lkml.org 
[lkml]   [2022]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] block: fix crash in 'blk_mq_elv_switch_none'
From
Date
ping...

On 2022/11/7 11:39, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> Syzbot found the following issue:
> general protection fault, probably for non-canonical address 0xdffffc000000001d: 0000 [#1] PREEMPT SMP KASAN
> KASAN: null-ptr-deref in range [0x00000000000000e8-0x00000000000000ef]
> CPU: 0 PID: 5234 Comm: syz-executor931 Not tainted 6.1.0-rc3-next-20221102-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
> RIP: 0010:__elevator_get block/elevator.h:94 [inline]
> RIP: 0010:blk_mq_elv_switch_none block/blk-mq.c:4593 [inline]
> RIP: 0010:__blk_mq_update_nr_hw_queues block/blk-mq.c:4658 [inline]
> RIP: 0010:blk_mq_update_nr_hw_queues+0x304/0xe40 block/blk-mq.c:4709
> RSP: 0018:ffffc90003cdfc08 EFLAGS: 00010206
> RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 0000000000000000
> RDX: 000000000000001d RSI: 0000000000000002 RDI: 00000000000000e8
> RBP: ffff88801dbd0000 R08: ffff888027c89398 R09: ffffffff8de2e517
> R10: fffffbfff1bc5ca2 R11: 0000000000000000 R12: ffffc90003cdfc70
> R13: ffff88801dbd0008 R14: ffff88801dbd03f8 R15: ffff888027c89380
> FS: 0000555557259300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000005d84c8 CR3: 000000007a7cb000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> nbd_start_device+0x153/0xc30 drivers/block/nbd.c:1355
> nbd_start_device_ioctl drivers/block/nbd.c:1405 [inline]
> __nbd_ioctl drivers/block/nbd.c:1481 [inline]
> nbd_ioctl+0x5a1/0xbd0 drivers/block/nbd.c:1521
> blkdev_ioctl+0x36e/0x800 block/ioctl.c:614
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:870 [inline]
> __se_sys_ioctl fs/ioctl.c:856 [inline]
> __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> As after dd6f7f17bf58 commit move '__elevator_get(qe->type)' before set
> 'qe->type', so will lead to access wild pointer.
> To solve above issue get 'qe->type' after set 'qe->type'.
>
> Reported-by: syzbot+746a4eece09f86bc39d7@syzkaller.appspotmail.com
> Fixes:dd6f7f17bf58("block: add proper helpers for elevator_type module refcount management")
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
> block/blk-mq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 2757368dc83f..3173d621f1f7 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4589,9 +4589,9 @@ static bool blk_mq_elv_switch_none(struct list_head *head,
>
> INIT_LIST_HEAD(&qe->node);
> qe->q = q;
> + qe->type = q->elevator->type;
> /* keep a reference to the elevator module as we'll switch back */
> __elevator_get(qe->type);
> - qe->type = q->elevator->type;
> list_add(&qe->node, head);
> elevator_disable(q);
> mutex_unlock(&q->sysfs_lock);

\
 
 \ /
  Last update: 2022-11-24 14:45    [W:3.278 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site