From nobody Mon Feb 9 01:35:07 2026 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BED6432860A for ; Thu, 23 Oct 2025 14:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761228912; cv=none; b=ERobEOsC5LG/eobanQS2YUyXE5KRS992mn4YWCdTozTinfrazOug7w/Aky2DoDBPqgq0i6UrIJI4SZula609ezoF8L/Lg/81oVGEG8P9R1QriNcBEKo7379AFAeFIyiUUSl3h65p/1KhzlI52w/X42nup6lL/D54JCy0mV/qMAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761228912; c=relaxed/simple; bh=CdGzPayY2HtafoVKU/xmDaM2LdM3QDNgNvm+GrBaNmg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=TAo7m68g4xtbdVnO+lFJ5d07PozNTkJFxPvZHugHRXDmIWxeoyuod9m7GVRKAg/oPXSGjTxPIVvKgatRwMpJvvYM9OI6NF34dQ5fe4rdEWiRpzU0AZLELIMVqULb3zySUmcHSHrCNQSmz+PZ1JLhSWTlRg3l6upaSPKlxkQq3AA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 23 Oct 2025 17:15:06 +0300 Received: from localhost (10.0.253.101) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 23 Oct 2025 17:15:06 +0300 From: Nikita Zhandarovich To: Ian Abbott , H Hartley Sweeten CC: Nikita Zhandarovich , Greg Kroah-Hartman , , Subject: [PATCH v2] comedi: pcl818: fix null-ptr-deref in pcl818_ai_cancel() Date: Thu, 23 Oct 2025 17:14:56 +0300 Message-ID: <20251023141457.398685-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Content-Type: text/plain; charset="utf-8" Syzbot identified an issue [1] in pcl818_ai_cancel(), which stems from the fact that in case of early device detach via pcl818_detach(), subdevice dev->read_subdev may not have initialized its pointer to &struct comedi_async as intended. Thus, any such dereferencing of &s->async->cmd will lead to general protection fault and kernel crash. Mitigate this problem by removing a call to pcl818_ai_cancel() from pcl818_detach() altogether. This way, if the subdevice setups its support for async commands, everything async-related will be handled via subdevice's own ->cancel() function in comedi_device_detach_locked() even before pcl818_detach(). If no support for asynchronous commands is provided, there is no need to cancel anything either. [1] Syzbot crash: Oops: general protection fault, probably for non-canonical address 0xdffffc= 0000000005: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] CPU: 1 UID: 0 PID: 6050 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT(ful= l) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 08/18/2025 RIP: 0010:pcl818_ai_cancel+0x69/0x3f0 drivers/comedi/drivers/pcl818.c:762 ... Call Trace: pcl818_detach+0x66/0xd0 drivers/comedi/drivers/pcl818.c:1115 comedi_device_detach_locked+0x178/0x750 drivers/comedi/drivers.c:207 do_devconfig_ioctl drivers/comedi/comedi_fops.c:848 [inline] comedi_unlocked_ioctl+0xcde/0x1020 drivers/comedi/comedi_fops.c:2178 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] ... Reported-by: syzbot+fce5d9d5bd067d6fbe9b@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dfce5d9d5bd067d6fbe9b Fixes: 00aba6e7b565 ("staging: comedi: pcl818: remove 'neverending_ai' from= private data") Cc: stable@vger.kernel.org Signed-off-by: Nikita Zhandarovich Reviewed-by: Ian Abbott --- v1 -> v2: Switch to a better, more logical approach, put forward by Ian Abbott , instead of doing an awkward check in pcl818_ai_cancel() itself. Adjust commit description. P.S. I've chosen to keep the old Fixes: tag. Not sure it's best, but it's at least partially correct. drivers/comedi/drivers/pcl818.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/comedi/drivers/pcl818.c b/drivers/comedi/drivers/pcl81= 8.c index 4127adcfb229..06fe06396f23 100644 --- a/drivers/comedi/drivers/pcl818.c +++ b/drivers/comedi/drivers/pcl818.c @@ -1111,10 +1111,9 @@ static void pcl818_detach(struct comedi_device *dev) { struct pcl818_private *devpriv =3D dev->private; =20 - if (devpriv) { - pcl818_ai_cancel(dev, dev->read_subdev); + if (devpriv) pcl818_reset(dev); - } + pcl818_free_dma(dev); comedi_legacy_detach(dev); }