public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Michael Schmitz <schmitzmic@gmail.com>
Cc: linux-block@vger.kernel.org,  axboe@kernel.dk,
	 linux-m68k@vger.kernel.org,  geert@linux-m68k.org
Subject: Re: [PATCH v4 1/2] block: fix signed int overflow in Amiga partition support
Date: Sun, 30 Sep 2018 08:16:58 +0200	[thread overview]
Message-ID: <m2pnwvmrvp.fsf@linux-m68k.org> (raw)
In-Reply-To: <1538265378-20544-2-git-send-email-schmitzmic@gmail.com> (Michael Schmitz's message of "Sun, 30 Sep 2018 12:56:17 +1300")

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.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2018-09-30  6:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 23:56 [PATCH v4 0/2] Amiga RDB partition support fixes Michael Schmitz
2018-09-29 23:56 ` [PATCH v4 1/2] block: fix signed int overflow in Amiga partition support Michael Schmitz
2018-09-30  6:16   ` Andreas Schwab [this message]
2018-10-01  4:27     ` Michael Schmitz
2018-09-29 23:56 ` [PATCH v4 2/2] block: add overflow checks for " Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2pnwvmrvp.fsf@linux-m68k.org \
    --to=schwab@linux-m68k.org \
    --cc=axboe@kernel.dk \
    --cc=geert@linux-m68k.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox