* [PATCH v1 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly
2026-08-31 15:21 [PATCH v1 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
@ 2026-08-31 15:21 ` Iván Ezequiel Rodriguez
2026-08-31 15:21 ` [PATCH v1 2/2] Input: uinput: align UI_ABS_SETUP validation with uapi docs Iván Ezequiel Rodriguez
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Iván Ezequiel Rodriguez @ 2026-08-31 15:21 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Iván Ezequiel Rodriguez
Return the error from input_ff_effect_from_user() instead of always
mapping failures to -EFAULT, so wrong buffer sizes surface as -EINVAL.
Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
---
drivers/input/evdev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3a718d600006..27bcf4f099be 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -1180,8 +1180,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
return str_to_user(dev->uniq, size, p);
case EVIOC_MASK_SIZE(EVIOCSFF):
- if (input_ff_effect_from_user(p, size, &effect))
- return -EFAULT;
+ error = input_ff_effect_from_user(p, size, &effect);
+ if (error)
+ return error;
error = input_ff_upload(dev, &effect, file);
if (error)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v1 2/2] Input: uinput: align UI_ABS_SETUP validation with uapi docs
2026-08-31 15:21 [PATCH v1 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
2026-08-31 15:21 ` [PATCH v1 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly Iván Ezequiel Rodriguez
@ 2026-08-31 15:21 ` Iván Ezequiel Rodriguez
2026-08-31 19:27 ` [PATCH v2 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Iván Ezequiel Rodriguez @ 2026-08-31 15:21 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Iván Ezequiel Rodriguez
Return -EINVAL for out-of-range axis codes and reject ABS_MT_SLOT
configurations whose minimum is not zero, as documented in uapi.
Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
---
drivers/input/misc/uinput.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d32fa4b508fc..e05c80182252 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -424,6 +424,13 @@ static int uinput_validate_absinfo(struct input_dev *dev, unsigned int code,
min = abs->minimum;
max = abs->maximum;
+ if (code == ABS_MT_SLOT && min != 0) {
+ printk(KERN_DEBUG
+ "%s: abs[%02x] minimum must be 0\n",
+ UINPUT_NAME, code);
+ return -EINVAL;
+ }
+
if ((min != 0 || max != 0) && max < min) {
printk(KERN_DEBUG
"%s: invalid abs[%02x] min:%d max:%d\n",
@@ -524,7 +531,7 @@ static int uinput_abs_setup(struct uinput_device *udev,
return -EFAULT;
if (setup.code > ABS_MAX)
- return -ERANGE;
+ return -EINVAL;
dev = udev->dev;
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 0/2] Input: evdev/uinput errno alignment
2026-08-31 15:21 [PATCH v1 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
2026-08-31 15:21 ` [PATCH v1 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly Iván Ezequiel Rodriguez
2026-08-31 15:21 ` [PATCH v1 2/2] Input: uinput: align UI_ABS_SETUP validation with uapi docs Iván Ezequiel Rodriguez
@ 2026-08-31 19:27 ` Iván Ezequiel Rodriguez
2026-08-31 19:27 ` [PATCH v2 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly Iván Ezequiel Rodriguez
2026-08-31 19:27 ` [PATCH v2 2/2] Input: uinput: return -EINVAL for out-of-range UI_ABS_SETUP axis code Iván Ezequiel Rodriguez
4 siblings, 0 replies; 6+ messages in thread
From: Iván Ezequiel Rodriguez @ 2026-08-31 19:27 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Iván Ezequiel Rodriguez
Two small fixes making evdev and uinput report the error codes their
uapi documentation promises.
Changes since v1:
- Dropped the ABS_MT_SLOT "minimum must be 0" validation from patch 2.
It was a userspace regression: uinput_create_device() already calls
input_mt_init_slots() for devices declaring ABS_MT_SLOT, and
input_mt_init_slots() overwrites the axis with
input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0).
A non-zero minimum is therefore accepted today and silently
corrected, so rejecting it with -EINVAL would break existing
callers.
- Patch 2 is now limited to the -ERANGE to -EINVAL change and its
commit message was reworded accordingly.
- Patch 1 is unchanged.
v1: https://lore.kernel.org/linux-input/20260831152156.166514-1-ivanrwcm25@gmail.com/
Iván Ezequiel Rodriguez (2):
Input: evdev: propagate EVIOCSFF copy errors correctly
Input: uinput: return -EINVAL for out-of-range UI_ABS_SETUP axis code
drivers/input/evdev.c | 5 +++--
drivers/input/misc/uinput.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly
2026-08-31 15:21 [PATCH v1 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
` (2 preceding siblings ...)
2026-08-31 19:27 ` [PATCH v2 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
@ 2026-08-31 19:27 ` Iván Ezequiel Rodriguez
2026-08-31 19:27 ` [PATCH v2 2/2] Input: uinput: return -EINVAL for out-of-range UI_ABS_SETUP axis code Iván Ezequiel Rodriguez
4 siblings, 0 replies; 6+ messages in thread
From: Iván Ezequiel Rodriguez @ 2026-08-31 19:27 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Iván Ezequiel Rodriguez
Return the error from input_ff_effect_from_user() instead of always
mapping failures to -EFAULT, so wrong buffer sizes surface as -EINVAL.
Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
---
drivers/input/evdev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3a718d600006..27bcf4f099be 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -1180,8 +1180,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
return str_to_user(dev->uniq, size, p);
case EVIOC_MASK_SIZE(EVIOCSFF):
- if (input_ff_effect_from_user(p, size, &effect))
- return -EFAULT;
+ error = input_ff_effect_from_user(p, size, &effect);
+ if (error)
+ return error;
error = input_ff_upload(dev, &effect, file);
if (error)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 2/2] Input: uinput: return -EINVAL for out-of-range UI_ABS_SETUP axis code
2026-08-31 15:21 [PATCH v1 0/2] Input: evdev/uinput errno alignment Iván Ezequiel Rodriguez
` (3 preceding siblings ...)
2026-08-31 19:27 ` [PATCH v2 1/2] Input: evdev: propagate EVIOCSFF copy errors correctly Iván Ezequiel Rodriguez
@ 2026-08-31 19:27 ` Iván Ezequiel Rodriguez
4 siblings, 0 replies; 6+ messages in thread
From: Iván Ezequiel Rodriguez @ 2026-08-31 19:27 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Iván Ezequiel Rodriguez
uinput_abs_setup() rejects an axis code above ABS_MAX with -ERANGE, but
the UI_ABS_SETUP documentation in include/uapi/linux/uinput.h states the
ioctl may only fail with -EINVAL, -ENOMEM or -EFAULT. An out-of-range
code is exactly the "incorrect values" case described there, and every
other validation failure in this path already returns -EINVAL.
Return -EINVAL so the code matches its documented uapi contract.
Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
---
drivers/input/misc/uinput.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d32fa4b508fc..7d6266c2bd84 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -524,7 +524,7 @@ static int uinput_abs_setup(struct uinput_device *udev,
return -EFAULT;
if (setup.code > ABS_MAX)
- return -ERANGE;
+ return -EINVAL;
dev = udev->dev;
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread