From: Nir Lichtman <nir@lichtman.org>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
ebiederm@xmission.com, kees@kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] exec: refactor an invalid executable check to use isprint
Date: Fri, 15 Nov 2024 16:53:51 +0000 [thread overview]
Message-ID: <20241115165351.GA209124@lichtman.org> (raw)
Remove private printable macro that is defined in exec.c and migrate to
using the public isprint macro instead
Signed-off-by: Nir Lichtman <nir@lichtman.org>
---
fs/exec.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index 6c53920795c2..3394de5882af 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1723,7 +1723,6 @@ int remove_arg_zero(struct linux_binprm *bprm)
}
EXPORT_SYMBOL(remove_arg_zero);
-#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
/*
* cycle the list of binary formats handler, until one recognizes the image
*/
@@ -1761,8 +1760,8 @@ static int search_binary_handler(struct linux_binprm *bprm)
read_unlock(&binfmt_lock);
if (need_retry) {
- if (printable(bprm->buf[0]) && printable(bprm->buf[1]) &&
- printable(bprm->buf[2]) && printable(bprm->buf[3]))
+ if (isprint(bprm->buf[0]) && isprint(bprm->buf[1]) &&
+ isprint(bprm->buf[2]) && isprint(bprm->buf[3]))
return retval;
if (request_module("binfmt-%04x", *(ushort *)(bprm->buf + 2)) < 0)
return retval;
--
2.39.2
next reply other threads:[~2024-11-15 16:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 16:53 Nir Lichtman [this message]
2024-11-15 17:04 ` [PATCH] exec: refactor an invalid executable check to use isprint Al Viro
2024-11-15 17:30 ` Nir Lichtman
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=20241115165351.GA209124@lichtman.org \
--to=nir@lichtman.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 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.