All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Mazur <krzysiek@podlesie.net>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	Dave Hansen <dave.hansen@intel.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Juergen Gross <jgross@suse.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>, Jiri Kosina <jkosina@suse.cz>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Brian Gerst <brgerst@gmail.com>,
	David Laight <David.Laight@aculab.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Eduardo Valentin <eduval@amazon.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Will Deacon <will.deacon@arm.com>,
	aliguori@amazon.com, daniel.gruss@iaik.tugraz.at,
	hughd@google.com, keescook@google.com,
	Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [RFC PATCH 00/16] PTI support for x86-32
Date: Fri, 26 Jan 2018 10:28:36 +0100	[thread overview]
Message-ID: <20180126092836.GA11003@shrek.podlesie.net> (raw)
In-Reply-To: <67E8EB67-EB60-441E-BDFB-521F3D431400@gmail.com>

On Thu, Jan 25, 2018 at 02:09:40PM -0800, Nadav Amit wrote:
> The PoC apparently does not work with 3GB of memory or more on 32-bit. Does
> you setup has more? Can you try the attack while setting max_addr=1G ?

No, I tested on:

Pentium M (Dothan): 1.5 GB RAM, PAE for NX, 2GB/2GB split

CONFIG_NOHIGHMEM=y
CONFIG_VMSPLIT_2G=y
CONFIG_PAGE_OFFSET=0x80000000
CONFIG_X86_PAE=y

and

Xeon (Pentium 4): 2 GB RAM, no PAE, 1.75GB/2.25GB split
CONFIG_NOHIGHMEM=y
CONFIG_VMSPLIT_2G_OPT=y
CONFIG_PAGE_OFFSET=0x78000000


Now I'm testing with standard settings on
Pentium M: 1.5 GB RAM, no PAE, 3GB/1GB split, ~890 MB RAM available

CONFIG_NOHIGHMEM=y
CONFIG_PAGE_OFFSET=0xc0000000
CONFIG_X86_PAE=n

and it still does not work.

reliability from https://github.com/IAIK/meltdown reports 0.38%
(1/256 = 0.39%, "true" random), and other libkdump tools does not work.

https://github.com/paboldin/meltdown-exploit (on linux_proc_banner
symbol) reports:
cached = 46, uncached = 515, threshold 153
read c0897020 = ff   (score=0/1000)
read c0897021 = ff   (score=0/1000)
read c0897022 = ff   (score=0/1000)
read c0897023 = ff   (score=0/1000)
read c0897024 = ff   (score=0/1000)
NOT VULNERABLE

and my exploit with:

	for (i = 0; i < 256; i++) {
		unsigned char *px = p + (i << 12);

		t = rdtsc();
		readb(px);
		t = rdtsc() - t;
		if (t < 100)
			printf("%02x %lld\n", i, t);
	}

loop returns only "00 45". When I change the exploit code (now based
on paboldin code to be sure) to:

	movzx (%[addr]), %%eax
	movl $0xaa, %%eax
	shl $12, %%eax
	movzx (%[target], %%eax), %%eax

I always get "0xaa 51", so the CPU is speculatively executing the second
load with (0xaa << 12) in eax, and without the movl instruction, eax seems
to be always 0. I even tried to remove the shift:

	movzx (%[addr]), %%eax
	movzx (%[target], %%eax), %%eax

and I've been reading known value (from /dev/mem, for instance 0x20),
I've modified target array offset, and the CPU is still touching "wrong"
cacheline, eax == 0 instead of 0x20. I've also tested movl instead
of movzx (with and 0xff).


On Core 2 Quad in 64-bit mode everything works as expected, vulnerable
to Meltdown (I did not test it in 32-bit mode). I don't have any Core
"1" to test.

On that Pentium M syscall slowdown caused by PTI is huge, 7.5 times slower
(7 times compared to patched kernel with disabled PTI), on Skylake with
PCID the same trivial benchmark is "only" 3.5 times slower (and 5.2
times slower without PCID).

Krzysiek

WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Mazur <krzysiek@podlesie.net>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	Dave Hansen <dave.hansen@intel.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Juergen Gross <jgross@suse.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>, Jiri Kosina <jkosina@suse.cz>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Brian Gerst <brgerst@gmail.com>,
	David Laight <David.Laight@aculab.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Eduardo Valentin <eduval@amazon.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Will Deacon <will.deacon@arm.com>,
	aliguori@amazon.com, daniel.gruss@iaik.tugraz.at,
	hughd@google.com, keescook@google.com,
	Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [RFC PATCH 00/16] PTI support for x86-32
Date: Fri, 26 Jan 2018 10:28:36 +0100	[thread overview]
Message-ID: <20180126092836.GA11003@shrek.podlesie.net> (raw)
In-Reply-To: <67E8EB67-EB60-441E-BDFB-521F3D431400@gmail.com>

On Thu, Jan 25, 2018 at 02:09:40PM -0800, Nadav Amit wrote:
> The PoC apparently does not work with 3GB of memory or more on 32-bit. Does
> you setup has more? Can you try the attack while setting max_addr=1G ?

No, I tested on:

Pentium M (Dothan): 1.5 GB RAM, PAE for NX, 2GB/2GB split

CONFIG_NOHIGHMEM=y
CONFIG_VMSPLIT_2G=y
CONFIG_PAGE_OFFSET=0x80000000
CONFIG_X86_PAE=y

and

Xeon (Pentium 4): 2 GB RAM, no PAE, 1.75GB/2.25GB split
CONFIG_NOHIGHMEM=y
CONFIG_VMSPLIT_2G_OPT=y
CONFIG_PAGE_OFFSET=0x78000000


Now I'm testing with standard settings on
Pentium M: 1.5 GB RAM, no PAE, 3GB/1GB split, ~890 MB RAM available

CONFIG_NOHIGHMEM=y
CONFIG_PAGE_OFFSET=0xc0000000
CONFIG_X86_PAE=n

and it still does not work.

reliability from https://github.com/IAIK/meltdown reports 0.38%
(1/256 = 0.39%, "true" random), and other libkdump tools does not work.

https://github.com/paboldin/meltdown-exploit (on linux_proc_banner
symbol) reports:
cached = 46, uncached = 515, threshold 153
read c0897020 = ff   (score=0/1000)
read c0897021 = ff   (score=0/1000)
read c0897022 = ff   (score=0/1000)
read c0897023 = ff   (score=0/1000)
read c0897024 = ff   (score=0/1000)
NOT VULNERABLE

and my exploit with:

	for (i = 0; i < 256; i++) {
		unsigned char *px = p + (i << 12);

		t = rdtsc();
		readb(px);
		t = rdtsc() - t;
		if (t < 100)
			printf("%02x %lld\n", i, t);
	}

loop returns only "00 45". When I change the exploit code (now based
on paboldin code to be sure) to:

	movzx (%[addr]), %%eax
	movl $0xaa, %%eax
	shl $12, %%eax
	movzx (%[target], %%eax), %%eax

I always get "0xaa 51", so the CPU is speculatively executing the second
load with (0xaa << 12) in eax, and without the movl instruction, eax seems
to be always 0. I even tried to remove the shift:

	movzx (%[addr]), %%eax
	movzx (%[target], %%eax), %%eax

and I've been reading known value (from /dev/mem, for instance 0x20),
I've modified target array offset, and the CPU is still touching "wrong"
cacheline, eax == 0 instead of 0x20. I've also tested movl instead
of movzx (with and 0xff).


On Core 2 Quad in 64-bit mode everything works as expected, vulnerable
to Meltdown (I did not test it in 32-bit mode). I don't have any Core
"1" to test.

On that Pentium M syscall slowdown caused by PTI is huge, 7.5 times slower
(7 times compared to patched kernel with disabled PTI), on Skylake with
PCID the same trivial benchmark is "only" 3.5 times slower (and 5.2
times slower without PCID).

Krzysiek

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2018-01-26  9:28 UTC|newest]

Thread overview: 183+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 16:36 [RFC PATCH 00/16] PTI support for x86-32 Joerg Roedel
2018-01-16 16:36 ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 01/16] x86/entry/32: Rename TSS_sysenter_sp0 to TSS_sysenter_stack Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 18:35   ` Thomas Gleixner
2018-01-16 18:35     ` Thomas Gleixner
2018-01-16 16:36 ` [PATCH 02/16] x86/entry/32: Enter the kernel via trampoline stack Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 20:30   ` Thomas Gleixner
2018-01-16 20:30     ` Thomas Gleixner
2018-01-16 22:37     ` Andy Lutomirski
2018-01-16 22:37       ` Andy Lutomirski
2018-01-16 22:45   ` Andy Lutomirski
2018-01-16 22:45     ` Andy Lutomirski
2018-01-17  9:18     ` Joerg Roedel
2018-01-17  9:18       ` Joerg Roedel
2018-01-17 18:10       ` Andy Lutomirski
2018-01-17 18:10         ` Andy Lutomirski
2018-01-19  9:55         ` Joerg Roedel
2018-01-19  9:55           ` Joerg Roedel
2018-01-19 16:30           ` Andy Lutomirski
2018-01-19 16:30             ` Andy Lutomirski
2018-01-22 10:11             ` Joerg Roedel
2018-01-22 10:11               ` Joerg Roedel
2018-01-22 17:46               ` Andy Lutomirski
2018-01-22 17:46                 ` Andy Lutomirski
2018-01-17  2:47   ` Boris Ostrovsky
2018-01-17  2:47     ` Boris Ostrovsky
2018-01-17  9:02     ` Joerg Roedel
2018-01-17  9:02       ` Joerg Roedel
2018-01-17 14:04       ` Andrew Cooper
2018-01-17 14:04         ` Andrew Cooper
2018-01-17 15:22         ` Boris Ostrovsky
2018-01-17 15:22           ` Boris Ostrovsky
2018-01-16 16:36 ` [PATCH 03/16] x86/entry/32: Leave the kernel via the " Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 22:48   ` Andy Lutomirski
2018-01-16 22:48     ` Andy Lutomirski
2018-01-17  9:24     ` Joerg Roedel
2018-01-17  9:24       ` Joerg Roedel
2018-01-17 13:57       ` Brian Gerst
2018-01-17 13:57         ` Brian Gerst
2018-01-17 14:00         ` Brian Gerst
2018-01-17 14:00           ` Brian Gerst
2018-01-17 14:14           ` Joerg Roedel
2018-01-17 14:14             ` Joerg Roedel
2018-01-17 14:45             ` Josh Poimboeuf
2018-01-17 14:45               ` Josh Poimboeuf
2018-01-17 14:10         ` Joerg Roedel
2018-01-17 14:10           ` Joerg Roedel
2018-01-17 18:12           ` Andy Lutomirski
2018-01-17 18:12             ` Andy Lutomirski
2018-01-19  9:57             ` Joerg Roedel
2018-01-19  9:57               ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 04/16] x86/pti: Define X86_CR3_PTI_PCID_USER_BIT on x86_32 Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 22:46   ` Andy Lutomirski
2018-01-16 22:46     ` Andy Lutomirski
2018-01-17  9:26     ` Joerg Roedel
2018-01-17  9:26       ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 05/16] x86/pgtable: Move pgdp kernel/user conversion functions to pgtable.h Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 06/16] x86/mm/ldt: Reserve high address-space range for the LDT Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 16:52   ` Peter Zijlstra
2018-01-16 16:52     ` Peter Zijlstra
2018-01-16 17:13     ` Joerg Roedel
2018-01-16 17:13       ` Joerg Roedel
2018-01-16 17:31       ` Peter Zijlstra
2018-01-16 17:31         ` Peter Zijlstra
2018-01-16 17:34         ` Waiman Long
2018-01-16 17:34           ` Waiman Long
2018-01-16 22:51     ` Andy Lutomirski
2018-01-16 22:51       ` Andy Lutomirski
2018-01-17  7:59       ` Peter Zijlstra
2018-01-17  7:59         ` Peter Zijlstra
2018-01-16 16:36 ` [PATCH 07/16] x86/mm: Move two more functions from pgtable_64.h to pgtable.h Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 18:03   ` Dave Hansen
2018-01-16 18:03     ` Dave Hansen
2018-01-16 19:11     ` Joerg Roedel
2018-01-16 19:11       ` Joerg Roedel
2018-01-16 19:34       ` Thomas Gleixner
2018-01-16 19:34         ` Thomas Gleixner
2018-01-16 16:36 ` [PATCH 08/16] x86/pgtable/32: Allocate 8k page-tables when PTI is enabled Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-17 23:43   ` Andy Lutomirski
2018-01-17 23:43     ` Andy Lutomirski
2018-01-19  9:57     ` Joerg Roedel
2018-01-19  9:57       ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 09/16] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32 Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 21:03   ` Thomas Gleixner
2018-01-16 21:03     ` Thomas Gleixner
2018-01-16 16:36 ` [PATCH 10/16] x86/mm/pti: Populate valid user pud entries Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 18:06   ` Dave Hansen
2018-01-16 18:06     ` Dave Hansen
2018-01-16 19:41     ` Joerg Roedel
2018-01-16 19:41       ` Joerg Roedel
2018-01-16 21:06   ` Thomas Gleixner
2018-01-16 21:06     ` Thomas Gleixner
2018-01-16 16:36 ` [PATCH 11/16] x86/mm/pgtable: Move pti_set_user_pgd() to pgtable.h Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 12/16] x86/mm/pae: Populate the user page-table with user pgd's Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 18:11   ` Dave Hansen
2018-01-16 18:11     ` Dave Hansen
2018-01-16 19:44     ` Joerg Roedel
2018-01-16 19:44       ` Joerg Roedel
2018-01-16 21:10   ` Thomas Gleixner
2018-01-16 21:10     ` Thomas Gleixner
2018-01-16 21:15     ` Dave Hansen
2018-01-16 21:15       ` Dave Hansen
2018-01-16 16:36 ` [PATCH 13/16] x86/mm/pti: Add an overflow check to pti_clone_pmds() Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 14/16] x86/mm/legacy: Populate the user page-table with user pgd's Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-17 23:41   ` Andy Lutomirski
2018-01-17 23:41     ` Andy Lutomirski
2018-01-16 16:36 ` [PATCH 15/16] x86/entry/32: Switch between kernel and user cr3 on entry/exit Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 16:36 ` [PATCH 16/16] x86/pti: Allow CONFIG_PAGE_TABLE_ISOLATION for x86_32 Joerg Roedel
2018-01-16 16:36   ` Joerg Roedel
2018-01-16 18:14 ` [RFC PATCH 00/16] PTI support for x86-32 Dave Hansen
2018-01-16 18:14   ` Dave Hansen
2018-01-16 19:46   ` Joerg Roedel
2018-01-16 19:46     ` Joerg Roedel
2018-01-16 18:59 ` Linus Torvalds
2018-01-16 18:59   ` Linus Torvalds
2018-01-16 19:02   ` Dave Hansen
2018-01-16 19:02     ` Dave Hansen
2018-01-16 19:21   ` Andrew Cooper
2018-01-16 19:21     ` Andrew Cooper
2018-01-16 19:55   ` Joerg Roedel
2018-01-16 19:55     ` Joerg Roedel
2018-01-16 21:20 ` Thomas Gleixner
2018-01-16 21:20   ` Thomas Gleixner
2018-01-17  9:55   ` Joerg Roedel
2018-01-17  9:55     ` Joerg Roedel
2018-01-16 22:26 ` Andy Lutomirski
2018-01-16 22:26   ` Andy Lutomirski
2018-01-17  9:33   ` Joerg Roedel
2018-01-17  9:33     ` Joerg Roedel
2018-01-19 10:55 ` Pavel Machek
2018-01-19 11:07   ` Joerg Roedel
2018-01-19 11:07     ` Joerg Roedel
2018-01-19 12:58     ` Pavel Machek
2018-01-21 20:13 ` Nadav Amit
2018-01-21 20:13   ` Nadav Amit
2018-01-21 20:44   ` Nadav Amit
2018-01-21 20:44     ` Nadav Amit
2018-01-21 23:46     ` Nadav Amit
2018-01-21 23:46       ` Nadav Amit
2018-01-22  2:11       ` Linus Torvalds
2018-01-22  2:11         ` Linus Torvalds
2018-01-22  2:20         ` hpa
2018-01-22  2:20           ` hpa
2018-01-22 20:14           ` Linus Torvalds
2018-01-22 20:14             ` Linus Torvalds
2018-01-22 21:10             ` H. Peter Anvin
2018-01-22 21:10               ` H. Peter Anvin
2018-01-23 14:38               ` Alan Cox
2018-01-23 14:38                 ` Alan Cox
2018-01-22  2:27         ` Nadav Amit
2018-01-22  2:27           ` Nadav Amit
2018-01-22  8:56       ` Joerg Roedel
2018-01-22  8:56         ` Joerg Roedel
2018-01-23 14:57         ` Alan Cox
2018-01-23 14:57           ` Alan Cox
2018-01-25 17:09         ` Alan Cox
2018-01-25 17:09           ` Alan Cox
2018-01-26 12:36           ` Joerg Roedel
2018-01-26 12:36             ` Joerg Roedel
2018-01-22  9:55       ` David Laight
2018-01-22 10:04         ` Joerg Roedel
2018-01-22 10:04           ` Joerg Roedel
2018-01-24 18:58 ` Krzysztof Mazur
2018-01-24 18:58   ` Krzysztof Mazur
2018-01-25 22:09   ` Nadav Amit
2018-01-25 22:09     ` Nadav Amit
2018-01-26  9:28     ` Krzysztof Mazur [this message]
2018-01-26  9:28       ` Krzysztof Mazur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180126092836.GA11003@shrek.podlesie.net \
    --to=krzysiek@podlesie.net \
    --cc=David.Laight@aculab.com \
    --cc=aarcange@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=daniel.gruss@iaik.tugraz.at \
    --cc=dave.hansen@intel.com \
    --cc=dvlasenk@redhat.com \
    --cc=eduval@amazon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=hughd@google.com \
    --cc=jgross@suse.com \
    --cc=jkosina@suse.cz \
    --cc=joro@8bytes.org \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.