From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 2EAC1282F38 for ; Sat, 11 Jul 2026 21:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783806919; cv=none; b=WmZza7nfFD/SsyC/ntysZgNSRsIircYZNhAz3hLjftMOi90SKHWeao05Kh9deUQs3aSmbASPpR6JTlUf4NEhR2wXUDk9Qaaa6VE7FQNTqbSVI/TNc7P9YIGTo4D4oGaMPfxEFpTdg6jIcu67AYRG26eOB7dfVtaGPgGbHcM/hyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783806919; c=relaxed/simple; bh=+g/zQMRr25BR6fKjHXZoDZ0Xm5YR7ayk9SrrK7joU9Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NaHdYw/8DfW5/lWR2G9lUg2VjUrnYvLsICd3jtcKFc3GY8ZtWoMEsjy+PtlYu701sK491WdKhUjdCBaPV5lis7GEVHvb0gxTeQoNWPobWdfVE5bEpGu0o7L9jCXSnCQmzVonUnVitPw7756kW3zspuvgp34yri/jccYMX4FtWcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nEhPteiL; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nEhPteiL" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-38125cebfdaso2674947a91.1 for ; Sat, 11 Jul 2026 14:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783806917; x=1784411717; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=8FLFQgdcqhO0RIIwKxkkuCrdHtU1MdsA2yWXjq6XIr8=; b=nEhPteiLMBfXyrY1gyPWawvaA4bFkYKDj2gVvJl1xE5oif40oGc71MPzcGjpeRhoXN +D+xBsOtGgt+B3jIWiY4vzUdPZ2oJEJCUX1KV/815B2VG+guVKsKdQpyi9B+oUQQDD1m 7UiEtmOYAVV6QOMNzembBs26CTYJ5zJ0CVw3QmJPMnLtYmaMgVy7GwEWBzpPKGz+fqeN t5GPTZusvM7qtyfwICHiVkRNa4UysdhQD3fc1OaTx3jU91lRY3JEIBdq2X/TE58ee/YC dsP2uklaonChIKEGc8CXrjC6j1ZwwAJLkcJ3/PvzvhjoP+i8645rF/lT9rveU0jN2vU6 +QOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783806917; x=1784411717; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8FLFQgdcqhO0RIIwKxkkuCrdHtU1MdsA2yWXjq6XIr8=; b=odNUNKX5pHromfR37nRpJEN8ADAQv6zdyn/D7FbGbDZCYyykx9U157KstcWJ+vsBfZ /V71/+3Dk9VKV+ZJjN4qnKBlOOXXi8EGygexULwNVlYmqXC5L0BXsi3fcuFXIj7KUtUN BN6/zebaGLITtsLKoE5vbQUkUrGniOLzvLEXF9ZIijJF9zPnktXzz0U1OoZvT9m6SLUT kL1eHwlNMgBKGLVMxP4fZMwaLRCiAf/LTRILrurqtRLT00d8I/s2yf6RRxld/sAp+I67 RDxBPeHAnpJGE5+s5I6/DM4lWvczmlUwJmhIpbXNxdWa2fnFEF7JbypqwSHUZSgNYkyS uRQQ== X-Forwarded-Encrypted: i=1; AHgh+Rq9cIzBImDGJMddpQmKf01pO88PTk9DF2HqsowIhnR28+4+6CENtsFk8v7R3O1dz60umJHT7jx8bsTxIXI=@vger.kernel.org X-Gm-Message-State: AOJu0YxHIZdWfzyp6g8HMDaEzqs9/FvhgPt9aLl2w4d8J0OtixNMztEY GDVRpV/nnMEGQKF4Q4U3owKUlaft02VtljlNiRL5lvF2oq3VuNwenO3Y X-Gm-Gg: AfdE7cnZ54oq0L1Et3sDN0PNZz/78fCbDcnTuUMNXQ++aVHgoOwDD9hobFTFL4DgEV7 eAPNgIE949TyCY0xeUsDjAJKjxW5e0LMqiO+RQgRsiSHI494DcZOsIAS+1RbSWMqGBpk0K03uEZ Zw1mTbQ7hgJ/bEihC74OrTcSmQuGPajl6aqVeWA2sjnUDqsekwYPibhh/BDkug7u8NckLgv8Sqo c5KPoAbBK4vTHVLyRLdEGUHsCXOYi1QoWw0dSyNNhIzTLSojVi9f7M4n3HfKTH15Ux6/HhA5Ckz d34JTkG8BqO8Gb1LHWHT7GXBgbVd/P5Ey09wifOu7lFteif0xEjG9/0ctqxV7JRFpCSJZKhvlbb oPMZypVutYt1A34DP9bL9vWDiFcWFiejfXZIZmYG25njCbSYPKrWBy1yYdgwzPtPikb0u0yCj0T o9uMSunGCF4MNNeeXtZDklcBdDijYHapY29wkQhM5P8vCq4JbmE5QU8YIDVhVOTaGCVF/FFIqF2 A== X-Received: by 2002:a17:90b:540d:b0:37f:9ce1:cda8 with SMTP id 98e67ed59e1d1-38dc7752969mr3988834a91.30.1783806917501; Sat, 11 Jul 2026 14:55:17 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:c63e:9756:a95c:c75]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311935fd091sm35851752eec.24.2026.07.11.14.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 14:55:16 -0700 (PDT) Date: Sat, 11 Jul 2026 14:55:13 -0700 From: Dmitry Torokhov To: Shih-Yuan Lee , Ronald =?utf-8?B?VHNjaGFsw6Ry?= Cc: Mark Brown , linux-input@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove Message-ID: References: <20260711055247.5412-1-fourdollars@debian.org> <20260711131140.18777-1-fourdollars@debian.org> <20260711131140.18777-2-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260711131140.18777-2-fourdollars@debian.org> Hi Shih-Yuan, On Sat, Jul 11, 2026 at 09:11:38PM +0800, Shih-Yuan Lee wrote: > During driver removal in applespi_remove(), the managed private data > structure is freed by devres. However, the driver does not cancel the > asynchronous work applespi->work, which registers the touchpad input > device. > > This creates a use-after-free (UAF) vulnerability if a pending or > running worker thread attempts to access the private data after the > remove function returns. > > Fix this by explicitly calling cancel_work_sync(&applespi->work) in > applespi_remove() before cleanups. > > Signed-off-by: Shih-Yuan Lee > --- > drivers/input/keyboard/applespi.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c > index b5ff71cd5a70..3bdb9e7cfb8b 100644 > --- a/drivers/input/keyboard/applespi.c > +++ b/drivers/input/keyboard/applespi.c > @@ -1822,6 +1822,8 @@ static void applespi_remove(struct spi_device *spi) > > applespi_drain_reads(applespi); > > + cancel_work_sync(&applespi->work); > + > debugfs_remove_recursive(applespi->debugfs_root); > } For this, and the next one, the issue is that the touchpad discovery is asynchronous. I wonder if making touchpad detection synchronous and making the entire driver as PROBE_PREFER_ASYNCHRONOUS would not make it simpler and more robust. It looks like Ronald tried to do that in [1] but unfortunately it was dropped on the floor (my fault :( ). Maybe you can try it out and freshen it? Thanks. -- Dmitry [1] https://lore.kernel.org/all/20190721070523.24695-1-ronald@innovation.ch/