Re: [PATCH 2/3] input: ff-memless: Add trigger left/right in ml_combine_effects

[email protected] Thu, 30 Jul 2026 10:24:40 +0000
Newsgroups org.kernel.vger.linux-input
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Extending `struct ff_rumble_effect` breaks backward compatibility for legacy userspace applications by interpreting uninitialized union padding as valid rumble magnitudes.
--

--- Patch [2]: [PATCH 2/3] input: ff-memless: Add trigger left/right in ml_combine_effects ---
commit 3748260413928654275c7c17fc4ca45fccc0a9ee
Author: Daniel Bomar <[email protected]>

input: ff-memless: Add trigger left/right in ml_combine_effects

Combine the new trigger magnitudes alongside the existing strong and weak
magnitudes, so that drivers using input_ff_create_memless() receive them
the same way.

> diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
> index d1fefd1dfc0de..f6e7f5e93c687 100644
> --- a/drivers/input/ff-memless.c
> +++ b/drivers/input/ff-memless.c

[ ... ]

> @@ -269,6 +269,8 @@ static void ml_combine_effects(struct ff_effect *effect,
>  	case FF_RUMBLE:
>  		strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff;
>  		weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff;
> +		trigger_left = (u32)new->u.rumble.trigger_left * gain / 0xffff;
> +		trigger_right = (u32)new->u.rumble.trigger_right * gain / 0xffff;

[Severity: Critical]
Does interpreting these new fields break backward compatibility for legacy
userspace applications?

Because struct ff_rumble_effect is part of a union dominated by larger
structs in struct ff_effect, extending its size did not change the total size
of struct ff_effect.

Legacy applications allocating struct ff_effect on the stack, setting
type = FF_RUMBLE, and initializing only strong_magnitude and weak_magnitude
could unknowingly pass uninitialized bytes to the kernel.

Since this code actively scales and applies trigger_left and trigger_right,
wouldn't those uninitialized bytes from the stack result in random trigger
vibrations?

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2