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=1796497922; b=fmIBBuZG7bNUgp3xbDVf3g13XiaRw9cgw0NuWM2MuTu+i0gOjRISMTANMW1f8IKTPlkF L36cwjzcHHidEyovyQdtFSTbVZBBblgRF90r+hCAtJcqrYLbCX2rqQaHEzmOfrd+2ek4/ Nw60kxyUEPA/LbK84j5pNiY+KajIg+IH5DEHVyIURWj5ASaRwufkWkTjLcwf/BrfANuqq MxAtnuMCV+P4bpD856D1mnF57xa5+4Li8OkMI1cDdLPVhgWYNw4NRsJKVPoQ9g/vWe2pV mfj/xXx4UonFNVmK1QvaAmlp9aHPCs4u9hlOBRdOLTEgtUICLZV588m/t8Ji5H3wZ0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796497922; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=/ZVHF1zJUz2LNCJrG74CX0eWR6SjI4oU7Rwf0y5K1BA=; b=s5O6+JnAnWgjdIKP7Sf06a50XJOD0Uoi+e38JQRIyP+6d1oDUgYBztMFLzeJIU4czc9k Z323PbZfaZb44RWuJAHR8NcXq/2X35VSLJ9FuN/lilf7M0Bvb8qNBBCzEcqOdUDQnu+At 9OMlwM8xLPwYOSgy12PbMggLjFjABBc/YqpmPQhSrWOYO6IWZBbNAH6J4gDVAMgV0Agwz LtOYrNy3HvfPBPuwxmB2ICMXthobY4F7yTkmcgkRCwDM1Hw3bbO/o3Y03YM6eL24/opwy q/CkpH2+qQxdu9rzo34yQx7B+0gIUkgiY/itob7kdbkvv35zTJSOP+8oCU7K4K4NEMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G4XwgAWm; 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 E71D3606A31F for ; Sat, 5 Dec 2026 19:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G4XwgAWm Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADA861F00936; Sat, 5 Dec 2026 19:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796497921; bh=/ZVHF1zJUz2LNCJrG74CX0eWR6SjI4oU7Rwf0y5K1BA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=G4XwgAWmKZGRCt/wrn4xoDZaNng4sE+3LdYjAwg4DiBiTiQHLVwFROZEKevqtOjDs W9vGAE2cWh3GyKakZ5GZbb8rIAvT5T8B+J4XDRzN9s6w+csNbYMXO/y15b//42cGpc 1ayOZIb/6FRBCEHUfs3EFcnlw/ipoCUxfcrZ7u/IgC9bY8S1UaIkmUiGj0CDK31EIM nDfwH3fGWQSTdkhNDA1NNYDStg5f01hhSpsm4S7ERqwyiTJW219q75U8zcmONproAE 6A/PFP7QQ+DMWldMzWkXAiwVSlvq+Nh4wmJK0lC3CLBNnqLhMcjQQTcA4dvYinYcLt h40kDcSzX1+eQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7 05/13] HID: Add hid-plugin framework for loadable plugin modules Reply-To: sashiko-reviews@lists.linux.dev To: "Rong Zhang" Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261206-hid-haptic-kmod-v7-5-3eea47035836@rong.moe> References: <20261206-hid-haptic-kmod-v7-0-3eea47035836@rong.moe> <20261206-hid-haptic-kmod-v7-5-3eea47035836@rong.moe> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 19:12:01 +0000 X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Low] HID: hid-plugin kernel-doc claims Any context for sleeping helpers - [Low] HID: struct hid_plugin kernel-doc omits non-devm allocation constraint - [Low] hid: __hid_device_probe() calls hid_plugin_prune() without stopping HID I/O -- commit 9e6de1f1db3878e50979912e55cc4cba6f26556d Author: Rong Zhang HID: Add hid-plugin framework for loadable plugin modules This commit introduces the hid-plugin framework so HID drivers can connect to optional loadable or builtin usage-page plugins, requesting plugin modules asynchronously and reprobing deferred devices once the plugin registers. Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdilzc35= inqda3exwzs3tk3ff@oagat6g46zto/ > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c > index ceff3c80d9962..318ddb9c76cbb 100644 > --- a/drivers/hid/hid-core.c > +++ b/drivers/hid/hid-core.c [ ... ] > @@ -2857,7 +2858,10 @@ static int __hid_device_probe(struct hid_device *h= dev, struct hid_driver *hdrv) > hid_device_io_stop(hdev); > devres_release_group(&hdev->dev, hdev->devres_group_id); > hid_close_report(hdev); > + hid_plugin_cleanup(hdev); > hdev->driver =3D NULL; > + } else { > + hid_plugin_prune(hdev); > } > =20 > return ret; [Severity: Low] Can hid_plugin_prune() race with incoming HID reports when a driver returns from probe() with hdev->io_started still set? Drivers such as hidpp_probe() in drivers/hid/hid-logitech-hidpp.c call hid_device_io_start(hdev) and return 0 without calling hid_device_io_stop(). Because __hid_input_report() serializes against probe through hdev->driver_input_lock rather than device_lock(&hdev->dev), an input report handler calling hid_plugin_to_priv() can race with hid_plugin_prune(): CPU0 CPU1 __hid_device_probe() hdrv->probe() hid_device_io_start(hdev) return 0 hid_plugin_prune(hdev) hid_plugin_disconnect_with_err() __hid_input_report() down_trylock(&driver_input_lock) hid_plugin_to_priv(hdev, id) plugin->disconnect(hdev, priv) hdev->plugins[id] =3D ERR_PTR() module_put(plugin->owner) ... uses priv <-- use-after-free No current in-tree driver triggers this today, since the drivers that leave hdev->io_started set do not call hid_plugin_to_priv() from report handlers, but it breaks the lockless hid_plugin_to_priv() contract for future callers. Calling hid_device_io_stop(hdev) when hdev->io_started is true before disconnecting unbound plugins would serialize pruning against __hid_input_report(), and hid_device_probe() immediately re-enables input on return. [ ... ] > diff --git a/drivers/hid/hid-plugin.h b/drivers/hid/hid-plugin.h > new file mode 100644 > index 0000000000000..2d411e9702850 > --- /dev/null > +++ b/drivers/hid/hid-plugin.h [ ... ] > + * @connect: Called on plugin connection to allocate and initialize the > + * plugin's private data. Usually the private data stores a pointer > + * to the plugin itself to expose plugin-specific methods. Context: > + * process context during driver probe. > + * @disconnect: Called on plugin disconnection to release all allocated > + * resources. Must be safe to call no matter the plugin is > + * currently bound or not. Context: process context during driver > + * probe or removal. [Severity: Low] Should the kernel-doc for @connect and @disconnect document that plugin private data and resources freed in @disconnect must not be allocated with devm_* tied to &hdev->dev, and that HID reports are already closed when @disconnect runs during cleanup? Both __hid_device_probe() on failure and hid_device_remove() call devres_release_group() and hid_close_report() before hid_plugin_cleanup(). A plugin using devm_* on &hdev->dev would hit a use-after-free or double free in @disconnect on teardown, and would leak those allocations on early hid_plugin_disconnect() or hid_plugin_prune(). [ ... ] > + * Context: Any context outside the plugin module. Can only be called wh= ile > + * probing or removing @hdev driver. > + */ > +static __always_inline void hid_plugin_disconnect(struct hid_device *hde= v, enum hid_plugin_id id) [Severity: Low] Should the Context annotations for hid_plugin_disconnect(), hid_plugin_prune(), hid_plugin_cleanup(), and hid_plugin_exit() specify process context instead of any context? __hid_plugin_disconnect(), __hid_plugin_prune(), and __hid_plugin_cleanup() all assert device_lock(&hdev->dev) and invoke plugin->bound() or plugin->disconnect(), which are documented as process context and may sleep. __hid_plugin_exit() calls disable_delayed_work_sync(), which also sleeps. In addition, hid_plugin_connect() and hid_plugin_disconnect() do not note that HID input report handling must not be active (driver_input_lock must be held) while mutating hdev->plugins[id]. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206-hid-haptic= -kmod-v7-0-3eea47035836@rong.moe?part=3D5