From nobody Sat Mar 09 09:06:00 2024 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 4TsHFj03FKz5DDrh; Sat, 9 Mar 2024 09:06:01 +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 4TsHFh6jB2z4GGf; Sat, 9 Mar 2024 09:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709975160; 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=1jsxCA6n0w10OsvuFkh3ovp2gbJz55UDVUEsXrx+3gw=; b=J312EU+aPV6U3U63xw68jcMnYTLySu+ctIRK6bWBEuhz7r7B6UlWvp3Q3GW2SUAfPLXSrx 2ClV6YU7iYZvUvIF+SV9vPfuM+8sz43yrGASV9iAcYl74rp8RZ7gWwoK1lkpdohdm1tANr 7seIZxACD+D9FUO3f1IsRioJkLT6q5WkilAI9m4WkAZZIpw+Fa/e8949cqpvXCNvfLFq7r nnZHctB/t7IuNAUhF3qtvguwvWo2xIARnBqvyBWG5+BzsI8JGpQTsvFJXuz8gfnnLWDnuH 0DUuXYG/xtl2H0NzqJtMgzX7DZLPn3ZOLvlBLMbsWDCWtWq8u4OqGckEcjY1VQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709975160; a=rsa-sha256; cv=none; b=JDo8BBSNH3oOJEsFlC748t6f/vISvBfNVOHZL2IWjIhVa0e06MLc3HLSsknOR4HdaQBhcG zMgi4IpwL2jGPpwcqgx8I+aphtawipz2EtlDsewhg0saYgmaj6NpVHq5uMJlAuLXZLXRFz d6z4Ah6n169vJ+0IDNAhxtKQcgHnPYLlgSSAJcA+jlKW4OmFHKii6p0qTEmTVVmhWprQwT osFQQMnj/CCoDqemBxAZFJOCPXhY1v2MNGnIc81yvF6Tm/DyKU33QpLxTJB7E3P7iuLyAP T1L1d261qa3HZN8vV0taTcD7cUaV1oCZCbcrrTK12+KWXkGzJG+65mfv/ogi+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709975160; 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=1jsxCA6n0w10OsvuFkh3ovp2gbJz55UDVUEsXrx+3gw=; b=ExBvMQuGzmtbViWHedr3csgGRaRAunPHYxqiJk5oomvuchlsZTSH3eDrnpdJ0QjvpaKOzm HYlgTI+xSbgMhJBgjb0fVeeK40e3sprPpIMpVJZnhxVroR0EznwRxYdiWBTZ8OLsNBnpZc HqpOAM8S6UI3CS8ozPs284eZU48YiV565F15I6JC4bFq8hBpEYGZHz3nndRixkrtFSZqKd 7ha8UGsjcfV1OxjgavWkvwLJCUdCy/KSKpfeCNqJYt1Pnl71TnK7y3t+ZF1Zth2bV1ga5/ nD1QeT8xVK3h5nbdFiH/CVC2XHWGPj2B9eJUwREXcZ/YjRIS9xOZj5M26Ero2Q== 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 4TsHFh6Fhxzwhl; Sat, 9 Mar 2024 09:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 429960W3078503; Sat, 9 Mar 2024 09:06:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4299602P078500; Sat, 9 Mar 2024 09:06:00 GMT (envelope-from git) Date: Sat, 9 Mar 2024 09:06:00 GMT Message-Id: <202403090906.4299602P078500@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1c1fde7540d8 - stable/13 - getblkx(9): be more tolerant but also strict with the buffer size checks 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1c1fde7540d813703d775e013a950145224f182e Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1c1fde7540d813703d775e013a950145224f182e commit 1c1fde7540d813703d775e013a950145224f182e Author: Konstantin Belousov AuthorDate: 2024-03-02 04:58:57 +0000 Commit: Konstantin Belousov CommitDate: 2024-03-08 18:48:02 +0000 getblkx(9): be more tolerant but also strict with the buffer size checks PR: 277414 (cherry picked from commit 7e4ac11b6076e6a9bf7341ddeae22784284ed733) --- sys/kern/vfs_bio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 546b6dfb6239..78dc6f511a4e 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -3963,9 +3963,11 @@ getblkx(struct vnode *vp, daddr_t blkno, daddr_t dblkno, int size, int slpflag, ("GB_KVAALLOC only makes sense with GB_UNMAPPED")); if (vp->v_type != VCHR) ASSERT_VOP_LOCKED(vp, "getblk"); - if (size > maxbcachebuf) - panic("getblk: size(%d) > maxbcachebuf(%d)\n", size, + if (size > maxbcachebuf) { + printf("getblkx: size(%d) > maxbcachebuf(%d)\n", size, maxbcachebuf); + return (EIO); + } if (!unmapped_buf_allowed) flags &= ~(GB_UNMAPPED | GB_KVAALLOC); @@ -4132,6 +4134,12 @@ newbuf_unlocked: vmio = vp->v_object != NULL; if (vmio) { maxsize = size + (offset & PAGE_MASK); + if (maxsize > maxbcachebuf) { + printf( + "getblkx: maxsize(%d) > maxbcachebuf(%d)\n", + maxsize, maxbcachebuf); + return (EIO); + } } else { maxsize = size; /* Do not allow non-VMIO notmapped buffers. */