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:	Sat, 16 Mar 2013 21:30:34 +0800
From:	Ming Lei <tom.leiming@...il.com>
To:	Hillf Danton <dhillf@...il.com>
Cc:	Sasha Levin <levinsasha928@...il.com>,
	Dave Jones <davej@...hat.com>,
	Greg Kroah-Hartman <greg@...ah.com>,
	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: use after free in sysfs_find_dirent

On Sat, Mar 16, 2013 at 8:39 PM, Hillf Danton <dhillf@...il.com> wrote:
> init rb node before use due to empty node checked by rb_next().
>
> --- a/fs/sysfs/dir.c    Sat Mar 16 20:12:16 2013
> +++ b/fs/sysfs/dir.c    Sat Mar 16 20:37:10 2013
> @@ -396,6 +396,7 @@ struct sysfs_dirent *sysfs_new_dirent(co
>
>         atomic_set(&sd->s_count, 1);
>         atomic_set(&sd->s_active, 0);
> +       rb_init_node(&sd->s_rb);

Looks there is no the symbol in linus tree, and not necessary since
rb_link_node() may initialize the node correctly.

Also I can't reproduce the problem on my Pandaboard with trinity, maybe
the below debug code can find the name of the affected node if anyone
would like to test it.

--
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 2fbdff6..9aa11c7 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -281,6 +281,10 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
 	 */
 	parent_sd = sd->s_parent;

+	if(!(sd->s_flags & SYSFS_FLAG_REMOVED))
+		printk("%s sysfs_dirent use after free: %s-%s\n",
+			__func__, parent_sd->s_name, sd->s_name);
+
 	if (sysfs_type(sd) == SYSFS_KOBJ_LINK)
 		sysfs_put(sd->s_symlink.target_sd);
 	if (sysfs_type(sd) & SYSFS_COPY_NAME)
@@ -962,6 +966,9 @@ static struct sysfs_dirent *sysfs_dir_pos(const void *ns,
 		int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) &&
 			pos->s_parent == parent_sd &&
 			hash == pos->s_hash;
+		if (valid && (atomic_read(&pos->s_count) <= 1))
+			printk("%s sysfs_dirent use after free: %s-%s\n",
+				__func__, parent_sd->s_name, pos->s_name);
 		sysfs_put(pos);
 		if (!valid)
 			pos = NULL;


Thanks,
-- 
Ming Lei
--
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