All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: P J P <ppandit@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
	John Snow <jsnow@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH] ide: set an upper limit to nb_sectors
Date: Tue, 19 Jan 2021 15:13:10 +0100	[thread overview]
Message-ID: <b0198f13-c5af-70c5-59cb-c34bac328b83@redhat.com> (raw)
In-Reply-To: <20210119134211.494133-1-ppandit@redhat.com>

Hi Prasad,

On 1/19/21 2:42 PM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
> 
> Set an upper limit to number of sectors on an IDE disk media.
> This is to ensure that logical block addresses (LBA) and
> nb_sector arguments remain within INT_MAX range.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
>  hw/ide/core.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> Update: limit s->nb_sectors count
>   -> https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04270.html
>   -> https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04173.html
> 
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index b49e4cfbc6..064998804a 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -1161,15 +1161,21 @@ static void ide_cfata_metadata_write(IDEState *s)
>                                      s->nsector << 9), 0x200 - 2));
>  }
> 
> +static void ide_set_nb_sectors(IDEState *s)
> +{
> +    uint64_t nb_sectors;
> +
> +    blk_get_geometry(s->blk, &nb_sectors);

       /* An explanation here would be useful */

or better, add a self-explaining definition for this magic value.

> +    s->nb_sectors = MIN(nb_sectors, (uint64_t)INT_MAX << 2);
> +}



      reply	other threads:[~2021-01-19 14:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 13:42 [PATCH] ide: set an upper limit to nb_sectors P J P
2021-01-19 14:13 ` Philippe Mathieu-Daudé [this message]

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=b0198f13-c5af-70c5-59cb-c34bac328b83@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.