From: Asmaa Mnebhi <asmaa@nvidia.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Asmaa Mnebhi <asmaa@nvidia.com>, Khalil Blaiech <kblaiech@nvidia.com>
Subject: [PATCH v1 5/7] i2c-mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()
Date: Tue, 16 Aug 2022 18:54:10 -0400 [thread overview]
Message-ID: <20220816225412.9095-6-asmaa@nvidia.com> (raw)
In-Reply-To: <20220816225412.9095-1-asmaa@nvidia.com>
memcpy() is called in a loop while 'operation->length' upper bound is
not checked and 'data_idx' also increments.
Reviewed-by: Khalil Blaiech <kblaiech@nvidia.com>
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
---
drivers/i2c/busses/i2c-mlxbf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 02ed6983c35c..c6959ba7113e 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -724,6 +724,9 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
if (flags & MLXBF_I2C_F_WRITE) {
write_en = 1;
write_len += operation->length;
+ if (data_idx + operation->length >
+ MLXBF_I2C_MASTER_DATA_DESC_SIZE)
+ return -ENOBUFS;
memcpy(data_desc + data_idx,
operation->buffer, operation->length);
data_idx += operation->length;
--
2.30.1
next prev parent reply other threads:[~2022-08-16 23:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 22:54 [PATCH v1 0/7] i2c-mlxbf.c: bug fixes and new feature support Asmaa Mnebhi
2022-08-16 22:54 ` [PATCH v1 1/7] i2c-mlxbf.c: Fix frequency calculation Asmaa Mnebhi
2022-08-16 22:54 ` [PATCH v1 2/7] i2c-mlxbf.c: remove IRQF_ONESHOT Asmaa Mnebhi
2022-08-16 22:54 ` [PATCH v1 3/7] i2c-mlxbf: add multi slave functionality Asmaa Mnebhi
2022-08-18 16:25 ` Wolfram Sang
2022-08-18 16:41 ` Asmaa Mnebhi
2022-08-16 22:54 ` [PATCH v1 4/7] i2c-mlxbf.c: incorrect base address passed during io write Asmaa Mnebhi
2022-08-18 16:27 ` Wolfram Sang
2022-08-18 16:40 ` Asmaa Mnebhi
2022-08-18 17:21 ` Asmaa Mnebhi
2022-08-18 20:24 ` Wolfram Sang
2022-08-18 20:30 ` Asmaa Mnebhi
2022-08-16 22:54 ` Asmaa Mnebhi [this message]
2022-08-16 22:54 ` [PATCH v1 6/7] i2c-mlxbf.c: support BlueField-3 SoC Asmaa Mnebhi
2022-08-18 15:11 ` Rob Herring
2022-08-18 20:43 ` Asmaa Mnebhi
2022-08-16 22:54 ` [PATCH v1 7/7] i2c-mlxbf.c: support lock mechanism Asmaa Mnebhi
2022-08-18 16:24 ` [PATCH v1 0/7] i2c-mlxbf.c: bug fixes and new feature support Wolfram Sang
2022-08-18 16:42 ` Asmaa Mnebhi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220816225412.9095-6-asmaa@nvidia.com \
--to=asmaa@nvidia.com \
--cc=kblaiech@nvidia.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.