From nobody Mon Apr 6 10:31:02 2026 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AA933BE16F for ; Thu, 19 Mar 2026 12:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773924038; cv=none; b=TeX8e2zLGKwYgB4AsDR3LzCO2ZbG/kZ+QRhgmA2k4Tr4HfNSZaGTzIGUA6tMyP5vw6xz0BGZXALd95B7C0dzamu3YZaQ69/dkKNzCZNJ0ZugrTfvj6yIdi5wlGUq+QYNXZmQwiLsStfdasjbxEKbdxeZjnzoTYL9tXFp6k2+7Rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773924038; c=relaxed/simple; bh=PVQ77e0jbKpBY2tJZGoqQGz8ou5TJuzgxx42AvozcOc=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=ER3+y3GGO3hOcuIRQMsekeAiHTVMzPfCHQGq0E1UhDq68jW50oYLxF8bGif9LXuG0p7e3AYbTVR8Szhq2q0874QjNrw01F23CmNd4aQywTUrb6FkTF0uY+0t/hO+5GZ76JyBOHlqR81TJzxdRUL5TUkVXjkiOs2OZb/Xx5Flhzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-67be26d440fso17141225eaf.1 for ; Thu, 19 Mar 2026 05:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773924034; x=1774528834; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ql18l176PvKtgikXfHvk7yFlowN+Q1SiUc2MMTj6OmY=; b=pkgK4MNtENQlctuZeUzszsTNkhqxFVmYPnwCJuQ4o6tu9/1tul0OTAS4x6aVCQzWuu KD9SxUIoX1sENK4y6H1EAvfbGpWKoDa/zxdtRT2wihrDQYshda6WUA1qU1ejUgL/Fwqc sBnL2iN1JdDGpXj8FPclr6fZFKzeSdF1O6esi3WCnDHAMxqvrO7K6unYBBzd20ikqGQT Xn6mZTbk/E6FZ/AErFaqZSUvLlaf/SLB+hXp2Nm5zGFcBQ0C96SMnm9g2xI3anNNi++N 4jLXXrHx8FZw0a+AGYiHJf+pOChl8/tdDJVe04RhYJfcifu486my95Kydr6wpEiybf9S EpfQ== X-Gm-Message-State: AOJu0Yw1V2Bx51PrejLMU3keICr06569/EacHe19VWyLv4DboOEsNphn ppnZ5KZPaRNKgnGly9t1D3KxyHT+iRjtLpyo2Wkb26TyBtoDWvyG6UhJhOdxys56PAreOkCRhaA b8/N8BC8jcPt3WKWamJPpy4g14Wn25oQqNaf/N/hJGdB+QPk+Xrr4dK3babI= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:2d04:b0:67b:db40:7a4c with SMTP id 006d021491bc7-67c0daea8b6mr4651032eaf.43.1773924033976; Thu, 19 Mar 2026 05:40:33 -0700 (PDT) Date: Thu, 19 Mar 2026 05:40:33 -0700 In-Reply-To: <69bba3fe.050a0220.227207.0030.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69bbeec1.050a0220.227207.0053.GAE@google.com> Subject: Forwarded: [PATCH] media: em28xx: fix use-after-free in v4l2_open() during init error path From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] media: em28xx: fix use-after-free in v4l2_open() during in= it error path Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master em28xx_v4l2_init() calls video_register_device() which makes the video device immediately visible to userspace. At this point, v4l2_open() can be called concurrently and access vdev->dev_debug which is embedded inside the em28xx_v4l2 structure. If a subsequent initialization step fails after video_register_device() succeeds, the error cleanup path calls kref_put(&v4l2->ref) which drops the reference count to zero and frees the em28xx_v4l2 structure via em28xx_free_v4l2(). This results in a use-after-free when v4l2_open() reads vdev->dev_debug from the already freed structure. Fix this by adding kref_get(&v4l2->ref) at the end of successful initialization, matching the kref_put() already present in em28xx_v4l2_fini(). This ensures the v4l2 structure is not freed while it is still accessible through the registered video device. The following race triggers the bug: em28xx_v4l2_init() video_register_device() <- device visible to userspace later step fails goto unregister_dev kref_put(&v4l2->ref) <- ref hits 0, struct freed! v4l2_open() <- runs concurrently reads vdev->dev_debug <- use-after-free! Fixes: 47677e51e2a4 ("[media] em28xx: Only deallocate struct em28xx after f= inishing all extensions") Reported-by: syzbot+1a7507a194fff09e5c44@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3D1a7507a194fff09e5c44 Signed-off-by: Deepanshu Kartikey --- drivers/media/usb/em28xx/em28xx-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em= 28xx/em28xx-video.c index 5f13f63fbdee..fe2a7771275d 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -2876,7 +2876,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) "V4L2 extension successfully initialized\n"); =20 kref_get(&dev->ref); - + kref_get(&v4l2->ref); mutex_unlock(&dev->lock); return 0; =20 --=20 2.43.0