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=1796380968; b=iKQVQxtlo0LiMzgtxv7PFaJOBUI67e8Ib9Q22jV6YANPjGggobZp2ZAlDisD0LeIJ5Dm Ljmfekp+QC0hjnML51UBD57vjy5W+rH4gH9v4u1kPTyr7LlMR0YiD2DTxwVeAtFC+CPrw 2aSaSNmHYLJLeElkA0z0yLIyxeHgsHQcu7QX52BD785ym7qViOtHli/c78obOqqpdIP8U N/twMN79jcloqK13zh0pjTw+3EYnsJBIvHGbqrBd/rT/AbwBixYOtGtUm5Rl10qGMAHYQ B4ib2wllYlVjEuIEYbcnpTNOZPrVR+IXdaSJfbwnxRl+3KqBXqGKU2WOOZ1VERJWgFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380968; 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=9P2MhaTJSQbrAz9Iv5GVyCdyaxi/BIUaqkuqoX2MneE=; b=31Y3NDvg+ibOdSgobf5TRHdNzHd8jKzkCsWNVi6xDULhtietTIoYYRBfDtdyrGsyC5EV kvixvJugNpJZ9402rMlczXScRfsa6on9sIJKVLk3hKbz3nxjsGJJ9jHmYtU4YwtiR16rk hInb9KDBU3U4jIxMCO3ejheUH0R/W5GAFihQlxLEmRvQb/wKQpA5tGSIg0kfqIreP8jpy 4Q3p8Dvt7RmsRbW4+iD9oeZmXhAcu8ROS/lkRKDXoJ0d11L84WrGQ5bY71E2nCNxyvfUp t1Agk0mJxv1xVg4xKZUhOS5g4AYuyVb1dF/j4oSahqwRKFJQxxY2263HugmZSiOLkQA== 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=mRLNX8v+; 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 D1BAA606A32F; Fri, 4 Dec 2026 10:42:48 +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=mRLNX8v+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FA641F000CE; Fri, 4 Dec 2026 10:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380968; bh=9P2MhaTJSQbrAz9Iv5GVyCdyaxi/BIUaqkuqoX2MneE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mRLNX8v+Tw4XhVRNsRiMJ1uigeEwWdYMPYltsfBcoJUtXXr2oHd2mlXniCFGEjbqV 5mhklOHODoG4icJ7qTu64puJYe6WQwE18chb+Dm+TsteUAP0cW0fLAaf22kQq+4hg0 6HupSOWW9MSQuQpVMqJ3SUD3b3XYswVVTWxyL07g= 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 7.3 485/742] gpio: virtio: compute the line names size in a size_t Date: Fri, 4 Dec 2026 19:05:49 +0900 Message-ID: <20261204100648.021165617@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -494,12 +494,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;