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: <20180110072900.GC14066@1wt.eu>
Date:   Wed, 10 Jan 2018 08:29:00 +0100
From:   Willy Tarreau <w@....eu>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     linux-kernel@...r.kernel.org, x86@...nel.org,
        Andy Lutomirski <luto@...nel.org>,
        Borislav Petkov <bp@...en8.de>,
        Brian Gerst <brgerst@...il.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, Kees Cook <keescook@...omium.org>
Subject: Re: [RFC PATCH v2 3/6] x86/pti: add a per-cpu variable pti_disable

On Wed, Jan 10, 2018 at 08:19:51AM +0100, Ingo Molnar wrote:
> 
> * Willy Tarreau <w@....eu> wrote:
> 
> > +#ifdef CONFIG_PAGE_TABLE_ISOLATION
> > +	this_cpu_write(pti_disable,
> > +		       next_p->mm && next_p->mm->context.pti_disable);
> > +#endif
> 
> Another pet peeve, please write:
> 
> > +	this_cpu_write(pti_disable, next_p->mm && next_p->mm->context.pti_disable);
> 
> or consider introducing an 'mm_next' local variable, set to next_p->mm, and use 
> that to shorten the sequence.

OK.

> More importantly, any strong reasons why the flag is logic-inverted? I.e. why not
> ::pti_enabled?

For me it's a matter of default case. Having a "pti_enabled" flag makes
one think the default is disabled and an action is required to turn it on.
With "pti_disabled", it becomes clearer that the default is enabled and an
action is required to turn it off. While it causes a double inversion for
the user due to the temporary choice of prctl name (we could have
ARCH_SET_PTI for example), I think it results on more readable code in
the sensitive parts like the asm one where these tests could possibly
end up inside #ifdefs. If we had "pit_enabled", something like this could
be confusing because it's not obvious whether this pti_enabled *enforces*
PTI or if its absence disables it :

#ifdef CONFIG_ALLOW_DISABLE_PTI
	cmpb $0, PER_CPU_VAR(pti_enabled)
	jz .Lend\@
#endif

But this is open to discussion of course.

Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ