super1: fix Floating point exception
PATCH 1/1 super1: fix Floating point exception
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 <[email protected]>
--- super1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
super1.c +4 -1
@@ -2683,7 +2683,10 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update updateinit_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 ;
Signature · 1 line
2.29.2
resend: [PATCH mdadm] super1: fix Floating point exception
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 <[email protected]>
--- super1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
super1.c +4 -1
@@ -2683,7 +2683,10 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update updateinit_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 ;
Signature · 1 line
2.29.2
Jes Sorensen
AppliedQuoted 11 lines · Zhao Heming
write_bitmap1didn't check return value oflocate_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) ```
Quoted 4 lines
Signed-off-by Zhao Heming <[email protected]>--- super1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Applied!
Thanks,
Jes