From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 AB9943C2785 for ; Sat, 11 Jul 2026 11:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783770603; cv=none; b=QpYA2PC7iPDuxoD3ULFHUHC6swhbF7L+iLl3w5gMSr+/vTPKDhxVsYqPuptA5eGtCdvs1b1Fl+HVf2DtobcQwvlrT93iDpYaj43TCLxyySz2pGCsAcVTY3rwG9ngXrzwMZaRchSfAmCK9U0dRiS0m0+OlbfMMc1SERumfTvOVf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783770603; c=relaxed/simple; bh=o2Hiy84rnP/9UMKURCEIhcD7/nHJlcIAPilhOK3M2oU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EI/hI5vWS/7swyOtS6ok/pqRI3eTuv0IUc7JTm4/a5JR2VQMNDA7FE/OpXpUXRTD5JL3sKHsutpg6LKVTii5EXJzOR98OUVCemfkhSgzmeeUDLrrSJfsZJyQRmIiaEu1uErAD3dBg6XMYnN5zn/XVIaUiZs8vEFvPLOXdTXrfvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-37ff8e0ad0fso2136129a91.2 for ; Sat, 11 Jul 2026 04:50:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783770601; x=1784375401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kJ53oWqRjCNjVlROCxKHTEOJ8pLHHBllpxRR0nGEHyI=; b=AwBx0TWH4R9GzXRwtgNv6RBD5CvFhzLDJlbs21+UBThFrSx4BQQR0//dCpaZvfMdaw zV4qO/t6GM3aDa7EBtg22nZJf5B2XZwLvSFF/6WneGwvjLdYd5+R/qy6scUYdcPN6nA8 sdk26DIylmjEsczZWDrqpJK2CIJ89rmMQkQKUGuLR1Ds+ofH4vWhQyVbdCZsJ7p3RApT Cr1n0owErHKXy4j1aIFcD9VEPW8ZmmIinh2Eio87ogDLtGCfdTbDvS8mD9SQPzbzUZ34 mNd+4MwCdf+10ryY6NMBCIaUI2S5U3XUqJgzc8f8UJlGUbRMtZvV8cu6YK18JcDljrbB JcQw== X-Forwarded-Encrypted: i=1; AHgh+Rp1aYDoyATTpG8ZukTkfjbo6O4i77u72ztOKbJ3uCIraiYDOX4NFXoWRUBoVVpIPrjZEkLCbANi7iGE8gg=@vger.kernel.org X-Gm-Message-State: AOJu0YxTWzuUlkfyvIdW7C6d42gC74K66pI94aSyYdLSo40MD/x/I3Sb Z2DiQYrBCN27sGh5KEpjzg1Fj5NYhIMEDhSbfFx3GItwAzwnqRwPA5o= X-Gm-Gg: AfdE7clAJk00ZImSSP/dytY7tH7PT5m5xd0F0Mcrg2aR8zmMjnWUj5/rMzpx02B0l+7 Bk0AmB7yfiuAT39zXNP9Iedkj4nER9B5qlV+79DZgS1CtCYr0IzINBzWLwIPgcWsZb5Bo0he5Zn RaNDknM6S1amtgVh7QmXAs9SxmrYbW+TJKGJ032DUgvMwz9TVhOlsWFvI9fFldtJWrm70CrIj5U chxJC4PMiS1LWs0dy28l2FRBXWS+emRCTJhOuUuZ2wN96SNLPM011EwXvA66HmnnV+mLDCE3SS8 tutizixdeVKBRcUhnUu4N8QgfQMMrvoMBpI9A4iZ1CYdCE2GOF0Me583/CvvtVC6ZvcBSRnvnre 1ymF74QKS4rnN9IdgDIz5qxrWx1KZQ8qhj3/b5MOREIntesVQByOcEb5Bn5UBH+rYVBeKmmKCR1 /Ve53hY3wWt/B4nCyKFqGMPpfEi82paAX++ZaZWQ9uYenA/8vNsellkL3vGGse9dEprCfEDhAM1 qVGgauW0e+l1/rDMq5cIuKbUA== X-Received: by 2002:a17:90b:5344:b0:381:1b66:4734 with SMTP id 98e67ed59e1d1-38dc75d0b31mr2658787a91.6.1783770601104; Sat, 11 Jul 2026 04:50:01 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-52-13.dynamic-ip.hinet.net. [61.228.52.13]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38a5506b48bsm3957570a91.1.2026.07.11.04.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 04:50:00 -0700 (PDT) From: Shih-Yuan Lee To: Dmitry Torokhov , Mark Brown Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Shih-Yuan Lee , linux-input@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove Date: Sat, 11 Jul 2026 19:49:35 +0800 Message-Id: <20260711114937.16670-2-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260711114937.16670-1-fourdollars@debian.org> References: <20260711055247.5412-1-fourdollars@debian.org> <20260711114937.16670-1-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); } -- 2.39.5