linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell Currey <ruscur@russell.cc>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH v1 5/6] powerpc/mm: Add a framework for Kernel Userspace Access Protection
Date: Wed, 21 Nov 2018 13:26:30 +1100	[thread overview]
Message-ID: <d5aa6ff391c0438371cae507e0b82a96eec4e979.camel@russell.cc> (raw)
In-Reply-To: <a8df3cd2be841ff5dd7b8d3fd357f40f9935f5a4.1541568128.git.christophe.leroy@c-s.fr>

On Wed, 2018-11-07 at 16:56 +0000, Christophe Leroy wrote:
> This patch implements a framework for Kernel Userspace Access
> Protection.
> 
> Then subarches will have to possibility to provide their own
> implementation
> by providing setup_kuap(), and lock/unlock_user_rd/wr_access
> 
> We separate read and write accesses because some subarches like
> book3s32 might only support write access protection.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

Separating read and writes does have a performance impact, I'm doing
some benchmarking to find out exactly how much - but at least for radix
it means we have to do a RMW instead of just a write.  It does add some
amount of security, though.

The other issue I have is that you're just locking everything here
(like I was), and not doing anything different for just reads or
writes.  In theory, wouldn't someone assume that they could (for
example) unlock reads, lock writes, then attempt to read?  At which
point the read would fail, because the lock actually locks both.

I would think we either need to bundle read/write locking/unlocking
together, or only implement this on platforms that can do one at a
time, unless there's a cleaner way to handle this.  Glancing at the
values you use for 8xx, this doesn't seem possible there, and it's a
definite performance hit for radix.

At the same time, as you say, it would suck for book3s32 that can only
do writes, but maybe just doing both at the same time and if
implemented for that platform it could just have a warning that it only
applies to writes on init?

Curious for people's thoughts on this.

- Russell 


  parent reply	other threads:[~2018-11-21  2:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 16:56 [PATCH v1 1/6] powerpc/mm: Fix reporting of kernel execute faults on the 8xx Christophe Leroy
2018-11-07 16:56 ` [RFC PATCH v1 2/6] powerpc: Add framework for Kernel Userspace Protection Christophe Leroy
2018-11-07 16:56 ` [RFC PATCH v1 3/6] powerpc: Add skeleton for Kernel Userspace Execution Prevention Christophe Leroy
2018-11-19  2:44   ` Russell Currey
2018-11-21 11:50     ` Michael Ellerman
2018-11-07 16:56 ` [RFC PATCH v1 4/6] powerpc/8xx: Add " Christophe Leroy
2018-11-07 16:56 ` [RFC PATCH v1 5/6] powerpc/mm: Add a framework for Kernel Userspace Access Protection Christophe Leroy
2018-11-07 17:08   ` Christophe LEROY
2018-11-21  2:26   ` Russell Currey [this message]
2018-11-21  8:32     ` Christophe LEROY
2018-11-22  1:25       ` Russell Currey
2018-11-28 10:05         ` Christophe LEROY
2018-11-07 16:56 ` [RFC PATCH v1 6/6] powerpc/8xx: Add " Christophe Leroy

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=d5aa6ff391c0438371cae507e0b82a96eec4e979.camel@russell.cc \
    --to=ruscur@russell.cc \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).