From: Jes Sorensen Date: Wed, 6 Apr 2016 20:13:59 +0000 (-0400) Subject: super1: Clear memory allocated for superblock + bitmap before use X-Git-Tag: mdadm-4.0~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dcee1c9cbcf9592275914706b76b1931490092c;p=thirdparty%2Fmdadm.git super1: Clear memory allocated for superblock + bitmap before use load_super1() did not clear memory allocated for the superblock + bitmap. This causes issues if the superblock does not contain a bitmap as later checks of bitmap features would rely on the bits being cleared. This bug has been around for a long time, but was only exposed in mdadm-3.4 with the introduction of the clustering code. Reported-by: Jan Stodola Signed-off-by: Jes Sorensen --- diff --git a/super1.c b/super1.c index d6f3c936..8d5543f7 100644 --- a/super1.c +++ b/super1.c @@ -2016,6 +2016,8 @@ static int load_super1(struct supertype *st, int fd, char *devname) return 1; } + memset(super, 0, SUPER1_SIZE); + if (aread(&afd, super, MAX_SB_SIZE) != MAX_SB_SIZE) { if (devname) pr_err("Cannot read superblock on %s\n",