mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Sang <oliver.sang@intel.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: <oe-lkp@lists.linux.dev>, <lkp@intel.com>,
	<linux-kernel@vger.kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Peter Newman <peternewman@google.com>,
	Babu Moger <babu.moger@amd.com>, Luck Tony <tony.luck@intel.com>,
	<linux-block@vger.kernel.org>, <oliver.sang@intel.com>
Subject: Re: [linus:master] [blk]  22465bbac5: BUG:KASAN:slab-use-after-free_in__cpuhp_state_add_instance_cpuslocked
Date: Wed, 18 Dec 2024 16:45:11 +0800	[thread overview]
Message-ID: <Z2KLl/lYpQsTPNpB@xsang-OptiPlex-9020> (raw)
In-Reply-To: <Z2Is2Ee8Me8qRPR-@fedora>

hi, Ming,

On Wed, Dec 18, 2024 at 10:00:56AM +0800, Ming Lei wrote:
> On Tue, Dec 17, 2024 at 10:20:47PM +0800, kernel test robot wrote:
> > 
> > 
> > Hello,
> > 
> > kernel test robot noticed "BUG:KASAN:slab-use-after-free_in__cpuhp_state_add_instance_cpuslocked" on:
> > 
> > commit: 22465bbac53c821319089016f268a2437de9b00a ("blk-mq: move cpuhp callback registering out of q->sysfs_lock")
> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
> > 
> > [test failed on linus/master      231825b2e1ff6ba799c5eaf396d3ab2354e37c6b]
> > [test failed on linux-next/master 3e42dc9229c5950e84b1ed705f94ed75ed208228]
> > 
> > in testcase: blktests
> > version: blktests-x86_64-3617edd-1_20241105
> > with following parameters:
> > 
> > 	disk: 1SSD
> > 	test: block-group-01
> > 
> > 
> > 
> > config: x86_64-rhel-9.4-func
> > compiler: gcc-12
> > test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory
> > 
> > (please refer to attached dmesg/kmsg for entire log/backtrace)
> > 
> > 
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <oliver.sang@intel.com>
> > | Closes: https://lore.kernel.org/oe-lkp/202412172217.b906db7c-lkp@intel.com
> > 
> > 
> > [ 232.596698][ T3545] BUG: KASAN: slab-use-after-free in __cpuhp_state_add_instance_cpuslocked (include/linux/list.h:1026 kernel/cpu.c:2446)
> 
> Hello,
> 
> Thanks for the report!
> 
> Unfortunately I can't reproduce it in my test VM by running
> 'blktests block/030' with:
> 
> - two numa nodes
> - enable CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION
> 
> 
> But just figured out that one freed hctx still may stay in cpuhp cb list, can
> you test the following patch?

yes, your patch fixed the issue we reported, and 'blktests block/030' can pass
now. thanks!

Tested-by: kernel test robot <oliver.sang@intel.com>

BTW, the config built with the patch is same as for 22465bbac5 when we made
original report, so still with CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION.

> 
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 92e8ddf34575..f655b34efffe 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4421,7 +4421,8 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
>  	/* reuse dead hctx first */
>  	spin_lock(&q->unused_hctx_lock);
>  	list_for_each_entry(tmp, &q->unused_hctx_list, hctx_list) {
> -		if (tmp->numa_node == node) {
> +		if (tmp->numa_node == node &&
> +				hlist_unhashed(&tmp->cpuhp_online)) {
>  			hctx = tmp;
>  			break;
>  		}
> 
> 
> thanks,
> Ming
> 

      reply	other threads:[~2024-12-18  8:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17 14:20 kernel test robot
2024-12-18  2:00 ` Ming Lei
2024-12-18  8:45   ` Oliver Sang [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=Z2KLl/lYpQsTPNpB@xsang-OptiPlex-9020 \
    --to=oliver.sang@intel.com \
    --cc=axboe@kernel.dk \
    --cc=babu.moger@amd.com \
    --cc=fenghua.yu@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=ming.lei@redhat.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=peternewman@google.com \
    --cc=reinette.chatre@intel.com \
    --cc=tony.luck@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®