From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Jiri Kosina" <jikos@kernel.org>,
"Benjamin Tissoires" <bentiss@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Julia Lawall" <Julia.Lawall@inria.fr>,
"Nicolas Palix" <nicolas.palix@imag.fr>,
"Filipe Laíns" <lains@riseup.net>,
"Bastien Nocera" <hadess@hadess.net>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, cocci@inria.fr
Subject: [PATCH 00/21] HID: fix racy force feedback initialization via .input_configured()
Date: Mon, 03 Aug 2026 11:46:25 -0700 [thread overview]
Message-ID: <20260803-hid-ff-input-configured-v1-0-1dc9bbacd88c@gmail.com> (raw)
When a HID driver calls hid_hw_start() with the HID_CONNECT_HIDINPUT
flag (included in HID_CONNECT_DEFAULT), the HID core immediately registers
the input device with the input subsystem, making it live and accessible to
userspace.
Historically, many HID drivers initialized force-feedback capabilities (via
input_ff_create_memless() or custom workqueues) in their probe() callback
after calling hid_hw_start(). This introduces a window where userspace can
open the input node and trigger force-feedback ioctls before the driver has
finished preparing its private structures or workqueues, leading to potential
NULL pointer dereferences and race conditions.
To eliminate this anti-pattern across the subsystem, this series:
- Enhances the HID core to automatically handle driver force-feedback
initialization during input device registration.
- Refactors individual HID drivers to perform all force-feedback setup
inside the .input_configured() callback, ensuring the input device is
fully prepared before it is exposed to userspace.
- Adds documentation and a Coccinelle script to prevent future regressions.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (21):
HID: core: automatically initialize generic FF if no other FF is present
HID: add documentation and Coccinelle script for FF registration race
HID: axff: move FF initialization to .input_configured()
HID: betop: move FF initialization to .input_configured()
HID: bigben: move FF initialization to .input_configured()
HID: dragonrise: move FF initialization to .input_configured()
HID: emsff: move FF initialization to .input_configured()
HID: gaff: move FF initialization to .input_configured()
HID: stadia: use open/close to manage workqueue lifecycle
HID: stadia: move FF initialization to .input_configured()
HID: holtek: move FF initialization to .input_configured()
HID: move generic FF initialization into hidinput_connect()
HID: microsoft: move FF initialization to .input_configured()
HID: pantherlord: move FF initialization to .input_configured()
HID: thrustmaster: move FF initialization to .input_configured()
HID: zeroplus: move FF initialization to .input_configured()
HID: mayflash: move FF initialization to .input_configured()
HID: smartjoyplus: move FF initialization to .input_configured()
HID: megaworld: move FF initialization to .input_configured()
HID: logitech-hidpp: move FF initialization to .input_configured()
HID: haptic: move FF initialization into .input_configured()
Documentation/hid/hidintro.rst | 50 ++++++++++++
drivers/hid/hid-axff.c | 40 +++-------
drivers/hid/hid-betopff.c | 33 +++-----
drivers/hid/hid-bigbenff.c | 89 ++++++++++-----------
drivers/hid/hid-core.c | 8 +-
drivers/hid/hid-dr.c | 66 ++++-----------
drivers/hid/hid-emsff.c | 50 ++----------
drivers/hid/hid-gaff.c | 53 +++----------
drivers/hid/hid-google-stadiaff.c | 112 ++++++++++----------------
drivers/hid/hid-haptic.c | 45 ++++-------
drivers/hid/hid-haptic.h | 6 +-
drivers/hid/hid-holtekff.c | 46 +++--------
drivers/hid/hid-input.c | 21 ++++-
drivers/hid/hid-logitech-hidpp.c | 36 +++++----
drivers/hid/hid-megaworld.c | 51 +++---------
drivers/hid/hid-mf.c | 77 +++++++-----------
drivers/hid/hid-microsoft.c | 38 ++-------
drivers/hid/hid-multitouch.c | 10 +--
drivers/hid/hid-pl.c | 150 +++++++++++++++--------------------
drivers/hid/hid-sjoy.c | 83 ++++++++-----------
drivers/hid/hid-tmff.c | 47 ++++-------
drivers/hid/hid-zpff.c | 43 ++--------
include/linux/hid.h | 2 +-
scripts/coccinelle/hid/ff_race.cocci | 34 ++++++++
24 files changed, 465 insertions(+), 725 deletions(-)
---
base-commit: 415606a7be939835db9b0d6b711887586646346d
change-id: 20260802-hid-ff-input-configured-397bc1503256
Thanks.
--
Dmitry
next reply other threads:[~2026-08-03 18:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:46 Dmitry Torokhov [this message]
2026-08-03 18:46 ` [PATCH 01/21] HID: core: automatically initialize generic FF if no other FF is present Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 02/21] HID: add documentation and Coccinelle script for FF registration race Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 03/21] HID: axff: move FF initialization to .input_configured() Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 04/21] HID: betop: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 05/21] HID: bigben: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 06/21] HID: dragonrise: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 07/21] HID: emsff: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 08/21] HID: gaff: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 09/21] HID: stadia: use open/close to manage workqueue lifecycle Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 10/21] HID: stadia: move FF initialization to .input_configured() Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 11/21] HID: holtek: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 12/21] HID: move generic FF initialization into hidinput_connect() Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 13/21] HID: microsoft: move FF initialization to .input_configured() Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 14/21] HID: pantherlord: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 15/21] HID: thrustmaster: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 16/21] HID: zeroplus: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 17/21] HID: mayflash: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 18/21] HID: smartjoyplus: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 19/21] HID: megaworld: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 20/21] HID: logitech-hidpp: " Dmitry Torokhov
2026-08-03 18:46 ` [PATCH 21/21] HID: haptic: move FF initialization into .input_configured() Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260803-hid-ff-input-configured-v1-0-1dc9bbacd88c@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=Julia.Lawall@inria.fr \
--cc=bentiss@kernel.org \
--cc=cocci@inria.fr \
--cc=corbet@lwn.net \
--cc=hadess@hadess.net \
--cc=jikos@kernel.org \
--cc=lains@riseup.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.palix@imag.fr \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox