From nobody Sun Feb 8 18:18:22 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B7EC2DCF78; Wed, 29 Oct 2025 02:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761705639; cv=none; b=qU0ZESAcgEaqD9YdwRZHL2wUD4OAu3k3zjaTMQ34WW7ghpX8hNb4DS4odB3j9bhDT/3DSRv5l7Qpn44ZT+X9rA6iJuMrCIGgCAtOtlY8fiO78xirK3YSpjBxwFaYCSaWAbM+cDuNCLX4uJadxZB2Hzv1o+mJpRRU3QU+TFy5A5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761705639; c=relaxed/simple; bh=7I1cY10rprgfnhojf9FbjlbVOwRLgWf/WGb4FAbdwiw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=NvB/YpUJ9Dwz4QwASqx/e5J32uMcd3HNC5ON6/DlcGPq7WsrvyBpePVZD+Z3og7Im9uzocXKYp5EuztZYyhQX7WnXcoooJUL0iN8CH5hHoko+hwLeQsjwJvfgOFLXqxQ1F6bntTny4EAzFe1qGgVLPONc9XmMxfMq7MufCV8Qlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 9c67c0b0b47011f0a38c85956e01ac42-20251029 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:d6bc5647-d94c-4825-91c2-2ba90179514d,IP:0,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:25 X-CID-META: VersionHash:a9d874c,CLOUDID:e7584f9344cb86322b556f9c5d91c0e6,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850,TC:nil,Content:0|50,EDM:5,IP:nil ,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES: 1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 9c67c0b0b47011f0a38c85956e01ac42-20251029 X-User: xiaopei01@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 54318501; Wed, 29 Oct 2025 10:40:20 +0800 From: Pei Xiao To: jic23@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, eugen.hristev@linaro.org Cc: Pei Xiao Subject: [PATCH v3] iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driver Date: Wed, 29 Oct 2025 10:40:16 +0800 Message-Id: <90dec520a9537af2feab9d56b22d99878fba9e2a.1761705396.git.xiaopei01@kylinos.cn> X-Mailer: git-send-email 2.25.1 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 Content-Type: text/plain; charset="utf-8" at91_adc_interrupt can call at91_adc_touch_data_handler function to start the work by schedule_work(&st->touch_st.workq). If we remove the module which will call at91_adc_remove to make cleanup, it will free indio_dev through iio_device_unregister but quite a bit later. While the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows: CPU0 CPU1 | at91_adc_workq_handler at91_adc_remove | iio_device_unregister(indio_dev) | //free indio_dev a bit later | | iio_push_to_buffers(indio_dev) | //use indio_dev Fix it by ensuring that the work is canceled before proceeding with the cleanup in at91_adc_remove. Fixes: 3ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position a= nd pressure channels") Signed-off-by: Pei Xiao --- changlog in v3: move cancel_work_sync after iio_device_unregister changlog in v2: use correct Fix id --- drivers/iio/adc/at91-sama5d2_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama= 5d2_adc.c index b4c36e6a7490..aa4ba3f5a506 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -2481,6 +2481,7 @@ static void at91_adc_remove(struct platform_device *p= dev) struct at91_adc_state *st =3D iio_priv(indio_dev); =20 iio_device_unregister(indio_dev); + cancel_work_sync(&st->touch_st.workq); =20 at91_adc_dma_disable(st); =20 --=20 2.25.1