]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
ffs: Correct the input size check in sysctl_ffs_fsck()
authorMark Johnston <markj@FreeBSD.org>
Mon, 31 May 2021 22:56:34 +0000 (18:56 -0400)
committerMark Johnston <markj@FreeBSD.org>
Mon, 31 May 2021 22:59:18 +0000 (18:59 -0400)
Make sure we return an error if no input was specified, since
SYSCTL_IN() will report success in that case.

Reported by: KMSAN
Reviewed by: mckusick
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30586

sys/ufs/ffs/ffs_alloc.c

index c7a1e2dec15e07127d718fd704f77f135586b69e..c895c8c7bf07714f1dd9fb2dcfc6b9e04e1c61b3 100644 (file)
@@ -3211,9 +3211,9 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
        cap_rights_t rights;
        int filetype, error;
 
-       if (req->newlen > sizeof cmd)
+       if (req->newptr == NULL || req->newlen > sizeof(cmd))
                return (EBADRPC);
-       if ((error = SYSCTL_IN(req, &cmd, sizeof cmd)) != 0)
+       if ((error = SYSCTL_IN(req, &cmd, sizeof(cmd))) != 0)
                return (error);
        if (cmd.version != FFS_CMD_VERSION)
                return (ERPCMISMATCH);