Message ID | 20230314165421.2823691-1-harperchen1110@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1880083wrd; Tue, 14 Mar 2023 10:12:37 -0700 (PDT) X-Google-Smtp-Source: AK7set/Mv/UEYKupwWPNr3MUnkdPjPoM4SAtWaTfF2bpPpXes1wR67wdU/wCjXHTWQBxd0ibJmJT X-Received: by 2002:a05:6a20:6925:b0:bf:8a97:6e48 with SMTP id q37-20020a056a20692500b000bf8a976e48mr34682099pzj.37.1678813956955; Tue, 14 Mar 2023 10:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678813956; cv=none; d=google.com; s=arc-20160816; b=Z9+NhiX01ZH50gho7aIV1eVQv4QKvEaZkCG9cyWMUTGDdt8EaKKuHGae+jeCiTe9qj 5rF62I465qquVQeo5fp8TtFHScVEmOGjU10Z6T1Zh0b3oW/miiBv4f9pFDhEaonu8R+W o8/Cm/o1QTFajckRerjcxL2S95xUnC+S+0YKF1GHLDES+JSLehngkzNasc27YEcXbKuj O9XGT0Iuvhq1fAkb/CvYPVm09sSOvEteCrZhNsSVeocWYs/nfmhWE8Yx6O6mGqkb96wA BrM22VQH66bdJBzhLPdtmbB6oR5d4f1LxmT0HeFL4lie3mXkTtSkqM4nw8bJyyGf7Qi+ XHyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EonhBFpRiqDdLBEHZpZFnmSI1fVQAggjhLPOkfzboxU=; b=RshwQo41PDDELXCW/k/mRw4808ctcTl8tWPR1CBXK8nAPu+E1tgzX2wIZXZeC4TboY wIQSXroZv7KkyFxCrxtSqwNm4CsplLt7LONzZsk3RIf72PA4MwWbJr2JaGMWGe2WmhP5 J3J+xRVmRKbX3tzAYqOD/n1hgkqgC6/2dcgoQx3Oq9OttG5kiI7x8Q1wxlNt7nJINUsj NHL8B/185axjXQ5mo4bFhogOMD8Wp0v4JaLYnIw/vGzubOQV2kPwOTp1eIr34pUfgGFk l3lysKbalS7bhnK/wITFPO5GgRKiN+YPULjcGDt9fcvMPKtU92Xx0ose89KL7jNhFAOW bW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GuoqaT0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a6540cb000000b00502ece2f57dsi2573887pgp.655.2023.03.14.10.12.21; Tue, 14 Mar 2023 10:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GuoqaT0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjCNQyc (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Tue, 14 Mar 2023 12:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjCNQya (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Mar 2023 12:54:30 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8720665C7D; Tue, 14 Mar 2023 09:54:28 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id a4-20020a056830008400b0069432af1380so8732614oto.13; Tue, 14 Mar 2023 09:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678812868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EonhBFpRiqDdLBEHZpZFnmSI1fVQAggjhLPOkfzboxU=; b=GuoqaT0ezIyiRlJ3FdQWwOTI1X530tBwzC970F6RfB+Bfx8PoriAp7ZVm+6yaPInDj 3TzgvnQTVasY62fklUd3uMQdNDD0qwgQkOPXdHBRo70mtdQebaz/NTqOsWDkj4JEASPL 7nmVkNlzpZhwU+6pijbaFFpyp73sxO3jX+MDechRyakZeXAG3Z7M2hXzAGjgoBvqxiNh lEzhnrTXc3PM4pMZ1bdSH0gJtd+oNQaDlYSyxoc9VzKcxo5YVYI0jwoM9WrvVUF4Pgij pYblBZ1TjYSh9IwkAVzQG5LJlLihUD1uxMLgQ2O6NcWsT47d3t97dmKKrMPBfG6gsTMU y2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678812868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EonhBFpRiqDdLBEHZpZFnmSI1fVQAggjhLPOkfzboxU=; b=cWPhZ1p4ogLAwZ5l7fMTinJxU/XyCZaqIedcLTCXdhkMqUCYCCntYdaMdWfa4vFnBL 0bf2mVsw8HFJQB0GB4Hn/IjAl6DBYs/B5dMGVf45p9Pr1z7CCV56Ba/3a1mOehs+Fnxd tOqqt2mN5To2ruqpWY56qdSgOy6ovYZb0DO/3N+Tg+dYxahZfzdhoGEjJJdrngkNnT4o 0U2Ezudaues2NdPIDKfZe/s3ofVpkc5FL1e1q3K/XM6r+pPKgoXPhRjnYYQkJ/43w3bS 8hImT0bDuw+JLXc5mmJDGoaESuv0UVoFHdIeSz4fwEpPy4x86oKEXRJVCKbiOjZPIuxr Y1Uw== X-Gm-Message-State: AO0yUKVKljdZk0mwHqNBrcPtYVBU3HTRmH7fj0K7TIVEbmvdzd1c+1iC wVNIlOSa5tbnMZSYR0QYpVc= X-Received: by 2002:a9d:4c4:0:b0:68d:4eb7:49d9 with SMTP id 62-20020a9d04c4000000b0068d4eb749d9mr21722524otm.37.1678812867863; Tue, 14 Mar 2023 09:54:27 -0700 (PDT) Received: from chcpu13.cse.ust.hk (191host119.mobilenet.cse.ust.hk. [143.89.191.119]) by smtp.gmail.com with ESMTPSA id z30-20020a9d71de000000b0069463b0207asm1332874otj.30.2023.03.14.09.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 09:54:27 -0700 (PDT) From: Wei Chen <harperchen1110@gmail.com> To: andi.shyti@kernel.org Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Wei Chen <harperchen1110@gmail.com> Subject: [PATCH v4] i2c: xgene-slimpro: Fix out-of-bounds bug in xgene_slimpro_i2c_xfer() Date: Tue, 14 Mar 2023 16:54:21 +0000 Message-Id: <20230314165421.2823691-1-harperchen1110@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760364023475435824?= X-GMAIL-MSGID: =?utf-8?q?1760364023475435824?= |
Series |
[v4] i2c: xgene-slimpro: Fix out-of-bounds bug in xgene_slimpro_i2c_xfer()
|
|
Commit Message
Wei Chen
March 14, 2023, 4:54 p.m. UTC
The data->block[0] variable comes from user and is a number between
0-255. Without proper check, the variable may be very large to cause
an out-of-bounds when performing memcpy in slimpro_i2c_blkwr.
Fix this bug by checking the value of writelen.
Fixes: f6505fbabc42 ("i2c: add SLIMpro I2C device driver on APM X-Gene platform")
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Cc: stable@vger.kernel.org
---
Changes in v2:
- Put length check inside slimpro_i2c_blkwr
Changes in v3:
- Correct the format of patch
Changes in v4:
- CC stable email address
drivers/i2c/busses/i2c-xgene-slimpro.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Hi Wei, On Tue, Mar 14, 2023 at 04:54:21PM +0000, Wei Chen wrote: > The data->block[0] variable comes from user and is a number between > 0-255. Without proper check, the variable may be very large to cause > an out-of-bounds when performing memcpy in slimpro_i2c_blkwr. > > Fix this bug by checking the value of writelen. > > Fixes: f6505fbabc42 ("i2c: add SLIMpro I2C device driver on APM X-Gene platform") > Signed-off-by: Wei Chen <harperchen1110@gmail.com> > Cc: stable@vger.kernel.org and... Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Thanks, Andi
On Tue, Mar 14, 2023 at 04:54:21PM +0000, Wei Chen wrote: > The data->block[0] variable comes from user and is a number between > 0-255. Without proper check, the variable may be very large to cause > an out-of-bounds when performing memcpy in slimpro_i2c_blkwr. > > Fix this bug by checking the value of writelen. > > Fixes: f6505fbabc42 ("i2c: add SLIMpro I2C device driver on APM X-Gene platform") > Signed-off-by: Wei Chen <harperchen1110@gmail.com> > Cc: stable@vger.kernel.org Applied to for-current, thanks!
diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c index bc9a3e7e0c96..0f7263e2276a 100644 --- a/drivers/i2c/busses/i2c-xgene-slimpro.c +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c @@ -308,6 +308,9 @@ static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip, u32 msg[3]; int rc; + if (writelen > I2C_SMBUS_BLOCK_MAX) + return -EINVAL; + memcpy(ctx->dma_buffer, data, writelen); paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen, DMA_TO_DEVICE);