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=1796380981; b=hjTrEWE7QbUzYXC7KEu9REDqAieCBUyabH9/B4Br/lqh7h8VqRpPl2w/wVZrQXmjK5Wq j6DuUSG69sZnH+wkVQAZMrOtY+704m2WyJAEnbUU4e5QquDEfM7Jzdd7++0osJoTIw2UV EbVLwgnoYJjDq0V3k1upfPgRMHbhT4iK1CEOfmlVeV0an1vjFYrLZJPgz44/lcfE96cZu R6ndqpXFtq4aJQVNVjD1oKKlzK+2LWrhfD6XGVnlk9tllSE6ZdDWUlTZ/c/RdgUf/fsiR gTt+UMcNYwBJvXCGqxN2e3Vv56991mQFUnqN+GHGqAXv6YLuA9PooJPWKtzylpqnJjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380981; 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=/W71zHXUMgZ3Nc5JXWDShid/dMCXlZqRDO37TyLj5EQ=; b=GHz8Imd2u4fnBm45WqTXyv3rS5zLNgc5Ek8dFIOQmoy0qK9JvBfH9PJKQDVteV2G0LXt XT+HyvGuKVcl/pZejLQwplPw6F98yAG8ZcHSGcn6bB2EP6CQCMRaQ1TLcSs0Ob9JFAdNT Na/9qpGJrZjI2bL+eY6KS/k9+xSNoY5VOvRsxdBykbZLSJ4yG9sThAKfNKhc5NGzZp2VO iO+nP9xeVsfd0UfXezjLgzc1PXYMvJ750ePco+cjQaTGYkzoIWt9BkILb0sy6eNaLhtxJ b68vL90AjOfVXfNuT2SCoKiqlgXVJiQCjt6wKsW67qwbOtQLS5eeDIu/aCkB2yCnk6w== 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=VUxp4NcQ; 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 D58F2606A330; Fri, 4 Dec 2026 10:43:01 +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=VUxp4NcQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF2D51F000C2; Fri, 4 Dec 2026 10:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380981; bh=/W71zHXUMgZ3Nc5JXWDShid/dMCXlZqRDO37TyLj5EQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VUxp4NcQZaSGcaUFv4lAsRj3uLCjsxnT1yKwP0hObrChN5AVPYLKO01JuigJINFzk X1dquLptK7cIqgACbNUZQn8LjVSVJ+gYDF1cCuKDw7WaXBKmwmmULCxzroaEYThfhN mhhkpcJk/HDSzsYC1AUsMSFhqVgtTv1rxHzoogEI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liu Chao , Dmitry Torokhov Subject: [PATCH 7.3 507/742] Input: goodix - reject a bak_ref length that cannot hold the checksum Date: Fri, 4 Dec 2026 19:06:11 +0900 Message-ID: <20261204100648.610246597@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: 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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liu Chao commit b3249e446d47c65dc09611705ad4d0a7587405ac upstream. driver_num and sensor_num are taken from the touchscreen config. A config with driver_num 1 and sensor_num 0 yields a bak_ref length of 0, for which devm_kzalloc() returns ZERO_SIZE_PTR. That pointer passes the !ts->bak_ref check and the subsequent ts->bak_ref[ts->bak_ref_len - 1] = 1 writes before the allocation. Reject a length that leaves no room for the trailing checksum before allocating, and skip saving a bak_ref that was never allocated. Without the second check a rejected length leaves bak_ref NULL while bak_ref_len still holds the bogus value, and goodix_save_bak_ref() then writes through the same index on suspend. Fixes: 09182ed20c04 ("Input: goodix - add support for controllers without flash") Cc: stable@vger.kernel.org Signed-off-by: Liu Chao Link: https://patch.msgid.link/20261106075129.3106093-1-liuc63@xiaopeng.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/touchscreen/goodix_fwupload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/input/touchscreen/goodix_fwupload.c +++ b/drivers/input/touchscreen/goodix_fwupload.c @@ -281,6 +281,8 @@ static int goodix_prepare_bak_ref(struct driver_num, sensor_num, have_key); ts->bak_ref_len = (driver_num * (sensor_num - 2) + 2) * 2; + if (ts->bak_ref_len < 2) + return -EINVAL; ts->bak_ref = devm_kzalloc(&ts->client->dev, ts->bak_ref_len, GFP_KERNEL); @@ -409,7 +411,7 @@ void goodix_save_bak_ref(struct goodix_t int error; u8 val; - if (!ts->firmware_name) + if (!ts->firmware_name || !ts->bak_ref) return; error = goodix_i2c_read(ts->client, GOODIX_REG_STATUS, &val, 1);