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] [day] [month] [year] [list]
Message-ID: <4C240D61.4000006@austin.ibm.com>
Date:	Thu, 24 Jun 2010 20:58:57 -0500
From:	Nathan Fontenot <nfont@...tin.ibm.com>
To:	Cornelia Huck <cornelia.huck@...ibm.com>
CC:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Store sysfs dirent structs in rbtree

On 06/24/2010 01:04 PM, Cornelia Huck wrote:
> On Wed, 23 Jun 2010 21:56:04 -0500,
> Nathan Fontenot <nfont@...tin.ibm.com> wrote:
> 
>> +static void sysfs_dirent_insert(struct sysfs_dirent *sd)
>> +{
>> +	struct sysfs_dirent *parent_sd = sd->s_parent;
>> +	struct sysfs_dirent *d;
>> +	struct rb_node **p = &parent_sd->s_dir.rb_root.rb_node;
>> +	struct rb_node *parent = NULL;
>> +
>> +	while (*p) {
>> +		int cmp_val;
>> +		parent = *p;
>> +		d = to_sysfs_dirent(parent);
>> +
>> +		cmp_val = strcmp(d->s_name, sd->s_name);
>> +		if (cmp_val < 0)
>> +			p = &parent->rb_left;
>> +		if (cmp_val > 0)
>> +			p = &parent->rb_right;
>> +	}
>> +
>> +	rb_link_node(&sd->s_dir.rb_node, parent, p);
>> +	rb_insert_color(&sd->s_dir.rb_node, &parent_sd->s_dir.rb_root);
>> +}
> 
> This will run into trouble if you have duplicate names in different
> namespaces. You won't see it with your patch though, since...
> 
>> @@ -536,14 +572,24 @@
>>  				       const void *ns,
>>  				       const unsigned char *name)
>>  {
>> -	struct sysfs_dirent *sd;
>> -
>> -	for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
>> -		if (ns && sd->s_ns && (sd->s_ns != ns))
>> -			continue;
>> -		if (!strcmp(sd->s_name, name))
>> -			return sd;
>> +	struct sysfs_dirent *d;
>> +	struct rb_node **p = &parent_sd->s_dir.rb_root.rb_node;
>> +	struct rb_node *parent = NULL;
>> +
>> +	while (*p) {
>> +		int cmp_val;
>> +		parent = *p;
>> +		d = to_sysfs_dirent(parent);
>> +
>> +		cmp_val = strcmp(d->s_name, name);
>> +		if (cmp_val == 0)
>> +			return d;
>> +		else if (cmp_val < 0)
>> +			p = &parent->rb_left;
>> +		else /* (cmp_val > 0) */
>> +			p = &parent->rb_right;
>>  	}
>> +
>>  	return NULL;
>>  }
> 
> ...you removed the namespace check down here.

Yep, I missed namespaces completely with this patch.  I'll try again.

> --
> 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/

--
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