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=1796388999; b=acCaBAunVJtHbE6+mjCkFUxkOCPBMe/Hqeg+6teWzVwwB0BrYbefTlr4F5WAfpjzF6xT ETFn/kanwdupfVFitBJBfmEN3DuHGG+1qncoK3bc/G/+hWv8GYMGRLBIvTm1gH/za4a6o FrXV/v1AuIyVgYhpWLVaXf1+FFwC6ITpFKYGM3Nqw/DKDpZdNI8uUPa17h9hETfDQ+E/B bxfpHm8TvOgN1KzWF6XfQeORTC26/E1KE0sWvYlpJAMxc1wO4lBlrDDgALoG2h5TjyIFI /khv181yhorEulVj7SFlqiVOAJuOQs/NrlZ80qFpFlkjB4arN9hAI6JIAGlSNgH0zsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388999; 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=+IpCCqYKZpDR1kDsOry0P6p4MVMo44rAFVBAZNAX1E0=; b=yIKBY7i6B0RXPDeqVVrsF8A/r+nUS6JU65jv+ZBxO/RlV23LP/ft2dX98qpHbYEWlmti 6I4u0vkiNrIsaJq56RiKsqZjbc78y/94x9mbECI1/buuMWPk4jRP1Vy2ov/TkY9Xm8Fs4 Zpqw24DPSDDSlOKarRDLNqm9w8VpGsrh11Tp2pMIl5s/LXLdsm7jpxLuFx9wBeKATUtr/ oF+Te4daQybWQIilCVdriiR9kDTthsD9nTLuOnHj9I3LrutODXwKLjK+BOf8FMI+H03wf pUd9PvcvvJM9q6/l6vDTGlCV91ehzBtPar3zm8xpL4wCFw2dEx5loka182w4SmDKyWA== 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=Vh2BH8Rz; 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 9D47A606A334; Fri, 4 Dec 2026 12:56:39 +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=Vh2BH8Rz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12E2C1F000C2; Fri, 4 Dec 2026 12:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388999; bh=+IpCCqYKZpDR1kDsOry0P6p4MVMo44rAFVBAZNAX1E0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Vh2BH8Rz0bSD8vjsBiaGksYFt5EyVhs1z7YjPtbYbH9gnG4lgoKRrNmsKgGmgXFZ3 cH7kLiJ2u+voEaWbwJxR4Q/3DIGBAhpodzj4v9XJZkzEHISuZVoZE7aIlaNzKhS475 OKrfIYMYw9xBW1OX3CL6rjCkKgO+OvqVKBeJJC4k= 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.1 0802/1059] HID: sensor-hub: Synchronize callback removal with raw events Date: Fri, 4 Dec 2026 19:05:33 +0900 Message-ID: <20261204100704.802129005@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 8874d368cd85f..764e0d16cec52 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