From: Benjamin Marzinski <bmarzins@redhat.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>,
Mike Snitzer <snitzer@redhat.com>,
dm-devel@lists.linux.dev, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v3 4/6] dm: fix dm_blk_report_zones
Date: Wed, 9 Apr 2025 10:55:19 -0400 [thread overview]
Message-ID: <Z_aKV4gM5HCMwXeU@redhat.com> (raw)
In-Reply-To: <c3e3521a-daf2-4856-9db5-e093a7e59be9@kernel.org>
On Wed, Apr 09, 2025 at 03:02:58PM +0900, Damien Le Moal wrote:
> On 4/9/25 8:51 AM, Benjamin Marzinski wrote:
> > If dm_get_live_table() returned NULL, dm_put_live_table() was never
> > called. Also, it is possible that md->zone_revalidate_map will change
> > while calling this function. Only read it once, so that we are always
> > using the same value. Otherwise we might miss a call to
> > dm_put_live_table().
> >
> > Finally, while md->zone_revalidate_map is set and a process is calling
> > blk_revalidate_disk_zones() to set up the zone append emulation
> > resources, it is possible that another process, perhaps triggered by
> > blkdev_report_zones_ioctl(), will call dm_blk_report_zones(). If
> > blk_revalidate_disk_zones() fails, these resources can be freed while
> > the other process is still using them, causing a use-after-free error.
> >
> > blk_revalidate_disk_zones() will only ever be called when initially
> > setting up the zone append emulation resources, such as when setting up
> > a zoned dm-crypt table for the first time. Further table swaps will not
> > set md->zone_revalidate_map or call blk_revalidate_disk_zones().
> > However it must be called using the new table (referenced by
> > md->zone_revalidate_map) and the new queue limits while the DM device is
> > suspended. dm_blk_report_zones() needs some way to distinguish between a
> > call from blk_revalidate_disk_zones(), which must be allowed to use
> > md->zone_revalidate_map to access this not yet activated table, and all
> > other calls to dm_blk_report_zones(), which should not be allowed while
> > the device is suspended and cannot use md->zone_revalidate_map, since
> > the zone resources might be freed by the process currently calling
> > blk_revalidate_disk_zones().
> >
> > Solve this by tracking the process that set md->zone_revalidate_map
> > dm_revalidate_zones() and only allowing that process to make use of it
> > in dm_blk_report_zones().
>
> ..that sets md->zone_revalidate_map in dm_revalidate_zones() and... ?
Yep. I'll fix that.
> >
> > Fixes: f211268ed1f9b ("dm: Use the block layer zone append emulation")
> > Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
>
> I do not recall reviewing this version, but looks OK to me with the sentence
> above fixed.
The code is the same as the original version that you reviewed, but I
forgot to remove your Reviewed-by when I rewrote the commit message.
Sorry.
-Ben
>
> > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
>
>
> --
> Damien Le Moal
> Western Digital Research
next prev parent reply other threads:[~2025-04-09 14:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 23:51 [PATCH v3 0/6] [PATCH v3 0/6] dm: fix issues with swapping dm tables Benjamin Marzinski
2025-04-08 23:51 ` [PATCH v3 1/6] dm: don't change md if dm_table_set_restrictions() fails Benjamin Marzinski
2025-04-08 23:51 ` [PATCH v3 2/6] dm: free table mempools if not used in __bind Benjamin Marzinski
2025-04-08 23:51 ` [PATCH v3 3/6] dm: handle failures in dm_table_set_restrictions Benjamin Marzinski
2025-04-09 5:57 ` Damien Le Moal
2025-04-08 23:51 ` [PATCH v3 4/6] dm: fix dm_blk_report_zones Benjamin Marzinski
2025-04-09 6:02 ` Damien Le Moal
2025-04-09 14:55 ` Benjamin Marzinski [this message]
2025-04-08 23:51 ` [PATCH v3 5/6] dm: limit swapping tables for devices with zone write plugs Benjamin Marzinski
2025-04-09 6:20 ` Damien Le Moal
2025-04-09 20:15 ` Benjamin Marzinski
2025-04-10 0:56 ` Damien Le Moal
2025-04-08 23:51 ` [PATCH v3 6/6] dm: fix native zone append devices on top of emulated ones Benjamin Marzinski
2025-04-09 6:21 ` Damien Le Moal
2025-04-09 6:24 ` [PATCH v3 0/6] [PATCH v3 0/6] dm: fix issues with swapping dm tables Damien Le Moal
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=Z_aKV4gM5HCMwXeU@redhat.com \
--to=bmarzins@redhat.com \
--cc=dlemoal@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=mpatocka@redhat.com \
--cc=snitzer@redhat.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.