From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 74D0F2874FE; Wed, 28 Jan 2026 15:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769615944; cv=none; b=M0UqwBlEsX3SygIi4R+9FHulkwmxwaeZGlse13FvBYjKk9Q1hzOpJPaTV7tnwGs6vKRvpwvfAdUaf4cQAgZU1ttVqAK3lkWm3zOhWPabJTbOlqWfE4NMSFlfyzuENqTDYaf7CLmful/uOCMCgR6PqpDZMuyGEgZHSVDqqnOiwp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769615944; c=relaxed/simple; bh=4MfH1XCzLJFSdpUXMoJrQ9DmU2OsiEBn+87ojDCWmA8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OmEmkAi6l0yAHaq69jmpLsngWmXhAzScFxdxLGhN9POYoOBdkHGQtygok4tOL72nJjAZGc+OmOY8z1P9y4euTTTxCKbeLm3NedzIaQQfoZ6PfrHNHkS0xD/44Q5Bbn52xuDu9zVUOfqlL6BhcvKbxUVmpn4AX6CzYB3SX6BP2ks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ARuVoqZQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ARuVoqZQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E95CCC4CEF1; Wed, 28 Jan 2026 15:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769615944; bh=4MfH1XCzLJFSdpUXMoJrQ9DmU2OsiEBn+87ojDCWmA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARuVoqZQ4p13vBhAuusJUO62Ypk3avEKZn7N0fV46mhz4pvCtkzSu3WZ/d2S786Sg +URWW8tBZ9DONlp8xIFe27SRDxbhZspd4FY+7vNfzD0tlHNBWNtZCHhKzRmWWe4r4E KC93YhNlIH6AOTkI++AlBykeG7vKGhNbnkjD193M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pei Xiao , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.18 160/227] iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driver Date: Wed, 28 Jan 2026 16:23:25 +0100 Message-ID: <20260128145350.210222464@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128145344.331957407@linuxfoundation.org> References: <20260128145344.331957407@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pei Xiao commit dbdb442218cd9d613adeab31a88ac973f22c4873 upstream. 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: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels") Signed-off-by: Pei Xiao Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/at91-sama5d2_adc.c | 1 + 1 file changed, 1 insertion(+) --- 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 platf struct at91_adc_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); + cancel_work_sync(&st->touch_st.workq); at91_adc_dma_disable(st);