Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Dec 2023 03:01:07 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 137b36455d51 - stable/14 - freebsd32: Fix error handling for suword32() calls
Message-ID:  <202312280301.3BS317tV035698@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=137b36455d51f7303166bd4e1625b0bf969b9db5

commit 137b36455d51f7303166bd4e1625b0bf969b9db5
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-21 16:51:29 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-28 02:58:47 +0000

    freebsd32: Fix error handling for suword32() calls
    
    suword32() returns -1 upon an error, not an errno value.
    
    MFC after:      1 week
    
    (cherry picked from commit bd1654ce92569bbfbe513749db08cdd781b3a036)
---
 sys/compat/freebsd32/freebsd32_capability.c | 5 +++--
 sys/compat/freebsd32/freebsd32_misc.c       | 5 ++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/compat/freebsd32/freebsd32_capability.c b/sys/compat/freebsd32/freebsd32_capability.c
index 82db5da5898a..681e511a59de 100644
--- a/sys/compat/freebsd32/freebsd32_capability.c
+++ b/sys/compat/freebsd32/freebsd32_capability.c
@@ -117,9 +117,10 @@ freebsd32_cap_ioctls_get(struct thread *td,
 	cmds = fdep->fde_ioctls;
 	if (cmds32 != NULL && cmds != NULL) {
 		for (i = 0; i < MIN(fdep->fde_nioctls, maxcmds); i++) {
-			error = suword32(&cmds32[i], cmds[i]);
-			if (error != 0)
+			if (suword32(&cmds32[i], cmds[i]) != 0) {
+				error = EFAULT;
 				goto out;
+			}
 		}
 	}
 	if (fdep->fde_nioctls == -1)
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 2f5cf95b4e4a..5aafc459d60a 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -2700,9 +2700,8 @@ freebsd32___sysctlbyname(struct thread *td,
 	    &oldlen, uap->new, uap->newlen, &rv, SCTL_MASK32, 1);
 	if (error != 0)
 		return (error);
-	if (uap->oldlenp != NULL)
-		error = suword32(uap->oldlenp, rv);
-
+	if (uap->oldlenp != NULL && suword32(uap->oldlenp, rv) != 0)
+		error = EFAULT;
 	return (error);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202312280301.3BS317tV035698>