From 3fde275167ce1f1455a03586d29840546d06d97a Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Mon, 25 Dec 2023 20:40:05 -0500 Subject: [PATCH] linux: Check for copyout errors in linux_fixup() This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: olce, dchagin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43104 --- sys/i386/linux/linux_sysvec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 8990b9b806ca..24f8ec2d7ea8 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -126,11 +126,14 @@ linux_fixup(uintptr_t *stack_base, struct image_params *imgp) argv = base; envp = base + (imgp->args->argc + 1); base--; - suword(base, (intptr_t)envp); + if (suword(base, (intptr_t)envp) != 0) + return (EFAULT); base--; - suword(base, (intptr_t)argv); + if (suword(base, (intptr_t)argv) != 0) + return (EFAULT); base--; - suword(base, imgp->args->argc); + if (suword(base, imgp->args->argc) != 0) + return (EFAULT); *stack_base = (uintptr_t)base; return (0); }