lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230601061423.3594104-1-lilingfeng3@huawei.com>
Date:   Thu, 1 Jun 2023 14:14:23 +0800
From:   Li Lingfeng <lilingfeng3@...wei.com>
To:     <dm-devel@...hat.com>
CC:     <agk@...hat.com>, <snitzer@...nel.org>,
        <linux-kernel@...r.kernel.org>, <houtao1@...wei.com>,
        <yi.zhang@...wei.com>, <yukuai3@...wei.com>,
        <lilingfeng3@...wei.com>
Subject: [PATCH] dm: don't lock fs when the map is NULL in process of suspend

As described in commit 38d11da522aa ("dm: don't lock fs when the map is
NULL in process of resume"), deadlock may be triggered between do_resume
and do_mount.
What's more, do_suspend and do_mount can also trigger it.
So clear DM_SUSPEND_LOCKFS_FLAG in dm_suspend instead of do_resume.

Signed-off-by: Li Lingfeng <lilingfeng3@...wei.com>
---
 drivers/md/dm-ioctl.c | 5 +----
 drivers/md/dm.c       | 3 +++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index cc77cf3d4109..7d5c9c582ed2 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1168,13 +1168,10 @@ static int do_resume(struct dm_ioctl *param)
 	/* Do we need to load a new map ? */
 	if (new_map) {
 		sector_t old_size, new_size;
-		int srcu_idx;
 
 		/* Suspend if it isn't already suspended */
-		old_map = dm_get_live_table(md, &srcu_idx);
-		if ((param->flags & DM_SKIP_LOCKFS_FLAG) || !old_map)
+		if (param->flags & DM_SKIP_LOCKFS_FLAG)
 			suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
-		dm_put_live_table(md, srcu_idx);
 		if (param->flags & DM_NOFLUSH_FLAG)
 			suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
 		if (!dm_suspended_md(md))
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 3b694ba3a106..39424a0b3cd6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2809,6 +2809,9 @@ int dm_suspend(struct mapped_device *md, unsigned int suspend_flags)
 
 	map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));
 
+	if (!map)
+		suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
+
 	r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED);
 	if (r)
 		goto out_unlock;
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ