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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 19 May 2015 16:15:48 +0100
From:	Richard Watts <rrw@...esim.co.uk>
To:	linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org
Subject: [PATCH 003/003] Attempt to cope with device changes and delayed kobject
 deallocation

Avoid issuing duplicate name errors when a kobject's sysfs directory is
scheduled for deletion but has not yet been deleted, and a directory
  with the same name is created.

Signed-off-by: Richard Watts <rrw@...esim.co.uk>
---
  fs/sysfs/dir.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 0b45ff4..e85de14 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -49,6 +49,21 @@ int sysfs_create_dir_ns(struct kobject *kobj, const 
void *ns)
  	else
  		parent = sysfs_root_kn;

+	kn = kernfs_find_and_get_ns(parent, kobject_name(kobj),
+				ns);
+	/* This check is non-atomic, but that is OK - the worst thing
+	 *  that can happen is a concurrent removal of the sysfs dir,
+	 *  which is exactly what we want anyway.
+	 */
+	if (kn) {
+		struct kobject *kobj_exist = (struct kobject *)kn->priv;
+
+		if (kobject_get_unless_zero(kobj_exist))
+			kobject_put(kobj_exist);
+		else
+			sysfs_remove_dir(kobj_exist);
+	}
+
  	if (!parent)
  		return -ENOENT;

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ