* [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
@ 2024-04-25 12:02 Johannes Thumshirn
2024-04-25 12:14 ` Damien Le Moal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-04-25 12:02 UTC (permalink / raw)
To: axboe; +Cc: linux-block, Changhui Zhong, Damien Le Moal, Johannes Thumshirn
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>
---
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,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
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
2024-04-25 13:48 ` Jens Axboe
2024-04-26 7:42 ` Changhui Zhong
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2024-04-25 12:14 UTC (permalink / raw)
To: Johannes Thumshirn, axboe; +Cc: linux-block, Changhui Zhong
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
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
@ 2024-04-25 13:48 ` Jens Axboe
2024-04-26 7:42 ` Changhui Zhong
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2024-04-25 13:48 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-block, Changhui Zhong, Damien Le Moal
On Thu, 25 Apr 2024 05:02:39 -0700, 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.
>
> [...]
Applied, thanks!
[1/1] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
commit: 57787fa42f9fc12fe18938eefc2acb2dc2bde9ae
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
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
2024-04-25 13:48 ` Jens Axboe
@ 2024-04-26 7:42 ` Changhui Zhong
2 siblings, 0 replies; 4+ messages in thread
From: Changhui Zhong @ 2024-04-26 7:42 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: axboe, linux-block, Damien Le Moal
On Thu, Apr 25, 2024 at 8:02 PM Johannes Thumshirn
<johannes.thumshirn@wdc.com> 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>
> ---
> 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,
> --
> 2.43.0
>
>
Verified the panic issue was fixed by this patch,
Tested-by: Changhui Zhong <czhong@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-26 7:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2024-04-25 13:48 ` Jens Axboe
2024-04-26 7:42 ` Changhui Zhong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).