* [PATCH] execve: block Emacs binaries
@ 2026-04-01 13:12 Mateusz Guzik
2026-04-01 18:37 ` Pedro Falcato
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Mateusz Guzik @ 2026-04-01 13:12 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, linux-fsdevel, Mateusz Guzik
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] execve: block Emacs binaries
2026-04-01 13:12 [PATCH] execve: block Emacs binaries Mateusz Guzik
@ 2026-04-01 18:37 ` Pedro Falcato
2026-04-01 19:24 ` Mateusz Guzik
2026-04-01 18:53 ` [PATCH 2/1] execve: only smart people should use vim Steven Rostedt
2026-04-01 20:43 ` [PATCH] execve: block Emacs binaries Eric Biggers
2 siblings, 1 reply; 8+ messages in thread
From: Pedro Falcato @ 2026-04-01 18:37 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: linux-mm, linux-kernel, linux-fsdevel
On Wed, Apr 01, 2026 at 03:12:26PM +0200, Mateusz Guzik wrote:
> 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;
> + }
> +
Can you block vim too? We only use ed(1) and GNU nano in this house.
--
Pedro
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/1] execve: only smart people should use vim
2026-04-01 13:12 [PATCH] execve: block Emacs binaries Mateusz Guzik
2026-04-01 18:37 ` Pedro Falcato
@ 2026-04-01 18:53 ` Steven Rostedt
2026-04-01 18:58 ` Mateusz Guzik
2026-04-01 20:43 ` [PATCH] execve: block Emacs binaries Eric Biggers
2 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2026-04-01 18:53 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: linux-mm, linux-kernel, linux-fsdevel
From: Steven Rostedt <rostedt@goodmis.org>
To keep people from getting stuck in vim and not knowing how to exit it.
Make running vim a bit more complex.
They can go back and use emacs, of course that will fail too, but then
they have something to work on.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
fs/exec.c | 11 +++++++++++
include/uapi/asm-generic/errno.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/fs/exec.c b/fs/exec.c
index 2e954b31e3a2..ecb425388008 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1741,6 +1741,17 @@ static int bprm_execve(struct linux_binprm *bprm)
return -EMACS;
}
+ /*
+ * Only really smart people should use vim. If they can't figure out
+ * how to circumvent this, then they have no right using it!
+ */
+ if (strstr(bprm->filename, "vim")) {
+ /*
+ * Learn to code!
+ */
+ return -NOTEMACS;
+ }
+
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 1a8fda40cd8a..4cc4ae653cec 100644
--- a/include/uapi/asm-generic/errno.h
+++ b/include/uapi/asm-generic/errno.h
@@ -123,5 +123,6 @@
#define EHWPOISON 133 /* Memory page has hardware error */
#define EMACS 134 /* Editor too big */
+#define NOTEMACS 135 /* Editor used by smart people */
#endif
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/1] execve: only smart people should use vim
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
0 siblings, 1 reply; 8+ messages in thread
From: Mateusz Guzik @ 2026-04-01 18:58 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-mm, linux-kernel, linux-fsdevel
On Wed, Apr 1, 2026 at 8:53 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: Steven Rostedt <rostedt@goodmis.org>
>
> To keep people from getting stuck in vim and not knowing how to exit it.
> Make running vim a bit more complex.
>
> They can go back and use emacs, of course that will fail too, but then
> they have something to work on.
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> fs/exec.c | 11 +++++++++++
> include/uapi/asm-generic/errno.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index 2e954b31e3a2..ecb425388008 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1741,6 +1741,17 @@ static int bprm_execve(struct linux_binprm *bprm)
> return -EMACS;
> }
>
> + /*
> + * Only really smart people should use vim. If they can't figure out
> + * how to circumvent this, then they have no right using it!
> + */
> + if (strstr(bprm->filename, "vim")) {
> + /*
> + * Learn to code!
> + */
> + return -NOTEMACS;
> + }
> +
I would consider extending this to nvim, otherwise looks good.
Reviewed-by: Mateusz Guzik <mjguzik@notobjecting.org>
> 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 1a8fda40cd8a..4cc4ae653cec 100644
> --- a/include/uapi/asm-generic/errno.h
> +++ b/include/uapi/asm-generic/errno.h
> @@ -123,5 +123,6 @@
> #define EHWPOISON 133 /* Memory page has hardware error */
>
> #define EMACS 134 /* Editor too big */
> +#define NOTEMACS 135 /* Editor used by smart people */
>
> #endif
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/1] execve: only smart people should use vim
2026-04-01 18:58 ` Mateusz Guzik
@ 2026-04-01 18:59 ` Mateusz Guzik
0 siblings, 0 replies; 8+ messages in thread
From: Mateusz Guzik @ 2026-04-01 18:59 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-mm, linux-kernel, linux-fsdevel
On Wed, Apr 1, 2026 at 8:58 PM Mateusz Guzik <mjguzik@gmail.com> wrote:
>
> On Wed, Apr 1, 2026 at 8:53 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > From: Steven Rostedt <rostedt@goodmis.org>
> >
> > To keep people from getting stuck in vim and not knowing how to exit it.
> > Make running vim a bit more complex.
> >
> > They can go back and use emacs, of course that will fail too, but then
> > they have something to work on.
> >
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > ---
> > fs/exec.c | 11 +++++++++++
> > include/uapi/asm-generic/errno.h | 1 +
> > 2 files changed, 12 insertions(+)
> >
> > diff --git a/fs/exec.c b/fs/exec.c
> > index 2e954b31e3a2..ecb425388008 100644
> > --- a/fs/exec.c
> > +++ b/fs/exec.c
> > @@ -1741,6 +1741,17 @@ static int bprm_execve(struct linux_binprm *bprm)
> > return -EMACS;
> > }
> >
> > + /*
> > + * Only really smart people should use vim. If they can't figure out
> > + * how to circumvent this, then they have no right using it!
> > + */
> > + if (strstr(bprm->filename, "vim")) {
> > + /*
> > + * Learn to code!
> > + */
> > + return -NOTEMACS;
> > + }
> > +
>
> I would consider extending this to nvim, otherwise looks good.
that's of course already covered, my bad!
>
> Reviewed-by: Mateusz Guzik <mjguzik@notobjecting.org>
>
> > 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 1a8fda40cd8a..4cc4ae653cec 100644
> > --- a/include/uapi/asm-generic/errno.h
> > +++ b/include/uapi/asm-generic/errno.h
> > @@ -123,5 +123,6 @@
> > #define EHWPOISON 133 /* Memory page has hardware error */
> >
> > #define EMACS 134 /* Editor too big */
> > +#define NOTEMACS 135 /* Editor used by smart people */
> >
> > #endif
> > --
> > 2.51.0
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] execve: block Emacs binaries
2026-04-01 18:37 ` Pedro Falcato
@ 2026-04-01 19:24 ` Mateusz Guzik
2026-04-01 21:32 ` David Laight
0 siblings, 1 reply; 8+ messages in thread
From: Mateusz Guzik @ 2026-04-01 19:24 UTC (permalink / raw)
To: Pedro Falcato; +Cc: linux-mm, linux-kernel, linux-fsdevel
On Wed, Apr 1, 2026 at 8:37 PM Pedro Falcato <pfalcato@suse.de> wrote:
> Can you block vim too? We only use ed(1) and GNU nano in this house.
>
I heard nano is a company-issued editor at Suse.
If I wanted to mess with Red Hat I would block mcedit.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] execve: block Emacs binaries
2026-04-01 13:12 [PATCH] execve: block Emacs binaries Mateusz Guzik
2026-04-01 18:37 ` Pedro Falcato
2026-04-01 18:53 ` [PATCH 2/1] execve: only smart people should use vim Steven Rostedt
@ 2026-04-01 20:43 ` Eric Biggers
2 siblings, 0 replies; 8+ messages in thread
From: Eric Biggers @ 2026-04-01 20:43 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: linux-mm, linux-kernel, linux-fsdevel
On Wed, Apr 01, 2026 at 03:12:26PM +0200, Mateusz Guzik wrote:
> 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;
> + }
Won't this break some existing text editing workflows? To ensure a
seamless transition I'd suggest also embedding a copy of a proper text
editor into the kernel image, and making the kernel automatically
replace the emacs binary with it.
- Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] execve: block Emacs binaries
2026-04-01 19:24 ` Mateusz Guzik
@ 2026-04-01 21:32 ` David Laight
0 siblings, 0 replies; 8+ messages in thread
From: David Laight @ 2026-04-01 21:32 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: Pedro Falcato, linux-mm, linux-kernel, linux-fsdevel
On Wed, 1 Apr 2026 21:24:54 +0200
Mateusz Guzik <mjguzik@gmail.com> wrote:
> On Wed, Apr 1, 2026 at 8:37 PM Pedro Falcato <pfalcato@suse.de> wrote:
> > Can you block vim too? We only use ed(1) and GNU nano in this house.
> >
>
> I heard nano is a company-issued editor at Suse.
>
> If I wanted to mess with Red Hat I would block mcedit.
>
You are all wimps.
Try editing files in a small 'miniroot' for an embedded system.
If you are really lucky you've got a shell that supports ## and %%.
David
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-01 21:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 13:12 [PATCH] execve: block Emacs binaries Mateusz Guzik
2026-04-01 18:37 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox