QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] acpi: pcihp: fix left shift undefined behavior in acpi_pcihp_eject_slot()
Date: Thu, 26 Mar 2020 09:58:39 -0400
Message-ID: <20200326095830-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20200326135624.32464-1-imammedo@redhat.com>

On Thu, Mar 26, 2020 at 09:56:24AM -0400, Igor Mammedov wrote:
> Coverity spots subj in following guest triggered code path
>   pci_write(, data = 0) -> acpi_pcihp_eject_slot(,slots = 0)
>      uinst32_t slot = ctz32(slots)
>      ...
>      ... = ~(1U << slot)
> where 'slot' value is 32 in case 'slots' bitmap is empty.
> 'slots' is a bitmap and empty one shouldn't  do anything
> so return early doing nothing if resulted slot value is
> not valid (i.e. not in 0-31 range)
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

tagged, thanks!

> ---
>  hw/acpi/pcihp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 4dcef372bf..0dc963e983 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -154,7 +154,7 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
>  
>      trace_acpi_pci_eject_slot(bsel, slot);
>  
> -    if (!bus) {
> +    if (!bus || slot > 31) {
>          return;
>      }
>  
> -- 
> 2.18.1



      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 13:56 Igor Mammedov
2020-03-26 13:58 ` Michael S. Tsirkin [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=20200326095830-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git