From: "yebin (H)" <yebin10@huawei.com>
To: Ye Bin <yebin@huaweicloud.com>, <axboe@kernel.dk>,
<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <ming.lei@redhat.com>,
<syzbot+746a4eece09f86bc39d7@syzkaller.appspotmail.com>
Subject: Re: [PATCH] block: fix crash in 'blk_mq_elv_switch_none'
Date: Thu, 24 Nov 2022 21:44:24 +0800 [thread overview]
Message-ID: <637F7538.1050002@huawei.com> (raw)
In-Reply-To: <20221107033956.3276891-1-yebin@huaweicloud.com>
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);
next prev parent reply other threads:[~2022-11-24 13:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 3:39 [PATCH] block: fix crash in 'blk_mq_elv_switch_none' Ye Bin
2022-11-07 6:19 ` Christoph Hellwig
2022-11-24 13:44 ` yebin (H) [this message]
2022-11-24 13:58 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=637F7538.1050002@huawei.com \
--to=yebin10@huawei.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=syzbot+746a4eece09f86bc39d7@syzkaller.appspotmail.com \
--cc=yebin@huaweicloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.