* [PATCH/mdadm] super1: Fix bblog_size accesses on big-ending machines.
@ 2016-01-29 1:35 NeilBrown
2016-02-02 12:20 ` Jes Sorensen
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2016-01-29 1:35 UTC (permalink / raw)
To: Jes Sorensen; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]
bblog_size is 16bit so using le32_to_cpu on it is not wise
and leads to errors on big-endian machines.
Change all such calls to use le16.
Bug was introduced in mdadm-3.3
Signed-off-by: NeilBrown <neilb@suse.com>
---
Hi Jes,
when you are ready to start queuing patches for mdadm, this will make
sure you have something to work with:-)
Thanks,
NeilBrown
super1.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/super1.c b/super1.c
index 8bcaa2fe02c8..9b877e504c4b 100644
--- a/super1.c
+++ b/super1.c
@@ -730,12 +730,12 @@ static int copy_metadata1(struct supertype *st, int from, int to)
}
if (super.bblog_size != 0 &&
- __le32_to_cpu(super.bblog_size) <= 100 &&
+ __le16_to_cpu(super.bblog_size) <= 100 &&
super.bblog_offset != 0 &&
(super.feature_map & __le32_to_cpu(MD_FEATURE_BAD_BLOCKS))) {
/* There is a bad block log */
unsigned long long bb_offset = sb_offset;
- int bytes = __le32_to_cpu(super.bblog_size) * 512;
+ int bytes = __le16_to_cpu(super.bblog_size) * 512;
int written = 0;
struct align_fd afrom, ato;
@@ -832,7 +832,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
__u64 *bbl, *bbp;
int i;
- if (!sb->bblog_size || __le32_to_cpu(sb->bblog_size) > 100
+ if (!sb->bblog_size || __le16_to_cpu(sb->bblog_size) > 100
|| !sb->bblog_offset){
printf("No bad-blocks list configured on %s\n", devname);
return 0;
@@ -843,7 +843,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
return 0;
}
- size = __le32_to_cpu(sb->bblog_size)* 512;
+ size = __le16_to_cpu(sb->bblog_size)* 512;
if (posix_memalign((void**)&bbl, 4096, size) != 0) {
pr_err("could not allocate badblocks list\n");
return 0;
@@ -986,7 +986,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
if (sb->bblog_offset && sb->bblog_size) {
unsigned long long bbend = super_offset;
bbend += (int32_t)__le32_to_cpu(sb->bblog_offset);
- bbend += __le32_to_cpu(sb->bblog_size);
+ bbend += __le16_to_cpu(sb->bblog_size);
if (bbend > earliest)
earliest = bbend;
}
--
2.7.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH/mdadm] super1: Fix bblog_size accesses on big-ending machines.
2016-01-29 1:35 [PATCH/mdadm] super1: Fix bblog_size accesses on big-ending machines NeilBrown
@ 2016-02-02 12:20 ` Jes Sorensen
0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2016-02-02 12:20 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid
NeilBrown <neilb@suse.com> writes:
> bblog_size is 16bit so using le32_to_cpu on it is not wise
> and leads to errors on big-endian machines.
> Change all such calls to use le16.
>
> Bug was introduced in mdadm-3.3
>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>
> Hi Jes,
> when you are ready to start queuing patches for mdadm, this will make
> sure you have something to work with:-)
>
> Thanks,
> NeilBrown
Applied!
Thanks,
Jes
>
> super1.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/super1.c b/super1.c
> index 8bcaa2fe02c8..9b877e504c4b 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -730,12 +730,12 @@ static int copy_metadata1(struct supertype *st, int from, int to)
> }
>
> if (super.bblog_size != 0 &&
> - __le32_to_cpu(super.bblog_size) <= 100 &&
> + __le16_to_cpu(super.bblog_size) <= 100 &&
> super.bblog_offset != 0 &&
> (super.feature_map & __le32_to_cpu(MD_FEATURE_BAD_BLOCKS))) {
> /* There is a bad block log */
> unsigned long long bb_offset = sb_offset;
> - int bytes = __le32_to_cpu(super.bblog_size) * 512;
> + int bytes = __le16_to_cpu(super.bblog_size) * 512;
> int written = 0;
> struct align_fd afrom, ato;
>
> @@ -832,7 +832,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
> __u64 *bbl, *bbp;
> int i;
>
> - if (!sb->bblog_size || __le32_to_cpu(sb->bblog_size) > 100
> + if (!sb->bblog_size || __le16_to_cpu(sb->bblog_size) > 100
> || !sb->bblog_offset){
> printf("No bad-blocks list configured on %s\n", devname);
> return 0;
> @@ -843,7 +843,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
> return 0;
> }
>
> - size = __le32_to_cpu(sb->bblog_size)* 512;
> + size = __le16_to_cpu(sb->bblog_size)* 512;
> if (posix_memalign((void**)&bbl, 4096, size) != 0) {
> pr_err("could not allocate badblocks list\n");
> return 0;
> @@ -986,7 +986,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
> if (sb->bblog_offset && sb->bblog_size) {
> unsigned long long bbend = super_offset;
> bbend += (int32_t)__le32_to_cpu(sb->bblog_offset);
> - bbend += __le32_to_cpu(sb->bblog_size);
> + bbend += __le16_to_cpu(sb->bblog_size);
> if (bbend > earliest)
> earliest = bbend;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-02 12:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-29 1:35 [PATCH/mdadm] super1: Fix bblog_size accesses on big-ending machines NeilBrown
2016-02-02 12:20 ` Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).