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=1796389295; b=o9Ht3VLBAPeCJe4Hlga93Q68t1zlBDmyshfhpYZXkI7CzVtRbDcS18rnsRhkdoJzX7Bc 5kAbxjrWm34LAuKAz3cAWhuEFo3Jkd5vXyFE0YD7I1f/ntzmhemLHeRWN9R969gPK4JFM dYaW76Ar83FpSHZ+ve138U+pAF6gGOTocA65+1UfEIYSCxXzessvD/LPzTr3OdGjeq6Fo Td1fGf8uTaaR3GjZM09Vl0jYphoaJoPNNB8/RzLrHiOVxF+opnJa9e9o9UZ5FBOoUfXYT zdxUwlpXhHw+Xzg4bJ+3vk1UjgpN5V+o4b/ICsH3zFkecoQKE0g/+Uti2ZDF/R3s8kg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389295; 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=1AXumM+ncKEY0EkeiJg7x7Ad3xPPmMUbF2+rzGJ4tFA=; b=KDQJyCDyIEGhUot6h93uBjfa/gkFPJMEtE2Np2PaeNFeAagksuTLSJwN4doLgb3AoWbQ Tikl+KFSy+b0t+n4Xg96UYgrDeLlvuT5t/qnx+VYZXRCTxLHNlJGRHT3YWXg9QueAG8U1 X1LXEfrzvKcv0VYUWoMVgSEUK/+4gOPcN7ZpZSjCoN9MjzyPr/nug6krhR1R/4aH/AZxN tdvuYCPyDHyIJsZXnHitoHyzsieQ87Mbc+CuH0LS0lkC+I4Nvh7ebW3uUWo0QHBRh2BFK 3xC/BkRbLiUJ5QA5yg9lk0AK31CHcsqgxTsJK4G06SvUw4dnWCrl2q0rwKUyhfW8wCw== 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=O2akR1+o; 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 3F429606A330; Fri, 4 Dec 2026 13:01:35 +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=O2akR1+o Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F3931F000C2; Fri, 4 Dec 2026 13:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389294; bh=1AXumM+ncKEY0EkeiJg7x7Ad3xPPmMUbF2+rzGJ4tFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=O2akR1+oqaw0ceLPHgoATJdgJzQ9VYJsvOf4ntaSg1Iuq+/lZARcFaRxMVC8Wv6Yh YyLEOf11w5PmKXKBIFV6SYq/f/VjOpUSJXSFlMzLGTwTeuos3AOhce1XNh+pP4QLfx UZ0Cf7lG3wCEfYH2h6UtaGKaTcy8zv3XRSsJv51w= 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.1 0939/1059] gpio: virtio: compute the line names size in a size_t Date: Fri, 4 Dec 2026 19:07:50 +0900 Message-ID: <20261204100708.347413336@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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;