All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weiping Zhang <zwp10758@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Bart Van Assche <bvanassche@acm.org>,
	tom.leiming@gmail.com, linux-block@vger.kernel.org
Subject: Re: [PATCH] block: reset mapping if failed to update hardware queue count
Date: Wed, 13 May 2020 11:14:08 +0800	[thread overview]
Message-ID: <CAA70yB6SLv4g+Vihnf5M24J_ibTsEh5VLZzwoXJb0GZMhp+jZg@mail.gmail.com> (raw)
In-Reply-To: <585b0389-aa83-59b8-a155-f23621155bcd@kernel.dk>

On Wed, May 13, 2020 at 10:22 AM Jens Axboe <axboe@kernel.dk> wrote:
>
> On 5/12/20 6:44 PM, Weiping Zhang wrote:
> > When we increase hardware queue count, blk_mq_update_queue_map will
> > reset the mapping between cpu and hardware queue base on the hardware
> > queue count(set->nr_hw_queues). The mapping cannot be reset if it
> > encounters error in blk_mq_realloc_hw_ctxs, but the fallback flow will
> > continue using it, then blk_mq_map_swqueue will touch a invalid memory,
> > because the mapping points to a wrong hctx.
> >
> > blktest block/030:
> >
> > null_blk: module loaded
> > Increasing nr_hw_queues to 8 fails, fallback to 1
> > ==================================================================
> > BUG: KASAN: null-ptr-deref in blk_mq_map_swqueue+0x2f2/0x830
> > Read of size 8 at addr 0000000000000128 by task nproc/8541
> >
> > CPU: 5 PID: 8541 Comm: nproc Not tainted 5.7.0-rc4-dbg+ #3
> > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> > rel-1.13.0-0-gf21b5a4-rebuilt.opensuse.org 04/01/2014
> > Call Trace:
> > dump_stack+0xa5/0xe6
> > __kasan_report.cold+0x65/0xbb
> > kasan_report+0x45/0x60
> > check_memory_region+0x15e/0x1c0
> > __kasan_check_read+0x15/0x20
> > blk_mq_map_swqueue+0x2f2/0x830
> > __blk_mq_update_nr_hw_queues+0x3df/0x690
> > blk_mq_update_nr_hw_queues+0x32/0x50
> > nullb_device_submit_queues_store+0xde/0x160 [null_blk]
> > configfs_write_file+0x1c4/0x250 [configfs]
> > __vfs_write+0x4c/0x90
> > vfs_write+0x14b/0x2d0
> > ksys_write+0xdd/0x180
> > __x64_sys_write+0x47/0x50
> > do_syscall_64+0x6f/0x310
> > entry_SYSCALL_64_after_hwframe+0x49/0xb3
>
> Applied, thanks. Please do run blktests on your series in the future.
>
No problem, thanks a lot.
> --
> Jens Axboe
>

      reply	other threads:[~2020-05-13  3:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13  0:44 [PATCH] block: reset mapping if failed to update hardware queue count Weiping Zhang
2020-05-13  2:20 ` Jens Axboe
2020-05-13  3:14   ` Weiping Zhang [this message]

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=CAA70yB6SLv4g+Vihnf5M24J_ibTsEh5VLZzwoXJb0GZMhp+jZg@mail.gmail.com \
    --to=zwp10758@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=linux-block@vger.kernel.org \
    --cc=tom.leiming@gmail.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.