The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] media: dvb-usb: az6027: fix out-of-bounds in az6027_i2c_xfer()
@ 2025-04-21 11:50 Jeongjun Park
  0 siblings, 0 replies; only message in thread
From: Jeongjun Park @ 2025-04-21 11:50 UTC (permalink / raw)
  To: mchehab
  Cc: christophe.jaillet, hverkuil, harperchen1110, linux-media,
	linux-kernel, Jeongjun Park

Missing maximum size check on msg[i].len causes out-of-bounds vuln for u8 *data.
Therefore, we need to add proper range checking to prevent this vuln.

Fixes: 858e97d7956d ("media: dvb-usb: az6027: fix three null-ptr-deref in az6027_i2c_xfer()")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 drivers/media/usb/dvb-usb/az6027.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
index 056935d3cbd6..f9bd8a4c1577 100644
--- a/drivers/media/usb/dvb-usb/az6027.c
+++ b/drivers/media/usb/dvb-usb/az6027.c
@@ -988,7 +988,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
 			/* write/read request */
 			if (i + 1 < num && (msg[i + 1].flags & I2C_M_RD)) {
 				req = 0xB9;
-				if (msg[i].len < 1) {
+				if (msg[i].len < 1 || msg[i + 1].len + 5 > sizeof(data)) {
 					i = -EOPNOTSUPP;
 					break;
 				}
@@ -1005,7 +1005,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
 
 				/* demod 16bit addr */
 				req = 0xBD;
-				if (msg[i].len < 1) {
+				if (msg[i].len < 1 || msg[i].len - 2 > sizeof(data)) {
 					i = -EOPNOTSUPP;
 					break;
 				}
@@ -1034,7 +1034,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
 			} else {
 
 				req = 0xBD;
-				if (msg[i].len < 1) {
+				if (msg[i].len < 1 || msg[i].len - 1 > sizeof(data)) {
 					i = -EOPNOTSUPP;
 					break;
 				}
--

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-04-21 11:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 11:50 [PATCH] media: dvb-usb: az6027: fix out-of-bounds in az6027_i2c_xfer() Jeongjun Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox