From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381798; b=VXpR5o+YFRWxObTDhU4B8jIsQig/08D1apLjjATfGsB47y2P0fcSxKl8WWBPPGHQcm4l 35Ek3Y58pDumhUGMD0TgL/PR4EFx363zINfqt655RWhKOG70jK+iGqHCUJVHRs5DpcBLx 6ls/aHKfoVA7fhTAxOtWj6x4Mi7vyxn69mZU31UDlBZPr8sp9clqpi7rxw3omZh9PxS1T bQuE8jc2vMbgorhshhi0m6GwotjCSGSn/G8WI4Jd6+8FPAiIDNnflfLkK9FhuIySdGqNf 7+dfGaQEALog3XZUgt3BMKCMz1Qt8sQiZvHeArD2N0jcEySnw34pCxI71Qly0UmCG9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381798; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YjdltdVdE4pucCkOhltMyL0WaP6ywhI790P0sm+p6dE=; b=MRZj5BxBqsSEvNRksictJ4rNQd3raxW0ODn+6QKx+WwMufDxBYUn79cfVEsdcUN45xq5 PWTAVGxFQ0sZOMdySyxHJE5dsfwTU1eu5FH/B0RGwj3qnD2VozyGeGAwqsB+sk7C5WJgZ bXT3roO5/1w87svrIEjXKHY7q3H+I/GeM7aP/GdQJDYQ/5nC0y1i/WXgia4nBc6udvr6E Qk9aTmiYlPbnEsG7syv4ACUuvh326eVxIfwxu/jIa6w0nydBzzNFBl5nxKL068D2cWvA1 O/miPInW/Zns+eknOMk/6/p2NtisXjAp2+ECv1Pd2OE3w5qOQoE3qO/OA3jUTv4zZCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="BWdhQ/Rs"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E1D4606A332; Fri, 4 Dec 2026 10:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BWdhQ/Rs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C11A1F000C2; Fri, 4 Dec 2026 10:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381798; bh=YjdltdVdE4pucCkOhltMyL0WaP6ywhI790P0sm+p6dE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BWdhQ/Rs2vw2iQ/5reV5xFypZTSsNNEAANclj4s4ydEpctS79XrW5+sFiATJf7tvF Ozb6yJKbp2qo1JM3a9zQqxnagY3iIKbVNSCF1LAccIMpJHqo5HB4qOkvq+KCEX0z8H jISV+tlZtMdGlXiM7JGj2HxOa88yHa4NAu1Cd+fg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Semyon Maryasin , Joshua Crofts , Zhang Lixu , Srinivas Pandruvada , Jonathan Cameron , Jiri Kosina , Sasha Levin Subject: [PATCH 6.18 177/703] HID: sensor-hub: Synchronize callback removal with raw events Date: Fri, 4 Dec 2026 19:01:16 +0900 Message-ID: <20261204100632.578985821@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Pandruvada [ Upstream commit abe10ad9c5fd868553b1262df403d5aaea3eff64 ] Raw-event processing holds pdata->lock across callback lookup and invocation, and takes dyn_callback_lock during lookup. Removal must prevent both active callbacks and future lookups before client state can be released. Take pdata->lock before dyn_callback_lock, matching raw-event order, and unlink the callback while holding both locks. This ensures active raw-event callbacks have finished and prevents future lookups. Fixes: 401ca24fb34a ("HID: sensors: introduce sensor framework") Reported-by: Semyon Maryasin Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/ Reviewed-by: Joshua Crofts Tested-by: Semyon Maryasin Tested-by: Zhang Lixu Signed-off-by: Srinivas Pandruvada Reviewed-by: Jonathan Cameron Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-sensor-hub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index faeb9c4536f52..9f14439cc0788 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -173,7 +173,9 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); unsigned long flags; - spin_lock_irqsave(&pdata->dyn_callback_lock, flags); + /* Serialize callback removal with raw-event callback execution. */ + spin_lock_irqsave(&pdata->lock, flags); + spin_lock(&pdata->dyn_callback_lock); list_for_each_entry(callback, &pdata->dyn_callback_list, list) if (callback->usage_id == usage_id && callback->hsdev == hsdev) { @@ -181,7 +183,8 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, kfree(callback); break; } - spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); + spin_unlock(&pdata->dyn_callback_lock); + spin_unlock_irqrestore(&pdata->lock, flags); return 0; } -- 2.53.0