From owner-dev-commits-src-main@freebsd.org Wed Aug 11 20:44:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE48665B1A2; Wed, 11 Aug 2021 20:44:47 +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 4GlMJH5nkYz4Vbq; Wed, 11 Aug 2021 20:44:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A86C01603F; Wed, 11 Aug 2021 20:44:47 +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 17BKilg1092267; Wed, 11 Aug 2021 20:44:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKilZL092266; Wed, 11 Aug 2021 20:44:47 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:44:47 GMT Message-Id: <202108112044.17BKilZL092266@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 645b7efd496d - main - geom_disk: Add KMSAN checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 645b7efd496d649211056be0e2d3525ef21dc53d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:44:48 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=645b7efd496d649211056be0e2d3525ef21dc53d commit 645b7efd496d649211056be0e2d3525ef21dc53d Author: Mark Johnston AuthorDate: 2021-08-11 20:22:26 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 20:33:41 +0000 geom_disk: Add KMSAN checks - In g_disk_start(), verify that the data to be written is initialized according to KMSAN shadow state. - In g_disk_done(), verify that the block driver updated shadow state as expected, so as to catch sources of false positives early. Sponsored by: The FreeBSD Foundation --- sys/geom/geom_disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 2f0e72fad52d..9877243fa36e 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -239,6 +240,9 @@ g_disk_done(struct bio *bp) bp2->bio_error = bp->bio_error; bp2->bio_completed += bp->bio_length - bp->bio_resid; + if (bp->bio_cmd == BIO_READ) + kmsan_check(bp2->bio_data, bp2->bio_completed, "g_disk_done"); + switch (bp->bio_cmd) { case BIO_ZONE: bcopy(&bp->bio_zone, &bp2->bio_zone, sizeof(bp->bio_zone)); @@ -445,6 +449,10 @@ g_disk_start(struct bio *bp) KASSERT((dp->d_flags & DISKFLAG_UNMAPPED_BIO) != 0 || (bp->bio_flags & BIO_UNMAPPED) == 0, ("unmapped bio not supported by disk %s", dp->d_name)); + + if (bp->bio_cmd == BIO_WRITE) + kmsan_check_bio(bp, "g_disk_start"); + off = 0; bp3 = NULL; bp2 = g_clone_bio(bp);