The branch main has been updated by markj:

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

commit bd1654ce92569bbfbe513749db08cdd781b3a036
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2023-12-21 16:51:29 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2023-12-21 16:54:05 +0000

    freebsd32: Fix error handling for suword32() calls
    
    suword32() returns -1 upon an error, not an errno value.
    
    MFC after:      1 week
---
 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);
 }
 

Reply via email to