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=1796382399; b=oMDmy1OuQ9r6n/AVnm+nbjdVeEMzlcjDFlgLj9tQZGbEWhipGk853GcWlyizGWS2lv9g Hzjve5ef/R8zV/jI6rQu7l4p9W9uzxBuJhHt4/Q+wXFE63kymSEw47bO7phq8n+gliqev S8HmLAmpdlstEQWN/jgtQ9rk7veAnEDTvE03n6yHDvNLyOSXohxliLHDxYomzX24tykb+ 9h4Pgv6rM2QvGF89NQwjJKakex583ksA4/SPDkkyMpScdAl4n64m1yfbQgb0N+PF1RMzW AXOBJaHWp40hKRNI9uY6lvvkeqCKsMzRf19t+SYct22MLgoJOeIa0smBjabNB01AwHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382399; 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=80BzAUanLm/oOTmv8KfmpfskIKZA7U7w7wJmYYGRWhk=; b=NDCc9iLn5/O98F6aQ/CShCfu+N+hc1r8J8PccipXVvhPD/ZJWsCY7jgjJi+hgoHB/P7X MFrfmBxEmiNYLgOmeJPsLBeVBfCCKO9l5nQT7JCo+YNbyDGzl3yxW8o54XaZfMWfxJpZr evq7xfelqJPsmE+kzWK6UPRnRGUIkW4Ws6DHcjM8dr3SYhjAd4Cu33pnO+xhgwGYnLtMk Xv++pu1K4elAqdqzDRTfNt4Jwv9blSe1XlO2wEdmV9kklkSD+P70EsbKKEU69BrqVCyM0 Jr6eAKlDqZBGWn/obR8dDPtUhatuofLw25NdTfvwrXwn2G7WlVakH+nBwOSi98yBA4g== 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=f4cDpttw; 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 C8E6B606A333; Fri, 4 Dec 2026 11:06:39 +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=f4cDpttw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EEEF1F00897; Fri, 4 Dec 2026 11:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382399; bh=80BzAUanLm/oOTmv8KfmpfskIKZA7U7w7wJmYYGRWhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f4cDpttw1J9v1Lh7ixFoOjq8xddms3mmn4nz44P1wLngbFPRNjKbcY0yjD+aDywem HENvTm9aoBZqqPSYqB+21uTTVEjBoBjeJjjg+bGG2iFK1l6Lef8EOCbC8GtI6JVT5V hVXXp8uxFp6pZNraM/q2MP30q9h/fHMyc95PWBLA= 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.18 436/703] gpio: virtio: compute the line names size in a size_t Date: Fri, 4 Dec 2026 19:05:35 +0900 Message-ID: <20261204100639.413962143@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -487,12 +487,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;