From nobody Sat Mar 02 05:03:11 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 4TmtBl5CdFz5C0Q0; Sat, 2 Mar 2024 05:03:11 +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 4TmtBl3PGpz4tFj; Sat, 2 Mar 2024 05:03:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709355791; 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=LU33pCy9Pq9Tg95VDFeCDrIkh5ir0J5VXuUG3NzcK9c=; b=vwOwAeRnH3C/R3vZ57g/XywU0MzTAY8aDuEx6s4r805n4NkiIY7PISgoLVezQakA8sj15d 9Sxyg9IcIdsikO8JYxmTf88VdD7hL5N2DLAdjcvc2NbJAowpYxtg1/rXyQQMwvjXqcpn9E u2/unhfH8F4sZjyasXXtPZpgHbf9H0kuEs6JCDu2yDyL+GKdqKIQenztjr4RD3zVc8WrA7 +FZvbsARcYYD92V4LW0cTBAsF8i89rMBhinkves8mwgOgHl72Y9uLY+f7kzCHQMKjhAV5t OJGVCr1xgTEKWMsMrSbDR5KUBhPGojcpauNLKW7EV1vZJ7t+KEf7LXQ5NzzjNw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709355791; a=rsa-sha256; cv=none; b=U4KBZx24/5n+Aus8joMJe6dsj6gRplCRtHkqP1LczQhOsXs3UXNk+Fsmg7RYwfQo8x1FJL bQ6y3K3wQfjYYYFF7DyfeFfCOrZvX+oBgUfNncNKzO/nX7qnBbAAEbdr3mdH6enLN6Jk4c jfheNAzAJT5hkxt0Amwz4ngciBYA3SR3cDnvUSIlcR7IBlA5ckpH42ZsrCfK89/E/zjuCu BkwtgjbmUDmdiWg82LGD0IVOoOXWQfa8RKng87DFAshEKlALBxMAZNWI/7OhRb236gmqfM grZmvhN0PcJhvZvgk1Amk1siu6u0oLiMWcIfQOZVKwdCidSp5Ja1imjsKLmMHQ== 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=1709355791; 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=LU33pCy9Pq9Tg95VDFeCDrIkh5ir0J5VXuUG3NzcK9c=; b=B9NnLEQgM379ieBNqPZGJfTVtwbCQEwYTb9fpQFovwobAaREJbjlt4N3WT0CFIf91oVOVw HGOIjwz3Ju9aM7s5+KJ9WTYof90KZFT8NWYAvQ6ubMwRJ/fMpHFxejaPFZ1nDuU5HOywSL /vk9IkF24/+TURCPGFYpR5ahWEdOjkBOPzAP8Zbz1sdGyBF9FAdPUTCqDjRZxMGKETlHjV MmSqqZk82CvBq8VenUG5qI612XWJ71HScS2Xle32BOftou914OxTtWwulR+8JpKy3eN+Yt zZTM8fHDbZsA78/yo0Wjk9gI01QrjUe9rkJ4bcnK9MzdNTNeF+7pkq4oOQ1ndA== 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 4TmtBl30Ppzx8X; Sat, 2 Mar 2024 05:03:11 +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 42253BNc051593; Sat, 2 Mar 2024 05:03:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42253Bun051590; Sat, 2 Mar 2024 05:03:11 GMT (envelope-from git) Date: Sat, 2 Mar 2024 05:03:11 GMT Message-Id: <202403020503.42253Bun051590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7e4ac11b6076 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 7e4ac11b6076e6a9bf7341ddeae22784284ed733 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7e4ac11b6076e6a9bf7341ddeae22784284ed733 commit 7e4ac11b6076e6a9bf7341ddeae22784284ed733 Author: Konstantin Belousov AuthorDate: 2024-03-02 04:58:57 +0000 Commit: Konstantin Belousov CommitDate: 2024-03-02 05:02:55 +0000 getblkx(9): be more tolerant but also strict with the buffer size checks It is possible that on-disk filesystem format causes allocation of buffers of size larger than maxbcachebuf. Currently, getblkx() and indirectly bufkva_alloc() panic in that situation. It is more useful to return an error instead, allowing the system to continue running. PR: 277414 Reported by: Robert Morris MFC after: 1 week Sponsored by: The FreeBSD Foundation --- 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 4e0832475c3e..b5466fb2cd53 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -3985,9 +3985,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); @@ -4161,6 +4163,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. */