From patchwork Fri Mar 7 15:06:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 871197 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp811096wri; Fri, 7 Mar 2025 07:12:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXldtrBVfuARFzmgRlC6A2i3VT7sQ5cBegEdDxFLTJzA0eomh4wsvON7FC3d34gBRlo4btQCA==@linaro.org X-Google-Smtp-Source: AGHT+IGdQ3sTMcxe5Icx2gD9i2Sol2yamLpVCh0m/y94EL1ToqQ8UAF/KfuxI7vFZXFBLRMHkvDf X-Received: by 2002:a05:6102:2927:b0:4c1:83c4:8562 with SMTP id ada2fe7eead31-4c30a619ce9mr2372536137.13.1741360363150; Fri, 07 Mar 2025 07:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741360363; cv=none; d=google.com; s=arc-20240605; b=PoqpqWBL5KO3dW8UcxPu5KK9WK8nDSiRTzHSfRMRCe5Hp5rDqb7TxQEfLiQckphYnI A7K5Fab1FkCoidL/nyjjBnQJzVYZJqIw77EjfpqwjrO1v1qabVLdvKfrrDQeNcuZhGbZ tXHVnMbzUvGTU3EMqwGiOePQWLG2wmG9ONlkOycKgJXjmP4MbTbHtW0QFr6P+ehK7Kiv 5ObnRKgG31nXSIaiKI/XnrSvTd3kyGziwp4/RNPVM2ENnEB55ojBztHrXiXgsAuwCwMo t9MDYQiJFiJ3h1XRJc9rzsGnn2HSz64lD5TJPQ17mOXppAQ9s3RnR+H8VuOUoVhT74Qp O6tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=dJa7xFMSJ9Cj8sAYI9y1hV/NskVbtE4S9vRHsNQbdj8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=hf1nUpgCpgGfYlKKxib9y/Gs5OZJzPTt+8/OFy7IsyURn8mrYF5vEv9i5JTkGY9Hlp 49B9yKL46Ruclz6k1gkiQCaVrpncCIVquNfJ7jkEL+gS4qWgVEe9R5SCHAZeTfRhpoDd sXRw08o/y5ufCBqjArEDVKw+kfbcjZ562us9BZfJ8qMqbmY2cRbM3uDi0bP/OSqNRmyp RYGtAC7jbbGslLJspLfRMl44rJAKei6AjfQdNFYw3J4QsFGONFlS+H0uHat3k/t0yLtg aC4G9elBN5k3onCZNeXXxfcBYkTKAbWMBehDiNVunOAYSQjwxlruLxDnMJdPGes14pE+ 6cHw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSrxlXKZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-86d33c97d84si791099241.118.2025.03.07.07.12.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 07:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSrxlXKZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqZIJ-0000w0-Vo; Fri, 07 Mar 2025 10:07:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqZIF-0000us-9C for qemu-devel@nongnu.org; Fri, 07 Mar 2025 10:07:20 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqZIC-000898-7i for qemu-devel@nongnu.org; Fri, 07 Mar 2025 10:07:18 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-390cf7458f5so1927703f8f.2 for ; Fri, 07 Mar 2025 07:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741360034; x=1741964834; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dJa7xFMSJ9Cj8sAYI9y1hV/NskVbtE4S9vRHsNQbdj8=; b=XSrxlXKZDWZghH/3DjN+v7VrXSUicoODJzOBNQUNbkH8n9JW9D5UllUJJw5GBnFRNF xUdYs2pYnm1PWhLxgGCfPvF1+zlBKWVdHs6RvGD0x5RfJsBV4EEARMGpNls1ymFI8xR+ QPodK6eWVZWoXqfAfwlpwevuOArkn/wIcN6msUZvRSnEa5rUWWg+iSAjR2V0Gb0EOvEw q7CEX/P9z0HQd+oFNAwpGhA3PTRiv7uq935zN2rgl+jIKXIuX7TQc3PDKEarYeVj6PZ7 Ct7wh7NvxlbhZwgaeddPvsbvcZNBaSV8xe4QKwaPFCyyJxyq8XzCTe+qhwJS31kEknVY ARYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741360034; x=1741964834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dJa7xFMSJ9Cj8sAYI9y1hV/NskVbtE4S9vRHsNQbdj8=; b=PVwUCa4Ikzz0xX+r/SSBTCFxWZ2qLHoIGBoosr23zByCJcks6CivJF0RBxyKvQCPKN ejUa1yY11FkwNAFTXgyqJ0CJrnjYT/TgIYcd1w21g4MjkpSdWV2Hxse8TIqGfSC6zHrt xmU6gxQoSGZsLYeAhvRseLTnqjsSjg4/t48SpUOnLRyF49cjgEijb3G1DGbUSk7ahf/K 3fO2y5SRcVmHnTF3ed824TgHlyaHg0jgJVcor/GZ0QopYT7gbbECSzuaEFFAAxi2MtQi J/i+918QBtkREsLgzq/smnz0J9zTDTmHt95yBWqDUbAgarrofbgURsd3gbR5EO2Sa2Ys cTxQ== X-Gm-Message-State: AOJu0YyvXsJgn4lnDmMKEhzuL7+4VkAhrNHVo0fPSW+jD8OC1qWv/vRr M5CSVt+W5zuEB3lerKAvG16CQ3L+8ol7RQ3xEBnQhvz7yXE86iZW3bUrO1qB8ZKZaOZKW55viw0 x X-Gm-Gg: ASbGnctgfVp/ATlXDSLDzEU52uk9zpeH8FMgHNXUJaEVD+Y67SwFcBhE1CUB4qxt4iq pquYMOW44R8VCoYNDwT87UeMS9IqS7tFVvvj+oQCDjz2IE0jzjOuxMNWthrSd6DV5I0lAeOxCsv 3CgBLowN+/yA8MpeOVbmdzBfrzc4d84NRMaZwtiMfLhmU3b0TL6IFdMPbdqA8ZZ4E8UmVHEoj74 EbmZjJdOsyYXvKqf2jH91lwMytq/PO2n33irygIH+yCrlMdzND2cNjgaENGlwAiEcB4dT1fyTHC Rdhb5sRxOesUhpQ2yKsUbbAVVwHGGBYbD4KG1i1TISdmvFfgr1E= X-Received: by 2002:a5d:6d0f:0:b0:390:e46f:4454 with SMTP id ffacd0b85a97d-39132d72c52mr3186094f8f.32.1741360033505; Fri, 07 Mar 2025 07:07:13 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c1031fdsm5443627f8f.89.2025.03.07.07.07.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 07:07:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/21] hw/gpio: npcm7xx: fixup out-of-bounds access Date: Fri, 7 Mar 2025 15:06:49 +0000 Message-ID: <20250307150708.3222813-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307150708.3222813-1-peter.maydell@linaro.org> References: <20250307150708.3222813-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Patrick Venture The reg isn't validated to be a possible register before it's dereferenced for one case. The mmio space registered for the gpio device is 4KiB but there aren't that many registers in the struct. Cc: qemu-stable@nongnu.org Fixes: 526dbbe0874 ("hw/gpio: Add GPIO model for Nuvoton NPCM7xx") Signed-off-by: Patrick Venture Reviewed-by: Philippe Mathieu-Daudé Message-id: 20250226024603.493148-1-venture@google.com Signed-off-by: Peter Maydell --- hw/gpio/npcm7xx_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c index 23e67424c9f..2916056fae6 100644 --- a/hw/gpio/npcm7xx_gpio.c +++ b/hw/gpio/npcm7xx_gpio.c @@ -220,8 +220,6 @@ static void npcm7xx_gpio_regs_write(void *opaque, hwaddr addr, uint64_t v, return; } - diff = s->regs[reg] ^ value; - switch (reg) { case NPCM7XX_GPIO_TLOCK1: case NPCM7XX_GPIO_TLOCK2: @@ -242,6 +240,7 @@ static void npcm7xx_gpio_regs_write(void *opaque, hwaddr addr, uint64_t v, case NPCM7XX_GPIO_PU: case NPCM7XX_GPIO_PD: case NPCM7XX_GPIO_IEM: + diff = s->regs[reg] ^ value; s->regs[reg] = value; npcm7xx_gpio_update_pins(s, diff); break;