From nobody Wed Jun 22 00:59:41 2022 X-Original-To: dev-commits-src-main@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 C099585F7B5; Wed, 22 Jun 2022 00:59:41 +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 4LSQ5T5475z4Xhk; Wed, 22 Jun 2022 00:59:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655859581; 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=6ICvmem3jICiElSNN0p1eRYOUo7MQQEc0y3g/aPrjAY=; b=SLQr69oG7THMFTf0UdUJVCQRsgA1cnXX6XbVw34WoJm/k9bew4/wJLtQp11eWn8vPIFU2z gdIjbOLSBuzWGh6rn7qzVgiHxGnn2yagrnZxVH1oIctPuyYF/ItrW4zNDnhCOniU5h5aMK j/CtIX6Te1D2IhblK3zKsNdzHrlfEXcWd1SMTEpBAb65Pn8p9nqjxvaaMPmZtpiM43dvts /mxC1tcpce8sLOehLNm70f9fST71EPvwzQXNzGsBoWR9w/xzCkIV/wa/JGeqD9FnDZvmwD 5F8WiOxoXou0d2okndZ8jE6qoUMeu/5mJK/c1ylHBTFganmiqYFWjQE4CUYrDA== 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 8A3F31C5AC; Wed, 22 Jun 2022 00:59:41 +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 25M0xfvx042326; Wed, 22 Jun 2022 00:59:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25M0xfkr042325; Wed, 22 Jun 2022 00:59:41 GMT (envelope-from git) Date: Wed, 22 Jun 2022 00:59:41 GMT Message-Id: <202206220059.25M0xfkr042325@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Chuck Silvers Subject: git: 5bd21cbbd1df - main - vfs: fix vfs_bio_clrbuf() for PAGE_SIZE > block size List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: chs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5bd21cbbd1df837ccc9fe7834f43636fd20d8792 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655859581; 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=6ICvmem3jICiElSNN0p1eRYOUo7MQQEc0y3g/aPrjAY=; b=tlvHeYHc5mleSQC2ntfLjM8+eiaUSsNBwjpTSHvq9fwaVfH2tC/xU0fw/hQo9w0XCezcNP u+5MVMO3pvTvFgxBF61QD3XMsUptZ8ziyMRPravafARMvcyR/MHKptp0YQ29kdzEPoqyIS 2wwgtMUU629fs5NnxlOfKdBdD3qyRoChuwAZZY1kHJZZ6SQiH2M59MdgzpI2cwlDeq/axi fFEa+aBTn4u+t+T1MfKPNxDsKtBJpZd/fmdbhG5OH3keT9IJunFW6jlynEo8kti6ZwFkRC fY84Fr4kKEtWSlHSf66YCBBycaEUr6jfCRTRhgkJsBEynZuhtYmp+G1r92Hu5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655859581; a=rsa-sha256; cv=none; b=jo1y1NAcmfqI8X/lCzQqA0ZSoQTiUYbzZLvcNnNvlybYmEJ3PUu/PEX5K75miexZqkd33U f2Lr2tQ+UhSbq/o1BXPWMln4r2H8qyCInW1fUDKrqmNclaUOgn0V49GSghMVjYx+7XxpaN n4230oFtjKMb11rFHvkIAUsFw+das6q4t7VmN7Vhxp6FmHKvfizr78PBtcgv1B+mnDSS0r GMScxruraoPnrXYxcAcbKuufy2hnlN/cTvs+xjCF7pc4VAB54paWkgmNthGPjC0cPH9bAy +G7+eTui4WejYpbnHn5boPxSDK2XOK7JsGZqfSnUJ/Lzkqg91OfPqDM4QZ2QFA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by chs: URL: https://cgit.FreeBSD.org/src/commit/?id=5bd21cbbd1df837ccc9fe7834f43636fd20d8792 commit 5bd21cbbd1df837ccc9fe7834f43636fd20d8792 Author: Chuck Silvers AuthorDate: 2022-06-22 00:58:52 +0000 Commit: Chuck Silvers CommitDate: 2022-06-22 00:58:52 +0000 vfs: fix vfs_bio_clrbuf() for PAGE_SIZE > block size Calculate the desired page valid mask using math that will not overflow the types used. Sponsored by: Netflix Reviewed by: mckusick, kib, markj Differential Revision: https://reviews.freebsd.org/D34837 --- sys/kern/vfs_bio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 9082147b6034..7724e66f7bad 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -4852,7 +4852,8 @@ vfs_bio_set_valid(struct buf *bp, int base, int size) void vfs_bio_clrbuf(struct buf *bp) { - int i, j, mask, sa, ea, slide; + int i, j, sa, ea, slide, zbits; + vm_page_bits_t mask; if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) { clrbuf(bp); @@ -4871,7 +4872,9 @@ vfs_bio_clrbuf(struct buf *bp) if (bp->b_pages[i] == bogus_page) continue; j = sa / DEV_BSIZE; - mask = ((1 << ((ea - sa) / DEV_BSIZE)) - 1) << j; + zbits = (sizeof(vm_page_bits_t) * NBBY) - + (ea - sa) / DEV_BSIZE; + mask = (VM_PAGE_BITS_ALL >> zbits) << j; if ((bp->b_pages[i]->valid & mask) == mask) continue; if ((bp->b_pages[i]->valid & mask) == 0)