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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 13 Feb 2024 21:51:01 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Kees Cook <keescook@...omium.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Florian Weimer <fweimer@...hat.com>, linux-kernel@...r.kernel.org,
	linux-arch@...r.kernel.org, linux-api@...r.kernel.org,
	x86@...nel.org, Eric Biederman <ebiederm@...ssion.com>,
	linux-mm@...ck.org
Subject: Re: [PATCH v4] ELF: AT_PAGE_SHIFT_MASK -- supply userspace with
 available page shifts

On Fri, Feb 09, 2024 at 04:41:36PM -0800, Kees Cook wrote:
> On Fri, Feb 09, 2024 at 03:30:37PM +0300, Alexey Dobriyan wrote:
> > On Mon, Feb 05, 2024 at 04:48:08AM -0800, Kees Cook wrote:
> > > On Mon, Feb 05, 2024 at 12:51:43PM +0300, Alexey Dobriyan wrote:
> > > > +#define ARCH_AT_PAGE_SHIFT_MASK					\
> > > > +	do {							\
> > > > +		u32 val = 1 << 12;				\
> > > > +		if (boot_cpu_has(X86_FEATURE_PSE)) {		\
> > > > +			val |= 1 << 21;				\
> > > > +		}						\
> > > > +		if (boot_cpu_has(X86_FEATURE_GBPAGES)) {	\
> > > > +			val |= 1 << 30;				\
> > > > +		}						\
> > > 
> > > Can we use something besides literal "12", "21", and "30" values here?
> > 
> > Ehh, no, why? Inside x86_64 the page shifts are very specific numbers,
> > they won't change.
> 
> Well, it's nicer to have meaningful words to describe these things.

Not really. Inside specific arch page shifts are fixed, so using names
is just more macros one need to remember.

If I were to invent names (which I wouldn't), the best names are

	PAGE_SHIFT
	PAGE_SHIFT2
	PAGE_SHIFT3
	...

with PAGE_SHIFT2, PAGE_SHIFT3 being optional macros if arch doesn't support
multiple page sizes.

> In fact, PAGE_SHIFT already exists for 12, and HPAGE_SHIFT already exists
> for 21. Please use those, and add another, perhaps GBPAGE_SHIFT, for 30.

HPAGE_SHIFT is bad name, H doesn't describe anything unless arch is
known. Hugepages is marketing name. If GBPAGE_SHIFT is good name,
then HPAGE_SHIFT is bad name, it should've been MBPAGE_SHIFT, which
wrong because it is 2 MiB not 1 MiB.

BTW parisc has REAL_HPAGE_SHIFT !

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ