Linux USB
 help / color / mirror / Atom feed
* [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads
@ 2026-10-19 12:35 Andi Shyti
  2026-10-19 12:45 ` sashiko-bot
  2026-10-19 14:13 ` Alan Stern
  0 siblings, 2 replies; 3+ messages in thread
From: Andi Shyti @ 2026-10-19 12:35 UTC (permalink / raw)
  To: linux-media, linux-usb, syzkaller-bugs, stable
  Cc: Alan Stern, Antti Palosaari, Greg Kroah-Hartman,
	Mauro Carvalho Chehab, Andi Shyti

ec168_i2c_xfer() checks the length of the register-address
message in a combined demodulator read, but does not validate the
read message length. Userspace can supply a zero-length read
through I2C_RDWR.

This reaches ec168_ctrl_msg(), which selects an IN control pipe
for READ_DEMOD with wLength set to zero. The USB core treats
control requests without a data stage as OUT(*), triggering the
"BOGUS control dir" warning in usb_submit_urb().

Reject zero-length read messages with -EOPNOTSUPP before issuing
the USB request, using the existing exit path to release the I2C
mutex.

(*) is_out = ... || !setup->wLength;

Fixes: 2bf290be4f3e ("V4L/DVB (13364): ec168: add new driver for E3C EC168 DVB USB")
Reported-by: syzbot+ed3ada41c4eb1c4ab78e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ed3ada41c4eb1c4ab78e
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Cc: <stable@vger.kernel.org> # v2.6.33+
---
 drivers/media/usb/dvb-usb-v2/ec168.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/ec168.c b/drivers/media/usb/dvb-usb-v2/ec168.c
index 973b32356b17..f6b98c7d3704 100644
--- a/drivers/media/usb/dvb-usb-v2/ec168.c
+++ b/drivers/media/usb/dvb-usb-v2/ec168.c
@@ -115,7 +115,7 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 	while (i < num) {
 		if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
 			if (msg[i].addr == ec168_ec100_config.demod_address) {
-				if (msg[i].len < 1) {
+				if (msg[i].len < 1 || msg[i+1].len < 1) {
 					i = -EOPNOTSUPP;
 					break;
 				}
-- 
2.55.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads
  2026-10-19 12:35 [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads Andi Shyti
@ 2026-10-19 12:45 ` sashiko-bot
  2026-10-19 14:13 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-19 12:45 UTC (permalink / raw)
  To: Andi Shyti, linux-usb

> ec168_i2c_xfer() checks the length of the register-address
> message in a combined demodulator read, but does not validate the
> read message length. Userspace can supply a zero-length read
> through I2C_RDWR.
> 
> This reaches ec168_ctrl_msg(), which selects an IN control pipe
> for READ_DEMOD with wLength set to zero. The USB core treats
> control requests without a data stage as OUT(*), triggering the
> "BOGUS control dir" warning in usb_submit_urb().
> 
> Reject zero-length read messages with -EOPNOTSUPP before issuing
> the USB request, using the existing exit path to release the I2C
> mutex.
> 
> (*) is_out = ... || !setup->wLength;
> 
> Fixes: 2bf290be4f3e ("V4L/DVB (13364): ec168: add new driver for E3C EC168 DVB USB")
> Reported-by: syzbot+ed3ada41c4eb1c4ab78e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ed3ada41c4eb1c4ab78e
> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019123542.4040472-1-andi.shyti@kernel.org?part=1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads
  2026-10-19 12:35 [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads Andi Shyti
  2026-10-19 12:45 ` sashiko-bot
@ 2026-10-19 14:13 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Stern @ 2026-10-19 14:13 UTC (permalink / raw)
  To: Andi Shyti
  Cc: linux-media, linux-usb, syzkaller-bugs, stable, Antti Palosaari,
	Greg Kroah-Hartman, Mauro Carvalho Chehab

On Mon, Oct 19, 2026 at 02:35:42PM +0200, Andi Shyti wrote:
> ec168_i2c_xfer() checks the length of the register-address
> message in a combined demodulator read, but does not validate the
> read message length. Userspace can supply a zero-length read
> through I2C_RDWR.
> 
> This reaches ec168_ctrl_msg(), which selects an IN control pipe
> for READ_DEMOD with wLength set to zero. The USB core treats
> control requests without a data stage as OUT(*), triggering the
> "BOGUS control dir" warning in usb_submit_urb().
> 
> Reject zero-length read messages with -EOPNOTSUPP before issuing
> the USB request, using the existing exit path to release the I2C
> mutex.
> 
> (*) is_out = ... || !setup->wLength;
> 
> Fixes: 2bf290be4f3e ("V4L/DVB (13364): ec168: add new driver for E3C EC168 DVB USB")
> Reported-by: syzbot+ed3ada41c4eb1c4ab78e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ed3ada41c4eb1c4ab78e
> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
> Cc: <stable@vger.kernel.org> # v2.6.33+
> ---
>  drivers/media/usb/dvb-usb-v2/ec168.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/dvb-usb-v2/ec168.c b/drivers/media/usb/dvb-usb-v2/ec168.c
> index 973b32356b17..f6b98c7d3704 100644
> --- a/drivers/media/usb/dvb-usb-v2/ec168.c
> +++ b/drivers/media/usb/dvb-usb-v2/ec168.c
> @@ -115,7 +115,7 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
>  	while (i < num) {
>  		if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
>  			if (msg[i].addr == ec168_ec100_config.demod_address) {
> -				if (msg[i].len < 1) {
> +				if (msg[i].len < 1 || msg[i+1].len < 1) {
>  					i = -EOPNOTSUPP;
>  					break;
>  				}

Isn't there an I2C quirks flag to indicate that 0-length reads aren't 
allowed?  Setting that flag would be more understandable than this test.

Alan Stern

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-19 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 12:35 [PATCH] media: dvb-usb-v2: ec168: Reject zero-length I2C reads Andi Shyti
2026-10-19 12:45 ` sashiko-bot
2026-10-19 14:13 ` Alan Stern

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