Skip to contentSkip to conversation

Backport request: Fix reading issue on mcp2221

PATCH In review Romain Sioen 4 participants 7 messages Oct 7, 2025 – Oct 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Backport request: Fix reading issue on mcp2221

Hi maintainers,

Please consider backporting the following patches to the stable trees. These patches fix a significant reading issue with mcp2221 on i2c eeprom. This request is following the one I did previously to fix hid-mcp2221 in previous LTS versions.

I have confirmed that the patches applie cleanly and build successfully against v6.12, v6.6, v6.1, v5.15 and v5.10 stable branches.

Thanks,

Romain

Arnaud Lecomte (1):
hid: fix I2C read buffer overflow in raw_event() for mcp2221

 drivers/hid/hid-mcp2221.c | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/1 hid: fix I2C read buffer overflow in raw_event() for mcp2221

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

---
 drivers/hid/hid-mcp2221.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hid/hid-mcp2221.c +4 -0
index 0f93c22a479f..83941b916cd6 100644
@@ -814,6 +814,10 @@ static int mcp2221_raw_event(struct hid_device *hdev,
 			}
 			if (data[2] == MCP2221_I2C_READ_COMPL ||
 			    data[2] == MCP2221_I2C_READ_PARTIAL) {
+				if (!mcp->rxbuf || mcp->rxbuf_idx < 0 || data[3] > 60) {
+					mcp->status = -EINVAL;
+					break;
+				}
 				buf = mcp->rxbuf;
 				memcpy(&buf[mcp->rxbuf_idx], &data[4], data[3]);
 				mcp->rxbuf_idx = mcp->rxbuf_idx + data[3];
Signature · 1 line
2.48.1
#2 lore raw

Re: [PATCH 1/1] hid: fix I2C read buffer overflow in raw_event() for mcp2221

Quoted 12 lines · Romain Sioen

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

Quoted 7 lines

I don't see a fixes tag :(

And is this only for 6.12 and 6.16?

thanks,

greg k-h

#3 lore raw

Re: [PATCH 1/1] hid: fix I2C read buffer overflow in raw_event() for mcp2221

Quoted 13 lines · Greg KH
Quoted 12 lines · Romain Sioen

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

Quoted 8 lines
Quoted 7 lines

I don't see a fixes tag :(

Hey, I am the author of the patch. I can find the fixes tag if this looks good to you. Thanks,

Arnaud

Quoted 5 lines

And is this only for 6.12 and 6.16?

thanks,

greg k-h

maintainer
#4 lore raw

Re: [PATCH 1/1] hid: fix I2C read buffer overflow in raw_event() for mcp2221

Quoted 22 lines · Arnaud
Quoted 20 lines · Greg KH
Quoted 19 lines · Romain Sioen

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

Quoted 3 lines
Quoted 1 line

I don't see a fixes tag :(

Hey, I am the author of the patch. I can find the fixes tag if this looks good to you.

There's no need for a fixes tag, just let us know where you want this backported to.

thanks,

greg k-h

#5 lore raw

Re: [PATCH 1/1] hid: fix I2C read buffer overflow in raw_event() for mcp2221

Quoted 22 lines · Greg KH
Quoted 21 lines · Arnaud
Quoted 20 lines · Greg KH
Quoted 19 lines · Romain Sioen

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I don't see a fixes tag :(

Hey, I am the author of the patch. I can find the fixes tag if this looks good to you.

There's no need for a fixes tag, just let us know where you want this backported to.

The ones, you already did the back-port to, seems good enough for me, Thanks Greg :)

Quoted 3 lines

thanks,

greg k-h

Arnaud

#6 lore raw

Re: [PATCH 1/1] hid: fix I2C read buffer overflow in raw_event() for mcp2221

Hi all,

Quoted 28 lines · Arnaud

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 25 lines · Greg KH
Quoted 24 lines · Arnaud
Quoted 13 lines · Greg KH
Quoted 12 lines · Romain Sioen

From: Arnaud Lecomte <[email protected]>

[ Upstream commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 ]

As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.

Quoted 8 lines
Quoted 7 lines

I don't see a fixes tag :(

Hey, I am the author of the patch. I can find the fixes tag if this looks good to you.

Quoted 9 lines
Quoted 2 lines

There's no need for a fixes tag, just let us know where you want this backported to.

The ones, you already did the back-port to, seems good enough for me, Thanks Greg :)

Quoted 3 lines

thanks,

greg k-h

Arnaud

Sorry for the confusion, I didn't put a tag indeed. I just wanted to backport this
patch to previous LTS versions 5.10, 5.15, 6.1, 6.6 and 6.12 as we need it to solve a bug. I tested it in all these stable versions and can confirm that it compiles correctly. This is in the continuity of a backport request I made 1 month ago which has been accepted
and merged.

Thank you for your help,

Romain