Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Sep 2021 13:36:26 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b036a48de674 - stable/13 - md: Clamp to a multiple of the sector size when resizing
Message-ID:  <202109071336.187DaQGf008087@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=b036a48de67404f4a9aafd9a9ca9f801710bd9a1

commit b036a48de67404f4a9aafd9a9ca9f801710bd9a1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-08-31 19:35:08 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
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))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109071336.187DaQGf008087>