mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@sina.com>
To: syzbot+436c71c257f18c488712@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	mchehab@kernel.org, syzkaller-bugs@googlegroups.com
Subject: [PATCH] media: dvb: reject dmxdev ioctl until adapter frontend init done
Date: Tue, 17 Nov 2026 18:56:53 +0800	[thread overview]
Message-ID: <20261117105653.61358-1-eadavis@sina.com> (raw)
In-Reply-To: <6afbf0cd.27ea6653.1a0e84.0004.GAE@google.com>

There is a race for usbv2 adapter dvb init and dmxdev ioctl:

   CPU1					CPU2
   ====					====
dvb_usbv2_probe()->
 dvb_usbv2_init()->
  dvb_usbv2_adapter_init()->
   dvb_usbv2_adapter_dvb_init()->
    dvb_dmxdev_init()
     dmxdev is ready			dvb_demux_ioctl()->
					 dvb_demux_do_ioctl()->
					  ...
					   dvb_usb_start_feed()
					     In the current context, active_fe
					     is 0 and adapter->fe[0] is NULL
					     because frontend hasn't inited,
					     this potentially hitting [1]
   dvb_usbv2_adapter_frontend_init()

Move active_fe init to dvb_usbv2_adapter_init() before dmxdev init, this would
reject dmxdev ioctl.

[1]
KASAN: null-ptr-deref in range [0x0000000000000308-0x000000000000030f]
RIP: 0010:ec168_streaming_ctrl+0x73/0x210 drivers/media/usb/dvb-usb-v2/ec168.c:312
Call Trace:
 dvb_usb_start_feed+0xa03/0xef0 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:308
 dmx_ts_feed_start_filtering+0xf6/0x220 drivers/media/dvb-core/dvb_demux.c:747
 dvb_dmxdev_start_feed+0x273/0x3f0 drivers/media/dvb-core/dmxdev.c:658
 dvb_dmxdev_filter_start+0x1b6/0xdd0 drivers/media/dvb-core/dmxdev.c:769
 dvb_dmxdev_pes_filter_set drivers/media/dvb-core/dmxdev.c:985 [inline]
 dvb_demux_do_ioctl+0xe64/0x1200 drivers/media/dvb-core/dmxdev.c:1099
 dvb_usercopy+0x167/0x340 drivers/media/dvb-core/dvbdev.c:996
 dvb_demux_ioctl+0x29/0x40 drivers/media/dvb-core/dmxdev.c:1208

Fixes: e48b2a68617c ("[media] dvb_usb_v2: frontend switching changes")
Reported-by: syzbot+436c71c257f18c488712@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=436c71c257f18c488712
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index bd86d250433d..c764f288065a 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -637,7 +637,6 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
 	dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, adap->id);
 
 	memset(adap->fe, 0, sizeof(adap->fe));
-	adap->active_fe = -1;
 
 	if (d->props->frontend_attach) {
 		ret = d->props->frontend_attach(adap);
@@ -760,6 +759,7 @@ static int dvb_usbv2_adapter_init(struct dvb_usb_device *d)
 		adap = &d->adapter[i];
 		adap->id = i;
 		adap->props = &d->props->adapter[i];
+		adap->active_fe = -1;
 
 		/* speed - when running at FULL speed we need a HW PID filter */
 		if (d->udev->speed == USB_SPEED_FULL &&
-- 
2.43.0


      reply	other threads:[~2026-11-17 10:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  6:14 [syzbot] [media?] general protection fault in ec168_streaming_ctrl syzbot
2026-11-17 10:56 ` Edward Adam Davis [this message]

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=20261117105653.61358-1-eadavis@sina.com \
    --to=eadavis@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=syzbot+436c71c257f18c488712@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®