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: <017b01cbd62d$633fd070$29bf7150$@mprc.pku.edu.cn>
Date:	Sun, 27 Feb 2011 11:21:12 +0800
From:	"Guan Xuetao" <gxt@...c.pku.edu.cn>
To:	"'Arnd Bergmann'" <arnd@...db.de>
Cc:	<linux-kernel@...r.kernel.org>, <linux-arch@...r.kernel.org>,
	"'Greg KH'" <greg@...ah.com>
Subject: RE: [PATCH 05/12] unicore32 additional architecture files: low-level lib: uaccess



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@...db.de]
> Sent: Friday, February 18, 2011 1:45 AM
> To: Guan Xuetao
> Cc: linux-kernel@...r.kernel.org; linux-arch@...r.kernel.org; 'Greg KH'
> Subject: Re: [PATCH 05/12] unicore32 additional architecture files: low-level lib: uaccess
> 
> On Wednesday 16 February 2011, Guan Xuetao wrote:
> > +
> > +#define __kernel_ok		(segment_eq(get_fs(), KERNEL_DS))
> > +#define __user_ok(addr, size)	(((size) <= TASK_SIZE)			\
> > +				&& ((addr) <= TASK_SIZE - (size)))
> > +#define __access_ok(addr, size)	(__kernel_ok || __user_ok((addr), (size)))
> 
> A nice trick to simplify this is to introduce a per-process variable for comparing
> the pointer, set_fs() then sets this variable to either TASK_SIZE or
> UINT_MAX.

Perhaps like this:
1. add a member named kaddr in thread_info
2. add following assignment codes in set_fs:
        current_thread_info()->kaddr =  segment_eq(fs, KERNEL_DS) ? UINT_MAX : TASK_SIZE;
3. then __access_ok will be:
        #define addr 
        #define __access_ok(addr, size)   (((size) <= TASK_SIZE)			\
				&& ((addr) <= current_thread_info()->kaddr)  - (size)))

> 
> This saves one conditional branch for each call to __access_ok.
> 
> 	Arnd

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