Thread (3 messages) flat view 3 messages, 2 authors, 2021-03-04
STALE2020d

[PATCH] super1: fix Floating point exception

From: Zhao Heming <hidden>
Date: 2021-01-30 09:52:24
Subsystem: the rest · Maintainer: Linus Torvalds

write_bitmap1 didn't check return value of locate_bitmap1, which will
operate bitmap area under invalid bitmap info.

mdadm core dumped when doing below steps:
node1 # mdadm -C /dev/md0 -b none -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb
node1 # mdadm -Ss
node1 # mdadm -A -U home-cluster --home-cluster=abc /dev/md0 /dev/sda /dev/sdb
Floating point exception (core dumped)
Signed-off-by: Zhao Heming <redacted>
---
 super1.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/super1.c b/super1.c
index 8b0d6ff..19fe6f5 100644
--- a/super1.c
+++ b/super1.c
@@ -2683,7 +2683,10 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
 
 	init_afd(&afd, fd);
 
-	locate_bitmap1(st, fd, 0);
+	if (locate_bitmap1(st, fd, 0) < 0) {
+		pr_err("Error: Invalid bitmap\n");
+		return -EINVAL;
+	}
 
 	if (posix_memalign(&buf, 4096, 4096))
 		return -ENOMEM;
-- 
2.29.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help