linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Kees Cook <kees@kernel.org>
Cc: Jeff Xu <jeffxu@chromium.org>, Jann Horn <jannh@google.com>,
	"Isaac J. Manjarres" <isaacmanjarres@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Alexander Aring <alex.aring@gmail.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>, Shuah Khan <shuah@kernel.org>,
	kernel-team@android.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Suren Baghdasaryan <surenb@google.com>,
	Kalesh Singh <kaleshsingh@google.com>,
	John Stultz <jstultz@google.com>
Subject: Re: [RFC PATCH v1 1/2] mm/memfd: Add support for F_SEAL_FUTURE_EXEC to memfd
Date: Wed, 8 Jan 2025 19:06:13 +0000	[thread overview]
Message-ID: <e8d21f15-56c6-43c3-9009-3de74cccdf3a@lucifer.local> (raw)
In-Reply-To: <202501061643.986D9453@keescook>

On Mon, Jan 06, 2025 at 04:44:33PM -0800, Kees Cook wrote:
> On Mon, Jan 06, 2025 at 10:26:27AM -0800, Jeff Xu wrote:
> > + Kees because this is related to W^X memfd and security.
> >
> > On Fri, Jan 3, 2025 at 7:14 AM Jann Horn <jannh@google.com> wrote:
> > >
> > > On Fri, Dec 6, 2024 at 7:19 PM Lorenzo Stoakes
> > > <lorenzo.stoakes@oracle.com> wrote:
> > > > On Thu, Dec 05, 2024 at 05:09:22PM -0800, Isaac J. Manjarres wrote:
> > > > > +             if (is_exec_sealed(seals)) {
> > > >
> > > > Are we intentionally disallowing a MAP_PRIVATE memfd's mapping's execution?
> > > > I've not tested this scenario so don't know if we somehow disallow this in
> > > > another way but note on write checks we only care about shared mappings.
> > > >
> > > > I mean one could argue that a MAP_PRIVATE situation is the same as copying
> > > > the data into an anon buffer and doing what you want with it, here you
> > > > could argue the same...
> > > >
> > > > So probably we should only care about VM_SHARED?
> > >
> > > FWIW I think it doesn't make sense to distinguish between
> > > shared/private mappings here - in the scenario described in the cover
> > > letter, it wouldn't matter that much to an attacker whether the
> > > mapping is shared or private (as long as the VMA contents haven't been
> > > CoWed already).
> > +1 on this.
> > The concept of blocking this for only shared mapping is questionable.
>
> Right -- why does sharedness matter? It seems more robust to me to not
> create a corner case but rather apply the flag/behavior universally?
>

I'm struggling to understand what you are protecting against, if I can receive a
buffer '-not executable-'. But then copy it into another buffer I mapped, and
execute it?

I mean am I missing something? It's very possible :)

The cost is complexity. And the difference between mappings which are shared and
those which are private and moreso MAP_PRIVATE of an fd are actually quite a lot
internally (go look at anon_vma code if you have the great benefit of not yet
doing so to see the deepest, darkest, 9th circle of complexity hell :>).

Again, I may be missing the point here or misunderstanding the apparent attack
vector, but this is where I'm coming from.

> --
> Kees Cook


  reply	other threads:[~2025-01-08 19:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06  1:09 [RFC PATCH v1 0/2] Add file seal to prevent future exec mappings Isaac J. Manjarres
2024-12-06  1:09 ` [RFC PATCH v1 1/2] mm/memfd: Add support for F_SEAL_FUTURE_EXEC to memfd Isaac J. Manjarres
2024-12-06 17:49   ` Kalesh Singh
2024-12-06 20:50     ` Isaac Manjarres
2024-12-06 18:19   ` Lorenzo Stoakes
2024-12-06 20:48     ` Isaac Manjarres
2024-12-06 21:14       ` Lorenzo Stoakes
2024-12-11 20:56         ` Isaac Manjarres
2025-01-03 15:13     ` Jann Horn
2025-01-06 18:26       ` Jeff Xu
2025-01-07  0:44         ` Kees Cook
2025-01-08 19:06           ` Lorenzo Stoakes [this message]
2025-01-08 22:07             ` Kees Cook
2025-01-09 23:30             ` Jeff Xu
2025-01-14 20:02               ` Isaac Manjarres
2025-01-14 21:29                 ` Kees Cook
2025-01-14 22:42                   ` Isaac Manjarres
2025-01-14 23:41                     ` Jeff Xu
2025-01-14 23:56                       ` Jeff Xu
2024-12-06  1:09 ` [RFC PATCH v1 2/2] selftests/memfd: Add tests for F_SEAL_FUTURE_EXEC Isaac J. Manjarres

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=e8d21f15-56c6-43c3-9009-3de74cccdf3a@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.aring@gmail.com \
    --cc=chuck.lever@oracle.com \
    --cc=isaacmanjarres@google.com \
    --cc=jannh@google.com \
    --cc=jeffxu@chromium.org \
    --cc=jlayton@kernel.org \
    --cc=jstultz@google.com \
    --cc=kaleshsingh@google.com \
    --cc=kees@kernel.org \
    --cc=kernel-team@android.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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