From: Mike Snitzer <snitzer@kernel.org>
To: Khazhismel Kumykov <khazhy@chromium.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>,
Alasdair Kergon <agk@redhat.com>,
Zdenek Kabelac <zkabelac@redhat.com>,
Joe Thornber <thornber@redhat.com>,
Heinz Mauelshagen <heinzm@redhat.com>,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
Khazhismel Kumykov <khazhy@google.com>
Subject: Re: [RFC PATCH v2] dm ioctl: fix erroneous EINVAL when signaled
Date: Thu, 18 Jul 2024 10:25:58 -0400 [thread overview]
Message-ID: <Zpkl9v6aYqodp6bE@kernel.org> (raw)
In-Reply-To: <20240717231833.2090430-1-khazhy@google.com>
On Wed, Jul 17, 2024 at 04:18:33PM -0700, Khazhismel Kumykov wrote:
> do_resume when loading a new map first calls dm_suspend, which could
> silently fail. When we proceeded to dm_swap_table, we would bail out
> with EINVAL. Instead, attempt to restore new_map and return ERESTARTSYS
> when signaled.
>
> Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
> ---
> drivers/md/dm-ioctl.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> v2: don't leak new_map if we can't assign it back to hc.
>
> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> index c2c07bfa6471..0591455ad63c 100644
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -1181,8 +1181,27 @@ static int do_resume(struct dm_ioctl *param)
> suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
> if (param->flags & DM_NOFLUSH_FLAG)
> suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
> - if (!dm_suspended_md(md))
> - dm_suspend(md, suspend_flags);
> + if (!dm_suspended_md(md)) {
> + r = dm_suspend(md, suspend_flags);
> + if (r == -EINTR)
> + r = -ERESTARTSYS;
> + if (r) {
> + down_write(&_hash_lock);
> + hc = dm_get_mdptr(md);
> + if (!hc)
> + r = -ENXIO;
> + if (hc && !hc->new_map) {
> + hc->new_map = new_map;
> + up_write(&_hash_lock);
> + } else {
> + up_write(&_hash_lock);
> + dm_sync_table(md);
> + dm_table_destroy(new_map);
> + }
> + dm_put(md);
> + return r;
> + }
> + }
>
> old_size = dm_get_size(md);
> old_map = dm_swap_table(md, new_map);
> --
> 2.45.2.993.g49e7a77208-goog
>
>
Thanks for the patch. The header could use more context for how this
issue has caused problems in practice (you touched on that in reply to
Mikulas for v1).
But I will review this closely starting the week of July 29. This is
a very fundamental codepath for DM so needs extended review.
Mike
next prev parent reply other threads:[~2024-07-18 14:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-17 18:56 [RFC PATCH] dm ioctl: fix erroneous EINVAL when signaled Khazhismel Kumykov
2024-07-17 19:44 ` Mikulas Patocka
2024-07-17 19:52 ` Khazhy Kumykov
2024-07-17 23:18 ` [RFC PATCH v2] " Khazhismel Kumykov
2024-07-18 14:25 ` Mike Snitzer [this message]
2024-07-23 12:51 ` Mikulas Patocka
2024-07-23 13:11 ` Zdenek Kabelac
2024-07-23 17:17 ` Khazhy Kumykov
2024-07-22 9:52 ` [RFC PATCH] " Zdenek Kabelac
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=Zpkl9v6aYqodp6bE@kernel.org \
--to=snitzer@kernel.org \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=heinzm@redhat.com \
--cc=khazhy@chromium.org \
--cc=khazhy@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=thornber@redhat.com \
--cc=zkabelac@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox