diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1990,16 +1990,16 @@ 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 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3607,11 +3607,13 @@ 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);