From owner-dev-commits-src-branches@freebsd.org Tue Sep 7 13:36:27 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 79B91664A74; Tue, 7 Sep 2021 13:36:27 +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 4H3mWZ6YS3z3vc3; Tue, 7 Sep 2021 13:36:26 +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 99A581388F; Tue, 7 Sep 2021 13:36:26 +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 187DaQSw008088; Tue, 7 Sep 2021 13:36:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 187DaQGf008087; Tue, 7 Sep 2021 13:36:26 GMT (envelope-from git) Date: Tue, 7 Sep 2021 13:36:26 GMT Message-Id: <202109071336.187DaQGf008087@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: b036a48de674 - stable/13 - md: Clamp to a multiple of the sector size when resizing 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/stable/13 X-Git-Reftype: branch X-Git-Commit: b036a48de67404f4a9aafd9a9ca9f801710bd9a1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2021 13:36:27 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b036a48de67404f4a9aafd9a9ca9f801710bd9a1 commit b036a48de67404f4a9aafd9a9ca9f801710bd9a1 Author: Mark Johnston AuthorDate: 2021-08-31 19:35:08 +0000 Commit: Mark Johnston CommitDate: 2021-09-07 13:36:19 +0000 md: Clamp to a multiple of the sector size when resizing We do this when creating md(4) devices, in kern_mdattach_locked(), but not when resizing the provider. Apply the same policy when resizing, as many GEOM classes do not expect to deal with providers for which pp->mediasize % pp->sectorsize != 0. Reported by: syzkaller Sponsored by: The FreeBSD Foundation (cherry picked from commit 47619b604402c9672a0f9bf62666f3bcba1dfb7e) --- sys/dev/md/md.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index c5c90d9173ad..308374f49f14 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -1592,6 +1592,7 @@ mdresize(struct md_s *sc, struct md_req *mdr) } sc->mediasize = mdr->md_mediasize; + g_topology_lock(); g_resize_provider(sc->pp, sc->mediasize); g_topology_unlock(); @@ -1799,6 +1800,7 @@ kern_mdresize_locked(struct md_req *mdr) return (ENOENT); if (mdr->md_mediasize < sc->sectorsize) return (EINVAL); + mdr->md_mediasize -= mdr->md_mediasize % sc->sectorsize; if (mdr->md_mediasize < sc->mediasize && !(sc->flags & MD_FORCE) && !(mdr->md_options & MD_FORCE))