* + mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd.patch added to mm-unstable branch
@ 2022-12-15 21:47 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-12-15 21:47 UTC (permalink / raw)
To: mm-commits, skhan, lkp, keescook, jorgelo, jannh, hughd, dverkamp,
dmitry.torokhov, dh.herrmann, jeffxu, akpm
The patch titled
Subject: mm/memfd: Add write seals when apply SEAL_EXEC to executable memfd
has been added to the -mm mm-unstable branch. Its filename is
mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Jeff Xu <jeffxu@google.com>
Subject: mm/memfd: Add write seals when apply SEAL_EXEC to executable memfd
Date: Thu, 15 Dec 2022 00:12:04 +0000
In order to avoid WX mappings, add F_SEAL_WRITE when apply F_SEAL_EXEC to
an executable memfd, so W^X from start.
This implys application need to fill the content of the memfd first, after
F_SEAL_EXEC is applied, application can no longer modify the content of
the memfd.
Typically, application seals the memfd right after writing to it.
For example:
1. memfd_create(MFD_EXEC).
2. write() code to the memfd.
3. fcntl(F_ADD_SEALS, F_SEAL_EXEC) to convert the memfd to W^X.
4. call exec() on the memfd.
Link: https://lkml.kernel.org/r/20221215001205.51969-5-jeffxu@google.com
Signed-off-by: Jeff Xu <jeffxu@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jorge Lucangeli Obes <jorgelo@chromium.org>
Cc: kernel test robot <lkp@intel.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/memfd.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/mm/memfd.c~mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd
+++ a/mm/memfd.c
@@ -222,6 +222,12 @@ static int memfd_add_seals(struct file *
}
}
+ /*
+ * SEAL_EXEC implys SEAL_WRITE, making W^X from the start.
+ */
+ if (seals & F_SEAL_EXEC && inode->i_mode & 0111)
+ seals |= F_SEAL_SHRINK|F_SEAL_GROW|F_SEAL_WRITE|F_SEAL_FUTURE_WRITE;
+
*file_seals |= seals;
error = 0;
_
Patches currently in -mm which might be from jeffxu@google.com are
mm-memfd-add-mfd_noexec_seal-and-mfd_exec.patch
mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd.patch
selftests-memfd-add-tests-for-mfd_noexec_seal-mfd_exec.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-15 21:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-15 21:47 + mm-memfd-add-write-seals-when-apply-seal_exec-to-executable-memfd.patch added to mm-unstable branch Andrew Morton
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.