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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250304122221.3317232-1-zxyan20@163.com>
Date: Tue,  4 Mar 2025 20:22:21 +0800
From: Zxyan Zhu <zxyan20@....com>
To: broonie@...nel.org
Cc: gregkh@...uxfoundation.org,
	rafael@...nel.org,
	dakr@...nel.org,
	linux-kernel@...r.kernel.org,
	Zxyan Zhu <zxyan20@....com>
Subject: [PATCH] regmap: debugfs: Fix name collision without atomic operations

A global variable caused debugfs name conflicts during re-entry,
leading to creation failures. Use atomic operations to ensure safe
and unique naming.

Signed-off-by: Zxyan Zhu <zxyan20@....com>
---
 drivers/base/regmap/regmap-debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fb84cda92a75..914fc032861d 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -20,7 +20,7 @@ struct regmap_debugfs_node {
 	struct list_head link;
 };
 
-static unsigned int dummy_index;
+static atomic_t dummy_index = ATOMIC_INIT(0);
 static struct dentry *regmap_debugfs_root;
 static LIST_HEAD(regmap_debugfs_early_list);
 static DEFINE_MUTEX(regmap_debugfs_early_lock);
@@ -596,11 +596,11 @@ void regmap_debugfs_init(struct regmap *map)
 	if (!strcmp(name, "dummy")) {
 		kfree(map->debugfs_name);
 		map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
-						dummy_index);
+						atomic_read(&dummy_index));
 		if (!map->debugfs_name)
 			return;
 		name = map->debugfs_name;
-		dummy_index++;
+		atomic_inc(&dummy_index);
 	}
 
 	map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ