aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/geom/misc
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2018-02-04 14:49:55 +0000
committerAlan Somers <asomers@FreeBSD.org>2018-02-04 14:49:55 +0000
commitf5b4099e6b72fd7ac9f620c389229a9a4bf09992 (patch)
treecc6486cf8b057ab5af16a6d048aa58e09d11dcd8 /sbin/geom/misc
parentaa3c83c3c6431c02c8c30318e9602b5e79ebe06e (diff)
downloadsrc-f5b4099e6b72fd7ac9f620c389229a9a4bf09992.tar.gz
src-f5b4099e6b72fd7ac9f620c389229a9a4bf09992.zip
geom: don't write stack garbage in disk labels
Most consumers of g_metadata_store were passing in partially unallocated memory, resulting in stack garbage being written to disk labels. Fix them by zeroing the memory first. gvirstor repeated the same mistake, but in the kernel. Also, glabel's label contained a fixed-size string that wasn't initialized to zero. PR: 222077 Reported by: Maxim Khitrov <max@mxcrypt.com> Reviewed by: cem MFC after: 3 weeks X-MFC-With: 323314 X-MFC-With: 323338 Differential Revision: https://reviews.freebsd.org/D14164
Notes
Notes: svn path=/head/; revision=328849
Diffstat (limited to 'sbin/geom/misc')
-rw-r--r--sbin/geom/misc/subr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index a8e60f6d286a..3985ae56edc6 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -273,6 +273,13 @@ out:
return (error);
}
+/*
+ * Actually write the GEOM label to the provider
+ *
+ * @param name GEOM provider's name (ie "ada0")
+ * @param md Pointer to the label data to write
+ * @param size Size of the data pointed to by md
+ */
int
g_metadata_store(const char *name, const unsigned char *md, size_t size)
{