From nobody Sat Jul 23 19:17:28 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lqwzs0KjMz4XWK6; Sat, 23 Jul 2022 19:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lqwzr6yBLz3Psh; Sat, 23 Jul 2022 19:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658603849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ePL/5XZwvVmLgdhim6gBN5Mxoqel9enoDWoyQ3r0cWA=; b=SO/GYZs1BFYuDZoQCrhhPLO/4pq0NyovdBeY0bPBADya+gvIlh+oLAe9Nc3AazNSWKxKnC WPIosvlxkT5ikU09oRP0WigG4IeEkos7sSVFQDWgJA3fT6DvKV+c1dxPTPaHBpPIz8tZGJ M+tk495COSnMDuySScRjUy/bRUtuDZXTLUSqtiHHy6zr2Biq5JLIYGuGtgIKq4giqvglnw pN2hXEHH/rgs0tnUNGlPM54CC04PfxizxNmOXdnwoAAoSodWGKa4l+YBzjO9+ydCgs0ynd 8+h+gRboA/84PHE4bPlnvM6Q5L9IfcX38We8XF9pwJN7OK38FnaIixkmZKHUkw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lqwzr5lldzrB0; Sat, 23 Jul 2022 19:17:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26NJHS84052476; Sat, 23 Jul 2022 19:17:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26NJHSBP052475; Sat, 23 Jul 2022 19:17:28 GMT (envelope-from git) Date: Sat, 23 Jul 2022 19:17:28 GMT Message-Id: <202207231917.26NJHSBP052475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 8c9aa94b42bf - main - Convert runtime param checks to KASSERTs for fo_fspacectl List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c9aa94b42bfe58f46be862ad5a08a68d9a19a4a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658603849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ePL/5XZwvVmLgdhim6gBN5Mxoqel9enoDWoyQ3r0cWA=; b=uHfm3bb8tM5SQ0qflOjcscrD6XM/oaags3pj6g4uDnMlMe5jylEXdh0FRCapR8t+OGnBUG G2GN270xqtXIfL8V56op1L92ELoHxoR87gSgmY3CsxKrfcKqurQGwkmWZ0m6RHWzyMsgDV lFUClaYKoRSiUOVR5ZYJOk7L1C/A/5wJUGL5FqERxuu7h6xeOzLNhEIoT7XpfAI1HgXpYa 4sPiGq5hTgDcDPSpKiRoUKBDSJt1A+Wpja9cqMFn2Zl+4C9IJaxqq/XzonLR682ty1v6Lz OPpy42KQupK4dg7dk10q4mEgPYXsahy0z5aA84eBfv479iaHk0R6g/NEfKFv/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658603849; a=rsa-sha256; cv=none; b=ljVhJQyoQcYDvUewumjfvBtU6KLR2lQzMdCRSMaYR8jkzXUb489OfO29POSOESzQCbQ+jn sD4L0PiIKfYL5j7H4IOSczocV0m694s3wgSqRXXL3ln9CR/AEG2U0DPeSNQyRv+TP16VMV sNYVEIoz9ZwaHH+vt2lls8KQR8xVqi7sgIzj/REG3ODLo85LR7rVXpA1JY1MHqaZBVM5ab ZGPIMNjqLWFE2NLp6MA/Vc0A4Z1+EU8E94vvFWw/xA4H5qZgU6h/D1FcIiWLCpJpEL6bqJ snt9C/s1donnDnUs36E7CRwEONXaKc0/p8DWNo9/IPV6/GS9/4jSLlajpLm/MA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=8c9aa94b42bfe58f46be862ad5a08a68d9a19a4a commit 8c9aa94b42bfe58f46be862ad5a08a68d9a19a4a Author: Ka Ho Ng AuthorDate: 2022-07-23 19:14:45 +0000 Commit: Ka Ho Ng CommitDate: 2022-07-23 19:16:23 +0000 Convert runtime param checks to KASSERTs for fo_fspacectl Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D35880 --- sys/kern/uipc_shm.c | 10 +++++----- sys/kern/vfs_vnops.c | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 1ca088edfd78..0af2b22866f4 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1990,16 +1990,16 @@ shm_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, off_t off, len; int error; - /* This assumes that the caller already checked for overflow. */ + KASSERT(cmd == SPACECTL_DEALLOC, ("shm_fspacectl: Invalid cmd")); + KASSERT((flags & ~SPACECTL_F_SUPPORTED) == 0, + ("shm_fspacectl: non-zero flags")); + KASSERT(*offset >= 0 && *length > 0 && *length <= OFF_MAX - *offset, + ("shm_fspacectl: offset/length overflow or underflow")); error = EINVAL; shmfd = fp->f_data; off = *offset; len = *length; - if (cmd != SPACECTL_DEALLOC || off < 0 || len <= 0 || - len > OFF_MAX - off || flags != 0) - return (EINVAL); - rl_cookie = rangelock_wlock(&shmfd->shm_rl, off, off + len, &shmfd->shm_mtx); switch (cmd) { diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index d5234b44e5eb..29851dcfaaa2 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3607,11 +3607,13 @@ vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, struct vnode *vp; int ioflag; + KASSERT(cmd == SPACECTL_DEALLOC, ("vn_fspacectl: Invalid cmd")); + KASSERT((flags & ~SPACECTL_F_SUPPORTED) == 0, + ("vn_fspacectl: non-zero flags")); + KASSERT(*offset >= 0 && *length > 0 && *length <= OFF_MAX - *offset, + ("vn_fspacectl: offset/length overflow or underflow")); vp = fp->f_vnode; - if (cmd != SPACECTL_DEALLOC || *offset < 0 || *length <= 0 || - *length > OFF_MAX - *offset || flags != 0) - return (EINVAL); if (vp->v_type != VREG) return (ENODEV);