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]
Message-ID: <871ud8hdyu.fsf@xmission.com>
Date:	Fri, 25 Jan 2013 18:31:37 -0800
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Aristeu Rozanski <aris@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, "Serge E. Hallyn" <serge@...lyn.com>
Subject: Re: [PATCH v2] userns: improve uid/gid map collision detection

Aristeu Rozanski <aris@...hat.com> writes:

> On Thu, Jan 24, 2013 at 04:46:12PM -0800, Andrew Morton wrote:
>> eek, a macro!  Macros are always bad.
>> 
>> This one is bad because
>> 
>> a) it's a macro
>> 
>> b) it evaluates its args multiple times and hence will cause nasty
>>    bugs if called with expressions-with-side-effects.
>> 
>> c) it evaluates its args multiple times and if called with
>>    non-trivial expressions the compiler might not be able to CSE those
>>    expressions, leading to code bloat.
>> 
>> Add lo, this patch:
>> 
>> --- a/kernel/user_namespace.c~userns-improve-uid-gid-map-collision-detection-fix
>> +++ a/kernel/user_namespace.c
>> @@ -521,7 +521,11 @@ struct seq_operations proc_projid_seq_op
>>  
>>  static DEFINE_MUTEX(id_map_mutex);
>>  
>> -#define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len))
>> +static bool in_range(u32 b, u32 first, u32 len)
>> +{
>> +	return b >= first && b < first + len;
>> +}
>> +
>>  static inline int extent_collision(struct uid_gid_map *new_map,
>>  				   struct uid_gid_extent *extent)
>>  {
>> 
>> reduces the user_namespace.o text from 4822 bytes to 4727 with
>> gcc-4.4.4.  This is a remarkably large difference.
>
> thanks Andrew
>
> (I see Eric already answered about the config option)

Aritsteu after looking at both my version and yours I am going with
mine.  While my code is a little wordier I have half the number of
comparisons your code does, and I took the time to kill the variable
introducing a function to test for range collisions makes unnecessary.
On Andrews size metric my version seems noticably smaller as well.

 size $PWD-build/kernel/user_namespace.o
   text	   data	    bss	    dec	    hex	filename
   4376	    144	      0	   4520	   11a8	/home/eric/projects/linux/linux-userns-devel-build/kernel/user_namespace.o


Short of something unexpected I plan to push all my code to linux-next
sometime tomorrow.

Eric

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