From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 439673382E1; Mon, 20 Apr 2026 15:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776699878; cv=none; b=n5tqnyfmamCd439x5+d2R66OsvKbgviZrWxsNtBqK5d2UmNHr9Cnt7gVQHzFnE2A08fz8yjhlAkS2JbyAyGonr1C4LqFsV5ar6/O0b2XtDtKlSIVRNFpwUpjAh3yGXK4arMXBHugXmwcX1GLcNlXRn9alZk87vYCyr0KKfuogxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776699878; c=relaxed/simple; bh=PuieWxSLzPnvF9nTHuD8nE+1sMEFpXjh+2zrKCtpE+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NgieolLHmAstir50TSh/BmhOexl5gHsgDGRESOmi27cd3Vwzm2fpr8MRTIb+1HgagCqZgtq1RiZWicdW5bPpst9471BhzGBvePvJs9PCIn5HQ4FmDzw2ozfAetiYKDjbCufpH2RY+bM+RWLHXtuShHhCwxW2if3kLTxxCrHX5I0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RbPXqfL7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RbPXqfL7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94D31C2BCB4; Mon, 20 Apr 2026 15:44:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776699877; bh=PuieWxSLzPnvF9nTHuD8nE+1sMEFpXjh+2zrKCtpE+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbPXqfL78qdCd8xfC+bydV0D9XJWKFWJ1uITh8YE9R2LrNVcFVFekZAKzb4l/EyyE tUW4rSBJko35fSkWDv7f2UGz4fbBvLEPOaIPYo9WzPuBulHLvR+J8VkUf93s7fdRnO pS5kVGE0zGeUjhzybDnRyVUjproNrZxoTk5cSkVM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Krzysztof Kozlowski , Alim Akhtar , Andi Shyti , stable Subject: [PATCH 7.0 04/76] i2c: s3c24xx: check the size of the SMBUS message before using it Date: Mon, 20 Apr 2026 17:41:15 +0200 Message-ID: <20260420153910.976790329@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153910.810034134@linuxfoundation.org> References: <20260420153910.810034134@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman commit c0128c7157d639a931353ea344fb44aad6d6e17a upstream. The first byte of an i2c SMBUS message is the size, and it should be verified to ensure that it is in the range of 0..I2C_SMBUS_BLOCK_MAX before processing it. This is the same logic that was added in commit a6e04f05ce0b ("i2c: tegra: check msg length in SMBUS block read") to the i2c tegra driver. Cc: Krzysztof Kozlowski Cc: Alim Akhtar Cc: Andi Shyti Cc: stable Assisted-by: gkh_clanker_2000 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/2026022314-rely-scrubbed-4839@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-s3c2410.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -503,8 +503,13 @@ static void i2c_s3c_irq_nextbyte(struct i2c->msg->buf[i2c->msg_ptr++] = byte; /* Add actual length to read for smbus block read */ - if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) + if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) { + if (byte == 0 || byte > I2C_SMBUS_BLOCK_MAX) { + s3c24xx_i2c_stop(i2c, -EPROTO); + break; + } i2c->msg->len += byte; + } prepare_read: if (is_msglast(i2c)) { /* last byte of buffer */