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: <9C204E93-5638-4272-A209-205A591D9FC7@vmware.com>
Date:   Thu, 11 Jul 2019 17:09:09 +0000
From:   Nadav Amit <namit@...are.com>
To:     Kees Cook <keescook@...omium.org>
CC:     Peter Zijlstra <peterz@...radead.org>,
        Jiri Kosina <jikos@...nel.org>,
        Xi Ruoyao <xry111@...gyan1223.wang>,
        Thomas Gleixner <tglx@...utronix.de>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>,
        Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
        Borislav Petkov <bp@...en8.de>, Len Brown <lenb@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Bob Moore <robert.moore@...el.com>,
        Erik Schmauss <erik.schmauss@...el.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Daniel Bristot de Oliveira <bristot@...hat.com>
Subject: Re: [GIT PULL] x86/topology changes for v5.3

> On Jul 11, 2019, at 8:08 AM, Kees Cook <keescook@...omium.org> wrote:
> 
> On Thu, Jul 11, 2019 at 10:01:34AM +0200, Peter Zijlstra wrote:
>> On Thu, Jul 11, 2019 at 07:11:19AM +0000, Nadav Amit wrote:
>>>> On Jul 10, 2019, at 7:22 AM, Jiri Kosina <jikos@...nel.org> wrote:
>>>> 
>>>> On Wed, 10 Jul 2019, Peter Zijlstra wrote:
>>>> 
>>>>> If we mark the key as RO after init, and then try and modify the key to
>>>>> link module usage sites, things might go bang as described.
>>>>> 
>>>>> Thanks!
>>>>> 
>>>>> 
>>>>> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
>>>>> index 27d7864e7252..5bf7a8354da2 100644
>>>>> --- a/arch/x86/kernel/cpu/common.c
>>>>> +++ b/arch/x86/kernel/cpu/common.c
>>>>> @@ -366,7 +366,7 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
>>>>> 	cr4_clear_bits(X86_CR4_UMIP);
>>>>> }
>>>>> 
>>>>> -DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
>>>>> +DEFINE_STATIC_KEY_FALSE(cr_pinning);
>>>> 
>>>> Good catch, I guess that is going to fix it.
>>>> 
>>>> At the same time though, it sort of destroys the original intent of Kees' 
>>>> patch, right? The exploits will just have to call static_key_disable() 
>>>> prior to calling native_write_cr4() again, and the protection is gone.
>>> 
>>> Even with DEFINE_STATIC_KEY_FALSE_RO(), I presume you can just call
>>> set_memory_rw(), make the page that holds the key writable, and then call
>>> static_key_disable(), followed by a call to native_write_cr4().
>> 
>> Or call text_poke_bp() with the right set of arguments.
> 
> Right -- the point is to make it defended against an arbitrary write,
> not arbitrary execution. Nothing is safe from arbitrary exec, but we can
> do our due diligence on making things read-only.

I don’t understand.

In the PoC that motivated this this patch [1], the attacker gained the
ability to call a function, control its first argument and used it to
disable SMEP/SMAP by calling native_write_cr4(), which he did before doing
an arbitrary write (another ability he gain).

After this patch, the attacker can instead call three functions, and by
controlling their first arguments (*) disable SMEP. I didn’t see something
in the motivating PoC that prevented calling 3 functions one at a time.

So it seems to me that it raised the bar for an attack by very little.

--

(*) set_memory_rw() has a second argument - the number of pages - but many
non-zero values may be fine (if not a warning from __cpa_process_fault()
might appear).

[1] https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ