Message ID | 1538265378-20544-2-git-send-email-schmitzmic@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Amiga RDB partition support fixes | expand |
On Sep 30 2018, Michael Schmitz <schmitzmic@gmail.com> wrote: > @@ -100,17 +101,17 @@ int amiga_partition(struct parsed_partitions *state) > > /* Tell Kernel about it */ > > - nr_sects = (be32_to_cpu(pb->pb_Environment[10]) + 1 - > - be32_to_cpu(pb->pb_Environment[9])) * > + nr_sects = (sector_t) ((be32_to_cpu(pb->pb_Environment[10]) > + + 1 - be32_to_cpu(pb->pb_Environment[9])) * > be32_to_cpu(pb->pb_Environment[3]) * > be32_to_cpu(pb->pb_Environment[5]) * > - blksize; > + blksize); That doesn't fix any signed int overflow. If you want to do calculation in sector_t you need to cast at least one operand to sector_t. In this form the cast is useless. Andreas.
Thanks Andreas, it appears I already made the same error in v2 of this series. My bad. I'll wait for a few more comments before respinning. Cheers, Michael Am 30.09.2018 um 19:16 schrieb Andreas Schwab: > On Sep 30 2018, Michael Schmitz <schmitzmic@gmail.com> wrote: > >> @@ -100,17 +101,17 @@ int amiga_partition(struct parsed_partitions *state) >> >> /* Tell Kernel about it */ >> >> - nr_sects = (be32_to_cpu(pb->pb_Environment[10]) + 1 - >> - be32_to_cpu(pb->pb_Environment[9])) * >> + nr_sects = (sector_t) ((be32_to_cpu(pb->pb_Environment[10]) >> + + 1 - be32_to_cpu(pb->pb_Environment[9])) * >> be32_to_cpu(pb->pb_Environment[3]) * >> be32_to_cpu(pb->pb_Environment[5]) * >> - blksize; >> + blksize); > > That doesn't fix any signed int overflow. If you want to do calculation > in sector_t you need to cast at least one operand to sector_t. In this > form the cast is useless. > > Andreas. >
diff --git a/block/partitions/amiga.c b/block/partitions/amiga.c index 5609366..902ddeb 100644 --- a/block/partitions/amiga.c +++ b/block/partitions/amiga.c @@ -32,7 +32,8 @@ int amiga_partition(struct parsed_partitions *state) unsigned char *data; struct RigidDiskBlock *rdb; struct PartitionBlock *pb; - int start_sect, nr_sects, blk, part, res = 0; + sector_t start_sect, nr_sects; + int blk, part, res = 0; int blksize = 1; /* Multiplier for disk block size */ int slot = 1; char b[BDEVNAME_SIZE]; @@ -100,17 +101,17 @@ int amiga_partition(struct parsed_partitions *state) /* Tell Kernel about it */ - nr_sects = (be32_to_cpu(pb->pb_Environment[10]) + 1 - - be32_to_cpu(pb->pb_Environment[9])) * + nr_sects = (sector_t) ((be32_to_cpu(pb->pb_Environment[10]) + + 1 - be32_to_cpu(pb->pb_Environment[9])) * be32_to_cpu(pb->pb_Environment[3]) * be32_to_cpu(pb->pb_Environment[5]) * - blksize; + blksize); if (!nr_sects) continue; - start_sect = be32_to_cpu(pb->pb_Environment[9]) * + start_sect = (sector_t) (be32_to_cpu(pb->pb_Environment[9]) * be32_to_cpu(pb->pb_Environment[3]) * be32_to_cpu(pb->pb_Environment[5]) * - blksize; + blksize); put_partition(state,slot++,start_sect,nr_sects); { /* Be even more informative to aid mounting */