linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] exec: Fix a NULL vs IS_ERR() test in bprm_add_fixup_comm()
@ 2024-11-02  9:31 Dan Carpenter
  2024-11-02 19:57 ` Kees Cook
  2024-11-03 22:52 ` Tycho Andersen
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-11-02  9:31 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Kees Cook, Eric Biederman, Alexander Viro, Christian Brauner,
	Jan Kara, linux-mm, linux-fsdevel, linux-kernel, kernel-janitors

The strndup_user() function doesn't return NULL, it returns error
pointers.  Fix the check to match.

Fixes: 7bdc6fc85c9a ("exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/exec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 7e24d585915e..c5c291502dca 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1512,10 +1512,10 @@ static int bprm_add_fixup_comm(struct linux_binprm *bprm,
 		return 0;
 
 	bprm->argv0 = strndup_user(p, MAX_ARG_STRLEN);
-	if (bprm->argv0)
-		return 0;
+	if (IS_ERR(bprm->argv0))
+		return PTR_ERR(bprm->argv0);
 
-	return -EFAULT;
+	return 0;
 }
 
 static struct linux_binprm *alloc_bprm(int fd, struct filename *filename, int flags)
-- 
2.45.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-03 22:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-02  9:31 [PATCH next] exec: Fix a NULL vs IS_ERR() test in bprm_add_fixup_comm() Dan Carpenter
2024-11-02 19:57 ` Kees Cook
2024-11-03 22:52 ` Tycho Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox