Re: [PATCH v5 1/2] block: fix signed int overflow in Amiga partition support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

On Sat, Oct 13, 2018 at 4:46 AM Michael Schmitz <schmitzmic@xxxxxxxxx> wrote:
> Am 12.10.2018 um 21:59 schrieb Geert Uytterhoeven:
> >> Changes from v4:
> >>
> >> Andreas Schwab:
> >> - correct cast to sector_t in sector address calculations
> >
> > Which you only did for the first case...
> >
> >> --- a/block/partitions/amiga.c
> >> +++ b/block/partitions/amiga.c
> >
> >> @@ -100,14 +101,14 @@ 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])
> >
> > ...here ...
> >
> >> +                          + 1 - be32_to_cpu(pb->pb_Environment[9])) *
> >>                            be32_to_cpu(pb->pb_Environment[3]) *
> >>                            be32_to_cpu(pb->pb_Environment[5]) *
> >>                            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]) *
> >
> > ... but not here?
>
> I meant to cast the first operand to sector_t here?

Silly me.

> But I can add brackets if you think the compiler might get this wrong.

No it's fine as-is.

Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>


Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux