Re: [PATCH] execve: block Emacs binaries

From: Eric Biggers

Date: Wed Apr 01 2026 - 16:44:07 EST


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@xxxxxxxxx>
> ---
> 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