Linux block layer
 help / color / mirror / Atom feed
* [PATCH] zloop: reject mismatched conventional zone files on restore
@ 2026-10-31 14:16 shao.mingyin
  2026-11-03  5:09 ` Damien Le Moal
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: shao.mingyin @ 2026-10-31 14:16 UTC (permalink / raw)
  To: dlemoal, hch, linux-block; +Cc: axboe, linux-kernel

From: Shao Mingyin <shao.mingyin@zte.com.cn>

When restoring a zloop device, zloop_init_zone() checks that the size of
each conventional zone file matches the configured zone size.  The check
prints an error and then jumps to out_fput, which releases the zone file
and returns the value left in "ret" by the preceding vfs_getattr() call,
that is, zero.  zloop_ctl_add() therefore treats the zone as initialized
and continues with a zone->file pointer that was already released; any
I/O to that zone then dereferences it.

Return -EINVAL, like the sequential zone path does for the same kind of
inconsistency.

While at it, print the zone size that is actually compared instead of the
zone capacity, which may be smaller and only made the message confusing.

Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---

diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 65634a39b0bf..fb541969a47c 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -1161,7 +1161,8 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,

 		if (restore && file_sectors != zlo->zone_size) {
 			pr_err("Invalid conventional zone %u file size (%llu sectors != %llu)\n",
-			       zone_no, file_sectors, zlo->zone_capacity);
+			       zone_no, file_sectors, zlo->zone_size);
+			ret = -EINVAL;
 			goto out_fput;
 		}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: reject mismatched conventional zone files on restore
  2026-10-31 14:16 [PATCH] zloop: reject mismatched conventional zone files on restore shao.mingyin
@ 2026-11-03  5:09 ` Damien Le Moal
  2026-11-03  5:30 ` Christoph Hellwig
  2026-11-03 14:31 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-11-03  5:09 UTC (permalink / raw)
  To: shao.mingyin, hch, linux-block; +Cc: axboe, linux-kernel

On 10/31/26 23:16, shao.mingyin@zte.com.cn wrote:
> From: Shao Mingyin <shao.mingyin@zte.com.cn>
> 
> When restoring a zloop device, zloop_init_zone() checks that the size of
> each conventional zone file matches the configured zone size.  The check
> prints an error and then jumps to out_fput, which releases the zone file
> and returns the value left in "ret" by the preceding vfs_getattr() call,
> that is, zero.  zloop_ctl_add() therefore treats the zone as initialized
> and continues with a zone->file pointer that was already released; any
> I/O to that zone then dereferences it.
> 
> Return -EINVAL, like the sequential zone path does for the same kind of
> inconsistency.
> 
> While at it, print the zone size that is actually compared instead of the
> zone capacity, which may be smaller and only made the message confusing.
> 
> Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>

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

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: reject mismatched conventional zone files on restore
  2026-10-31 14:16 [PATCH] zloop: reject mismatched conventional zone files on restore shao.mingyin
  2026-11-03  5:09 ` Damien Le Moal
@ 2026-11-03  5:30 ` Christoph Hellwig
  2026-11-03 14:31 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-11-03  5:30 UTC (permalink / raw)
  To: shao.mingyin; +Cc: dlemoal, hch, linux-block, axboe, linux-kernel

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: reject mismatched conventional zone files on restore
  2026-10-31 14:16 [PATCH] zloop: reject mismatched conventional zone files on restore shao.mingyin
  2026-11-03  5:09 ` Damien Le Moal
  2026-11-03  5:30 ` Christoph Hellwig
@ 2026-11-03 14:31 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-11-03 14:31 UTC (permalink / raw)
  To: dlemoal, hch, linux-block, shao.mingyin; +Cc: linux-kernel


On Sat, 31 Oct 2026 22:16:10 +0800, shao.mingyin@zte.com.cn wrote:
> When restoring a zloop device, zloop_init_zone() checks that the size of
> each conventional zone file matches the configured zone size.  The check
> prints an error and then jumps to out_fput, which releases the zone file
> and returns the value left in "ret" by the preceding vfs_getattr() call,
> that is, zero.  zloop_ctl_add() therefore treats the zone as initialized
> and continues with a zone->file pointer that was already released; any
> I/O to that zone then dereferences it.
> 
> [...]

Applied, thanks!

[1/1] zloop: reject mismatched conventional zone files on restore
      commit: 09c2e203e0ea8b68e7c9500401fa0ab60baf1a9d

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-03 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 14:16 [PATCH] zloop: reject mismatched conventional zone files on restore shao.mingyin
2026-11-03  5:09 ` Damien Le Moal
2026-11-03  5:30 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox