All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Kees Cook <keescook@chromium.org>
Cc: David Brown <david.brown@linaro.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>
Subject: Re: [kernel-hardening] Self Introduction
Date: Wed, 13 Jan 2016 11:29:38 +0000	[thread overview]
Message-ID: <20160113112937.GA2071@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <CAGXu5jLaAUnJosaw4Wxi+=uZ1GSfu9KZHAmwG4ewpgHLOh1YPg@mail.gmail.com>

+ rmk

On Tue, Jan 12, 2016 at 11:31:50AM -0800, Kees Cook wrote:
> On Mon, Jan 11, 2016 at 10:33 AM, David Brown <david.brown@linaro.org> wrote:
> > On Thu, Dec 10, 2015 at 03:52:16PM -0800, Kees Cook wrote:
> >
> >>> I haven't done any further improvements to them, nor have I received any
> >>> feedback. I'll rebase them against latest kernel if anyone else is
> >>> willing to test. I had a plan to run some benchmarks and see how
> >>> performance is affected (including the CPU_SW_DOMAIN_PAN) before pushing
> >>> again for upstreaming but I haven't had the time.
> >>
> >>
> >> David, getting back to something that might good to get your help
> >> with: would you be able to test Catalin's LPAE TTBR0 PAN series on
> >> real hardware? (Are you familiar with the LKDTM tests for this[1]?)
> >
> >
> > Sorry for the delay in getting back to you.  Been both moving and
> > taking vacation.
> >
> > I'd like to test this.  I'm just trying to see if I can track down
> > some hardware that'll boot LPAE.
> 
> Awesome! Thanks for the update.
> 
> Catalin, did you end up figuring out if your TTBR0 stuff was correct?
> You'd mentioned you needed to check something about the
> implementation?

Unfortunately, I checked with the ARM architecture folk. While the trick
is probably fine on existing hardware, the architecture allows caching
of the TTBCR bits (or their effect) in the TLB. Therefore changing the
TTBCR.EPD0 (or A1) to disable TTBR0 page table walks is not guaranteed
to have an effect until the TLBs are invalidated. CPU implementations
are allowed to rely on this, so we can't safely use it in Linux.

The minor side effect is that the PAN may not always work. We could
invalidate the TLBs at every PAN change and take a significant
performance hit. However, the more serious side effect is that TLB
conflicts may happen, leading to aborts (though unlikely on existing
hardware but we can't guarantee it for the future). The latter can't be
avoided (only reduce) by more TLB invalidation (the proper fix would be
MMU disabling).

In conclusion, I'm NAK'ing my own patch ;). The alternative is to make
TTBR0 point to swapper_pg_dir where there are no user mappings. The
difficulty is that such patch won't fit nicely onto the existing
uaccess_* macros that rmk added. It also doesn't work well with
switch_mm(), we would have to defer the TTBR0 setting until returning to
user space (cpu_switch_mm() should no longer be called in
check_and_switch_context() as it automatically enables privileged access
to user).

I haven't had time to look into re-writing the patch. Hopefully sometime
in February, unless someone else volunteers to take over.

Question for Russell: do we have any guarantees that lowmem doesn't
cross a 32-bit boundary? This would simplify the code a bit by
preserving the top 32-bit of TTBR0 when changing. But looking at the
sanity_check_meminfo(), I couldn't see anything that would guarantee
this. Even the virt_to_phys() macro does a carry add for the top 32-bit.

-- 
Catalin

  reply	other threads:[~2016-01-13 11:29 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 17:21 [kernel-hardening] Self Introduction David Brown
2015-12-09 22:19 ` Kees Cook
2015-12-10  0:00   ` David Brown
2015-12-10  0:14     ` Kees Cook
2015-12-10  0:26       ` David Brown
2015-12-10  0:41         ` Kees Cook
2015-12-10 17:14           ` Stephen Smalley
2015-12-10 17:49             ` Kees Cook
2015-12-10 17:55               ` Daniel Micay
2015-12-10 18:42                 ` Kees Cook
2015-12-10 19:07                   ` Daniel Micay
2015-12-10 19:23                     ` Kees Cook
2015-12-10 19:38                       ` Schaufler, Casey
2015-12-10 19:45                         ` Kees Cook
2015-12-11 17:54                           ` Valdis.Kletnieks
2015-12-11 18:44                             ` Kees Cook
2015-12-12 11:40                       ` Heiko Carstens
2015-12-10 22:38                   ` PaX Team
2015-12-10 23:04                     ` Daniel Micay
2015-12-10 18:42               ` Catalin Marinas
2015-12-10 18:47                 ` Kees Cook
2015-12-10 23:52                 ` Kees Cook
2015-12-11  1:04                   ` David Brown
2016-01-11 18:33                   ` David Brown
2016-01-12 19:31                     ` Kees Cook
2016-01-13 11:29                       ` Catalin Marinas [this message]
2016-01-13 11:31                       ` Catalin Marinas
2016-01-14  1:04                         ` Ben Hutchings
2016-01-14 11:11                           ` Catalin Marinas
2016-10-09 12:34 [kernel-hardening] self introduction Colin Vidal
2016-10-09 14:04 ` David Windsor
2016-10-09 19:09   ` Colin Vidal
2016-10-09 19:37     ` Jann Horn
2016-10-10  6:02       ` Reshetova, Elena
2016-10-10 16:01         ` Colin Vidal
2016-10-10 17:01           ` Reshetova, Elena
2016-10-10 21:05           ` Kees Cook
2016-10-12  3:19             ` Gengjia Chen
2016-10-12 22:31               ` Kees Cook
2016-10-13 11:14                 ` Gengjia Chen
2016-10-13 18:50                   ` Kees Cook
2016-10-17 11:57                     ` Gengjia Chen
2016-10-17 20:15                       ` Kees Cook
2016-10-18 11:52                         ` Gengjia Chen
2016-10-18 21:21                           ` Kees Cook
2016-10-12  8:25             ` Colin Vidal
2016-10-12 22:35               ` Kees Cook
2016-10-13 13:54                 ` Reshetova, Elena
2016-10-13 18:53         ` Kees Cook
2016-10-13 19:26           ` Hans Liljestrand
2016-10-10 20:57 ` Kees Cook
2016-10-12  8:27   ` Colin Vidal
2016-10-12 22:40     ` Kees Cook
2016-10-14 18:32   ` Andy Lutomirski

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=20160113112937.GA2071@e104818-lin.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=david.brown@linaro.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    /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.