* [PATCH] exec: refactor an invalid executable check to use isprint
@ 2024-11-15 16:53 Nir Lichtman
2024-11-15 17:04 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Nir Lichtman @ 2024-11-15 16:53 UTC (permalink / raw)
To: viro, brauner, jack, ebiederm, kees, linux-kernel
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] exec: refactor an invalid executable check to use isprint
2024-11-15 16:53 [PATCH] exec: refactor an invalid executable check to use isprint Nir Lichtman
@ 2024-11-15 17:04 ` Al Viro
2024-11-15 17:30 ` Nir Lichtman
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2024-11-15 17:04 UTC (permalink / raw)
To: Nir Lichtman; +Cc: brauner, jack, ebiederm, kees, linux-kernel
On Fri, Nov 15, 2024 at 04:53:51PM +0000, Nir Lichtman wrote:
> Remove private printable macro that is defined in exec.c and migrate to
> using the public isprint macro instead
> -#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
> - 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]))
RTFM(isprint). Or run a trivial loop and check what it does, for that
matter.
isprint('\t') is false. So's isprint('\n').
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] exec: refactor an invalid executable check to use isprint
2024-11-15 17:04 ` Al Viro
@ 2024-11-15 17:30 ` Nir Lichtman
0 siblings, 0 replies; 3+ messages in thread
From: Nir Lichtman @ 2024-11-15 17:30 UTC (permalink / raw)
To: Al Viro; +Cc: brauner, jack, ebiederm, kees, linux-kernel
On Fri, Nov 15, 2024 at 05:04:47PM +0000, Al Viro wrote:
> On Fri, Nov 15, 2024 at 04:53:51PM +0000, Nir Lichtman wrote:
> > Remove private printable macro that is defined in exec.c and migrate to
> > using the public isprint macro instead
>
>
> > -#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
>
> > - 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]))
>
> RTFM(isprint). Or run a trivial loop and check what it does, for that
> matter.
>
> isprint('\t') is false. So's isprint('\n').
Right my bad I read _SP as _S by mistake, I'll send out another version with a fix considering the spaces
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-15 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 16:53 [PATCH] exec: refactor an invalid executable check to use isprint Nir Lichtman
2024-11-15 17:04 ` Al Viro
2024-11-15 17:30 ` Nir Lichtman
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.