From: Mateusz Guzik <mjguzik@gmail.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH] execve: block Emacs binaries
Date: Wed, 1 Apr 2026 15:12:26 +0200 [thread overview]
Message-ID: <20260401131226.4011156-1-mjguzik@gmail.com> (raw)
No justification needed.
A new errno is introduced to indicate what happened.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
fs/exec.c | 16 ++++++++++++++++
include/uapi/asm-generic/errno.h | 2 ++
2 files changed, 18 insertions(+)
diff --git a/fs/exec.c b/fs/exec.c
index 9ea3a775d51e..2e954b31e3a2 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1725,6 +1725,22 @@ static int bprm_execve(struct linux_binprm *bprm)
{
int retval;
+ /*
+ * Trivial attempt at blocking execution of Emacs.
+ *
+ * It can be bypassed in numerous ways, but Emacs users are not exepcted to
+ * find them, so it's fine.
+ *
+ * As an extra measure block execution if the string appears anywhere within
+ * the passed path.
+ */
+ if (strstr(bprm->filename, "emacs")) {
+ /*
+ * Disgusting!
+ */
+ return -EMACS;
+ }
+
retval = prepare_bprm_creds(bprm);
if (retval)
return retval;
diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
index 92e7ae493ee3..1a8fda40cd8a 100644
--- a/include/uapi/asm-generic/errno.h
+++ b/include/uapi/asm-generic/errno.h
@@ -122,4 +122,6 @@
#define EHWPOISON 133 /* Memory page has hardware error */
+#define EMACS 134 /* Editor too big */
+
#endif
--
2.48.1
next reply other threads:[~2026-04-01 13:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 13:12 Mateusz Guzik [this message]
2026-04-01 18:37 ` [PATCH] execve: block Emacs binaries Pedro Falcato
2026-04-01 19:24 ` Mateusz Guzik
2026-04-01 21:32 ` David Laight
2026-04-01 18:53 ` [PATCH 2/1] execve: only smart people should use vim Steven Rostedt
2026-04-01 18:58 ` Mateusz Guzik
2026-04-01 18:59 ` Mateusz Guzik
2026-04-01 20:43 ` [PATCH] execve: block Emacs binaries Eric Biggers
2026-04-07 3:58 ` kernel test robot
2026-04-07 3:58 ` kernel test robot
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=20260401131226.4011156-1-mjguzik@gmail.com \
--to=mjguzik@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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