Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guillaume Casal" <guillaume.casal.42@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 3/3] input: Add FF_TRIGGER_RUMBLE capability bit
Date: Thu, 30 Jul 2026 10:39:20 +0000	[thread overview]
Message-ID: <20260730103921.37CB91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260730095317.767418-4-guillaume.casal.42@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Extending `struct ff_rumble_effect` within the `ff_effect` union breaks backward compatibility for older userspace applications that use `EVIOCSFF` by exposing uninitialized memory as trigger magnitudes.
- [Low] Missing `FF_TRIGGER_RUMBLE` string representation in the `force` array in `hid-debug.c`.
- [Low] `FF_TRIGGER_RUMBLE` is not documented in the Force Feedback API documentation.
--

--- Patch [3]: [PATCH 3/3] input: Add FF_TRIGGER_RUMBLE capability bit ---
commit 454627a6a6ad091c91ae3a0477831268ea8fe178
Author: Guillaume Casal <guillaume.casal.42@gmail.com>

input: Add FF_TRIGGER_RUMBLE capability bit

This commit adds the FF_TRIGGER_RUMBLE capability bit to allow userspace to
discover if a device has motors under the triggers. The capability is added
as a read-only bit at 0x62 to avoid conflicting with the effect id space.

> diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> index 3d62603a387b9..677e9505a4aa3 100644
> --- a/include/uapi/linux/input.h
> +++ b/include/uapi/linux/input.h
> @@ -528,6 +528,7 @@ struct ff_effect {
>  
>  #define FF_GAIN		0x60
>  #define FF_AUTOCENTER	0x61
> +#define FF_TRIGGER_RUMBLE	0x62

[Severity: High]
Does extending struct ff_rumble_effect (as mentioned in the commit message)
cause a regression for older userspace applications using EVIOCSFF?

Legacy applications frequently allocate struct ff_effect on the stack,
initialize only known fields like strong_magnitude and weak_magnitude, and
pass the struct to the EVIOCSFF ioctl.

In drivers/input/evdev.c:evdev_do_ioctl():

    case EVIOC_MASK_SIZE(EVIOCSFF):
        if (input_ff_effect_from_user(p, size, &effect))
            return -EFAULT;

This copies the entire union size from userspace. If uninitialized stack
garbage is copied, it could be interpreted as trigger_left and trigger_right.

Then in drivers/input/ff-memless.c:ml_combine_effects():

    trigger_left = (u32)new->u.rumble.trigger_left * gain / 0xffff;
    trigger_right = (u32)new->u.rumble.trigger_right * gain / 0xffff;

These uninitialized fields are actively read and processed into the final
effect playback state. Could this result in random, unintended vibration of
the trigger motors?

[Severity: Low]
Is the FF_TRIGGER_RUMBLE string representation missing in the force array?

In drivers/hid/hid-debug.c:force:

    static const char *force[FF_CNT] = {
        [FF_RUMBLE] = "FF_RUMBLE",

Without adding [FF_TRIGGER_RUMBLE] = "FF_TRIGGER_RUMBLE" here,
names[EV_FF][0x62] evaluates to NULL. This causes hid_resolv_event() to fall
back to printing the raw hex value ('0062') instead of 'FF_TRIGGER_RUMBLE'
in debugfs.

[Severity: Low]
Is FF_TRIGGER_RUMBLE missing from the Force Feedback API documentation?

Documentation/input/ff.rst:Querying device capabilities lists supported
EV_FF capability bits:

    - FF_GAIN    gain is adjustable
    - FF_AUTOCENTER  autocenter is adjustable

Since this commit introduces a new capability, should it be documented here
so userspace developers know how to discover trigger rumble support?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260730095317.767418-1-guillaume.casal.42@gmail.com?part=3

  reply	other threads:[~2026-07-30 10:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  9:53 [PATCH 0/3] input: force feedback for trigger rumble motors Guillaume Casal
2026-07-30  9:53 ` [PATCH 1/3] input: uapi: Add trigger_left and trigger_right to ff_rumble_effect struct Guillaume Casal
2026-07-30 10:04   ` sashiko-bot
2026-07-30  9:53 ` [PATCH 2/3] input: ff-memless: Add trigger left/right in ml_combine_effects Guillaume Casal
2026-07-30 10:24   ` sashiko-bot
2026-07-30  9:53 ` [PATCH 3/3] input: Add FF_TRIGGER_RUMBLE capability bit Guillaume Casal
2026-07-30 10:39   ` sashiko-bot [this message]
2026-07-30 13:40 ` [PATCH v2 0/4] input: force feedback for trigger rumble motors Guillaume Casal
2026-07-30 13:40   ` [PATCH v2 1/4] input: Add FF_TRIGGER_RUMBLE effect type Guillaume Casal
2026-07-30 13:53     ` sashiko-bot
2026-07-30 13:40   ` [PATCH v2 2/4] input: ff-memless: Handle FF_TRIGGER_RUMBLE Guillaume Casal
2026-07-30 13:40   ` [PATCH v2 3/4] HID: debug: Add FF_TRIGGER_RUMBLE name Guillaume Casal
2026-07-30 13:40   ` [PATCH v2 4/4] Documentation: input: Document FF_TRIGGER_RUMBLE Guillaume Casal

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=20260730103921.37CB91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=guillaume.casal.42@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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