From nobody Fri Nov 14 05:13:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585231037; cv=none; d=zohomail.com; s=zohoarc; b=R85ib+m/tiQe+DRMjiPAaIsOPpPXgAvGUvtx1IW34inrm1L/YdYnS96cES1rZ+/v9YQK2up77AfCV/kow4bYoiU8YH7Des0geGy8Uzki4AJPmox8dd5p1rI09htM24r/T0K1wWZY4YUIM2WTv2oSzIbp7Cc5ZhyKYr+qtAh91CI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585231037; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=fxngKB3n3H/APZAzYheqOCIOrULfa5FCCSkY14DVWqg=; b=b6odGowuv8juiLrq/QCCwU099blLjc+3rLqGeeIfFX+LZYzOEfrooB2TROy+4RtOQqxs52vukAHOlRYzhCEpaXEGVhx/mwgGlK2s8hPsSR/e/qiiCv/bapdeUQMmgkRRdDO5vkRktjssyJ5MlMcIP47bDFinXNmNpL3J+fMa0FA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585231037438541.1639592152561; Thu, 26 Mar 2020 06:57:17 -0700 (PDT) Received: from localhost ([::1]:52246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHT0W-0004uf-5p for importer@patchew.org; Thu, 26 Mar 2020 09:57:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60361) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHSzr-0004TH-TH for qemu-devel@nongnu.org; Thu, 26 Mar 2020 09:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHSzq-00088z-VS for qemu-devel@nongnu.org; Thu, 26 Mar 2020 09:56:35 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:43830) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHSzq-00088q-S3 for qemu-devel@nongnu.org; Thu, 26 Mar 2020 09:56:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-6pl3JBfnMwij3qs-iit3RA-1; Thu, 26 Mar 2020 09:56:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 829BD189F763; Thu, 26 Mar 2020 13:56:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DFE646; Thu, 26 Mar 2020 13:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585230994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fxngKB3n3H/APZAzYheqOCIOrULfa5FCCSkY14DVWqg=; b=hY2SWZYZHqU+oA7MsOe8rANtcg6dwKPY15mG+0677/3rWPUkgocU41MS7MRioiQ+mdiMGw 9duL2Pj5dSnBoaEhwsIBzC8fobrRE6FoABXUKmpgGmOG1dxWMGsQIg79dyNyRbCy5OLPUe YaP/LtE8BMU0zD+C1uIL4jI4vQpmrTM= X-MC-Unique: 6pl3JBfnMwij3qs-iit3RA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH] acpi: pcihp: fix left shift undefined behavior in acpi_pcihp_eject_slot() Date: Thu, 26 Mar 2020 09:56:24 -0400 Message-Id: <20200326135624.32464-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Coverity spots subj in following guest triggered code path pci_write(, data =3D 0) -> acpi_pcihp_eject_slot(,slots =3D 0) uinst32_t slot =3D ctz32(slots) ... ... =3D ~(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 Signed-off-by: Igor Mammedov --- 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, un= signed bsel, unsigned slo =20 trace_acpi_pci_eject_slot(bsel, slot); =20 - if (!bus) { + if (!bus || slot > 31) { return; } =20 --=20 2.18.1