From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383832; b=uS1LsDWYkwGyEWh/t/F0lK+SZqYhgs4vHROgrzn1n28/ttzVNX96sEWH/q8BCd9Nd+FO GOHUCjCOPw0fQSxG4M15uFRS4Ay+7QRbhCTA4tiv+FWh5+PGNDiR1yTfW1SGGvJRC6IKf Yk4pVsw/vhDD3vwV+IETUSPCSMxH4SsV5vlpShmWH1eqVfnS8DQ4dlSOP3pqwHXKTO0Fh tMzlAqXN3dCMrPP2k22JQOWNM2cl8twmKa/IoCTBUrdathtMtbS5FkNo9CntEFHgQvVr2 E5T9xVo9BoQzq8vaXQP3Qc+d0q2TCKRaheeS37UirWygnlVi6+5DL/0cQPd0bdnr+oQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383832; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=fPXBAwiZdjoPRn2hmbmXJfYsjE7lqKPOLOWXylqNk70=; b=tA0abjmKimSZpXgHDSYNxPZjesteYbkq5lxJzgyKHwVJE0VDNAH7zkul3nw2ztcT3OhH UHJykOo4K6jk19Tlm17Wi98dB4txzfT/ok4bVBTm0K3yCcL7mq5IUi3CuyolIwI2+oDMU DkXjIkqczMVi9ot0iHMVNCjo++GEmos5X5ZKRbJsMpiAc30PyGfnGFTrsm68cYgM39vV1 wy5aCMAZL1NeuFCRnWM2LbkWlUK9NkqZNGReAuJE4or+8WX9HyPDDhkVDomGVag3JYVhu x9jMol6bVXAzKUtdfuvd8kMIA6aBDWsGPpwuZxAjhgwwTo/Nm3uQHGWQ+MX3qyZMkGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="ev/Oeck6"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10656606A322; Fri, 4 Dec 2026 11:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ev/Oeck6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AB231F000C2; Fri, 4 Dec 2026 11:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383831; bh=fPXBAwiZdjoPRn2hmbmXJfYsjE7lqKPOLOWXylqNk70=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ev/Oeck6NvroAfdj9z9vrVwwLEW8NA2RMVX+pIAPo6d2JB6Em2NeF/27Yho5aqnR8 GP9FzKWaM1VY/vVaAPL6agRFXD9jhw/mMegkroC7dcVKU1/K0yYVcEkdmDi3q+nIOt qspw4OKFw5oRE4R3BS11IZMItqB43DjAlpwegyOo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lianjie Wang , Viresh Kumar , Bartosz Golaszewski Subject: [PATCH 6.12 387/555] gpio: virtio: compute the line names size in a size_t Date: Fri, 4 Dec 2026 19:07:10 +0900 Message-ID: <20261204100624.491773500@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lianjie Wang commit 9e3032dc4d92e6214ae687b4c474de9270ce74a2 upstream. virtio_gpio_get_names() computes the size of the GET_LINE_NAMES response as sizeof(*res) + gpio_names_size in an int, where gpio_names_size is a u32 from the config space. A gpio_names_size of 0xffffffff makes the size 0, devm_kzalloc() returns ZERO_SIZE_PTR, and reading the status byte of the response through it oopses: Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:_virtio_gpio_req+0x2b8/0x550 Call Trace: virtio_gpio_probe+0xc2a/0xfc0 virtio_dev_probe+0xa7a/0xc50 Compute the size with struct_size() into a size_t. Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver") Cc: stable@vger.kernel.org Signed-off-by: Lianjie Wang Acked-by: Viresh Kumar Link: https://patch.msgid.link/20261104195632.1702765-2-lian@is.s.u-tokyo.ac.jp Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-virtio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/gpio/gpio-virtio.c +++ b/drivers/gpio/gpio-virtio.c @@ -499,12 +499,13 @@ static const char **virtio_gpio_get_name struct device *dev = &vgpio->vdev->dev; u8 *gpio_names, *str; const char **names; - int i, ret, len; + size_t len; + int i, ret; if (!gpio_names_size) return NULL; - len = sizeof(*res) + gpio_names_size; + len = struct_size(res, value, gpio_names_size); res = devm_kzalloc(dev, len, GFP_KERNEL); if (!res) return NULL;