From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B1FE208A7; Sun, 1 Sep 2024 16:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725209843; cv=none; b=TjB5nrkD81BIpQRFk9OuPetrruFIl8XRPAbz/RNsymtZUZ6jHusxP8pLP5P3kZ1L1npMtTGdSC5tsikjpZMr/dzfH7mPg2mTQXZZhEjTN0Y3wYcmXvLbvi9TATHyqv3j4SxGl/8bawzksbIRCYCMUOmf4GcDatQAgow+00nTMik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725209843; c=relaxed/simple; bh=s497HjR8Z7sOMFLltS5+izsE4GK20G7VLoXjxx5HXvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TPauDxZFGBtIe1RcXb3TlPwx3/85XNCsOgwYxjUiJ+tXCqhdt4Q7yzVJV10isbm2p0KhUpbts7ML2Hz+ZxM5rG7Z70uDnX3AHvc1cpIZby2y4eDgybjhsjIELIYMFr82jr8wHLq4Rb9mSHCy1bfvPv5g56leRvnpShXWrLnSZ44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uWCg9OJn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uWCg9OJn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CFE1C4CEC3; Sun, 1 Sep 2024 16:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725209843; bh=s497HjR8Z7sOMFLltS5+izsE4GK20G7VLoXjxx5HXvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWCg9OJnVMzgY8VAKHozlBVMkJvyIcLMNyhzXeGUW7c0NX7nwQnsti4GTjkg0LGiZ sv7LgsAdZsdL3k6XI2RN5uWR0g5OGI0WZHz2iH4LlBcT58AQuyFPXN3DAy+oYqFMe7 2eSbSmEGECxsyLMuQK8RuKA43f+7E97IjiVrQtpU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikulas Patocka , Khazhismel Kumykov Subject: [PATCH 5.15 011/215] dm resume: dont return EINVAL when signalled Date: Sun, 1 Sep 2024 18:15:23 +0200 Message-ID: <20240901160823.671580902@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160823.230213148@linuxfoundation.org> References: <20240901160823.230213148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Khazhismel Kumykov commit 7a636b4f03af9d541205f69e373672e7b2b60a8a upstream. If the dm_resume method is called on a device that is not suspended, the method will suspend the device briefly, before resuming it (so that the table will be swapped). However, there was a bug that the return value of dm_suspended_md was not checked. dm_suspended_md may return an error when it is interrupted by a signal. In this case, do_resume would call dm_swap_table, which would return -EINVAL. This commit fixes the logic, so that error returned by dm_suspend is checked and the resume operation is undone. Signed-off-by: Mikulas Patocka Signed-off-by: Khazhismel Kumykov Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-ioctl.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1151,8 +1151,26 @@ static int do_resume(struct dm_ioctl *pa 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) { + down_write(&_hash_lock); + hc = dm_get_mdptr(md); + if (hc && !hc->new_map) { + hc->new_map = new_map; + new_map = NULL; + } else { + r = -ENXIO; + } + up_write(&_hash_lock); + if (new_map) { + 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);