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=1796386266; b=OyrBQKTbN2Djkbq8+UnExZVweZE51k3WphVQqRDKfTb462abUiG7vXQ0THWPqUmzG/QK gg1keXSkuf19JOW2ZGHmDGXSux+1ypBOIahZYslXxCyHthTd9mjmycicMWymCUIdeJzpt yi9c9dweTOeG0pepZ4eVk41cOXqw51AC543pzmKKQ9Kiu8S8hojzAds3DZl96UdlbqxEA Se4LUqu/7Djj71X2lEdaXAsc/Nvw2NSGuOte7xHCTTf0tuVoDkiZ1G7j7NClx23IYthtl YIJsyJkFLv6NS1/oTakzEvIZLXzefEcCK0cS7DQoWRVpZ+zdjA43QKA/xZRPrugyLUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386266; 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=aOUbdQZKpwBc8Xq5p1Am1NkH7otLSlodZbevqJ9/eM0=; b=fUObK1DSk2yH3EcoPbvDEO+BfcMToyxzB+XT4kUreQ41Esl2ZkxD/g90JrN43imyNIn+ Az3Dg86NESo+mRU1TZtqENfC3icPdHeMZXiwfXq+yWwDh2eIc99BoZazk3G4VjzhCMWmG EGidUAQlQIoOtOOhmhUDkxorSOBhH1qtmUTNLd9oOVILGCdMCByZYUGVC3av26qihdvi0 r9UAAcYPPE7RrCDRyFxrB68Lo+3Uu8RpjPNTdgFnd6a14wGoDvDzUEjrknkoJR7Lw9nSi 2r3Nu0qyRJ/vgcrybTRc+cke7/b9DhZPartzWxkh6H7nDpm48TjC40ixPzWUSN4pHhQ== 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=WntyBgKo; 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 974A2606A684; Fri, 4 Dec 2026 12:11:06 +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=WntyBgKo Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA3651F00937; Fri, 4 Dec 2026 12:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386266; bh=aOUbdQZKpwBc8Xq5p1Am1NkH7otLSlodZbevqJ9/eM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WntyBgKosBQH1TrELlfMRLvnJ/xwK6kr5fgWdBBiTrEZQ+uyyyMDY7gN2dkZwIYXf a1lN75veDA/kWiIGSOq5/2f8TQXi2iTGUcu7KAenZfBquHaCl3GwLaNLG7Y3dw+e3D sUSrPgb8gSZBTV8FKa9FVPuBqYwO16MFgyAsxmZo= 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.6 0890/1167] HID: sensor-hub: Synchronize callback removal with raw events Date: Fri, 4 Dec 2026 19:05:17 +0900 Message-ID: <20261204100725.373929789@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 316654294f25b..fd4597eeb104e 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