Date: Tue, 27 Jul 2021 01:49:35 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: a938bfca7a1a - stable/13 - graid3: Zero the metadata block before writing Message-ID: <202107270149.16R1nZkj067355@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=a938bfca7a1ab2238c956e6098e78154da47ee2c commit a938bfca7a1ab2238c956e6098e78154da47ee2c Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-07-13 21:46:02 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-07-27 01:47:12 +0000 graid3: Zero the metadata block before writing Ensure that string buffers and pad bytes are zero-filled before writing graid3 metadata. Reported by: KMSAN Sponsored by: The FreeBSD Foundation (cherry picked from commit 39552dff7bb5463a74e5195d65a3252c583d9414) --- sys/geom/raid3/g_raid3.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 5fe67c00068d..159eff990892 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -743,6 +743,7 @@ g_raid3_fill_metadata(struct g_raid3_disk *disk, struct g_raid3_metadata *md) struct g_raid3_softc *sc; struct g_provider *pp; + bzero(md, sizeof(*md)); sc = disk->d_softc; strlcpy(md->md_magic, G_RAID3_MAGIC, sizeof(md->md_magic)); md->md_version = G_RAID3_VERSION; @@ -756,9 +757,7 @@ g_raid3_fill_metadata(struct g_raid3_disk *disk, struct g_raid3_metadata *md) md->md_no = disk->d_no; md->md_syncid = disk->d_sync.ds_syncid; md->md_dflags = (disk->d_flags & G_RAID3_DISK_FLAG_MASK); - if (disk->d_state != G_RAID3_DISK_STATE_SYNCHRONIZING) - md->md_sync_offset = 0; - else { + if (disk->d_state == G_RAID3_DISK_STATE_SYNCHRONIZING) { md->md_sync_offset = disk->d_sync.ds_offset_done / (sc->sc_ndisks - 1); } @@ -768,12 +767,8 @@ g_raid3_fill_metadata(struct g_raid3_disk *disk, struct g_raid3_metadata *md) pp = NULL; if ((disk->d_flags & G_RAID3_DISK_FLAG_HARDCODED) != 0 && pp != NULL) strlcpy(md->md_provider, pp->name, sizeof(md->md_provider)); - else - bzero(md->md_provider, sizeof(md->md_provider)); if (pp != NULL) md->md_provsize = pp->mediasize; - else - md->md_provsize = 0; } void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107270149.16R1nZkj067355>