public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Changhui Zhong <czhong@redhat.com>
Subject: Re: [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
Date: Thu, 25 Apr 2024 22:14:08 +1000	[thread overview]
Message-ID: <3e9c410c-3bf8-4a82-83e3-1268304744c3@kernel.org> (raw)
In-Reply-To: <e5fec079dfca448cc21c425cfa5d7b291f5faa67.1714046443.git.johannes.thumshirn@wdc.com>

On 2024/04/25 22:02, Johannes Thumshirn wrote:
> Changhui reported a kernel crash when running this simple shell
> reproducer:
>  # cd /sys/kernel/debug/block && find  . -type f   -exec grep -aH . {} \;
> 
> The above results in a NULL pointer dereference if a device does not have
> a zone_wplugs_hash allocated.
> 
> To fix this, return early if we don't have a zone_wplugs_hash.
> 
> Reported-by: Changhui Zhong <czhong@redhat.com>
> Fixes: a98b05b02f0f ("block: Replace zone_wlock debugfs entry with zone_wplugs entry")
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

My bad... Thanks for the fix.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

> ---
>  block/blk-zoned.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 3a796420f240..bad68277c0b2 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -1774,6 +1774,9 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
>  	unsigned int zwp_bio_list_size, i;
>  	unsigned long flags;
>  
> +	if (!disk->zone_wplugs_hash)
> +		return 0;
> +
>  	rcu_read_lock();
>  	for (i = 0; i < disk_zone_wplugs_hash_size(disk); i++) {
>  		hlist_for_each_entry_rcu(zwplug,

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2024-04-25 12:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 12:02 [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show Johannes Thumshirn
2024-04-25 12:14 ` Damien Le Moal [this message]
2024-04-25 13:48 ` Jens Axboe
2024-04-26  7:42 ` Changhui Zhong

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=3e9c410c-3bf8-4a82-83e3-1268304744c3@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=czhong@redhat.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-block@vger.kernel.org \
    /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