Input: uinput/uhid - disallow control characters in phys paths
Subsystems (3)
PATCH 1/1 Input: uinput/uhid - disallow control characters in phys paths
There is no good reason to support those, no physical device will ever produce those. Allowing \n in phys previously triggered CVE-2026-50292 in libinput - there the PHYS udev property value was used as part of another udev property value. The linebreak then caused the property to be split across two lines, allowing uinput devices to inject malicious properties. While the bug is squarely inlibinput's court there still isn't a good reason for control characters in uinput/uhid.
--- drivers/hid/uhid.c | 1 + drivers/input/misc/uinput.c | 1 + include/linux/input.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+)
drivers/hid/uhid.c +1 -0
@@ -513,16 +513,17 @@ static int uhid_dev_create2(struct uhid_device *uhid, ret =PTR_ERR (hid); goto err_free; }BUILD_BUG_ON (sizeof (hid->name) !=sizeof (ev->u.create2.name));strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq)); hid->ll_driver = &uhid_hid_driver; hid->bus = ev->u.create2.bus; hid->vendor = ev->u.create2.vendor; hid->product = ev->u.create2.product; hid->version = ev->u.create2.version;
drivers/input/misc/uinput.c +1 -0
@@ -998,16 +998,17 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, phys =strndup_user (p,1024 );if (IS_ERR (phys)) { retval =PTR_ERR (phys); goto out; }kfree (udev->dev->phys); +input_sanitize_phys (phys); udev->dev->phys = phys; goto out;case UI_BEGIN_FF_UPLOAD : retval =uinput_ff_upload_from_user (p, &ff_up);if (retval) goto out;
include/linux/input.h +15 -0
@@ -527,16 +527,31 @@ int input_set_keycode(struct input_dev *dev,bool input_match_device_id (const struct input_dev *dev,const struct input_device_id *id);void input_enable_softrepeat (struct input_dev *dev,int delay,int period);bool input_device_enabled (struct input_dev *dev); +/** +* input_sanitize_phys - replace invalid characters in a phys string +* @phys: the phys path to sanitize (modified in place) +* +* Replaces any control characters and non-ASCII characters with '?'. +**/ +static inline void input_sanitize_phys (char *phys) +{ +char *p; + +for (p = phys; *p; p++) +if (*p <0x20 || *p >0x7e ) + *p ='?' ; +} +extern const struct class input_class;/** * struct ff_device - force-feedback part of an input device * @upload: Called to upload an new effect into device * @erase: Called to erase an effect from device * @playback: Called to request device to start playing specified effect * @set_gain: Called to set specified gain
---
base-commit: 58717b2a1365d06c8c64b72aa948541b53fe31eb
change-id: 20260717-wip-uinput-sanitize-phys-abb6cf40e577
Best regards,
Signature · 1 line
Peter Hutterer <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch provides an incomplete mitigation for CVE-2026-50292. It sanitizes the phys property to prevent udev property injection via control characters (newlines), but completely fails to sanitize the name and uniq properties, which are also exported to uevents and controlled by userspace. --
--- Patch [1]: [PATCH] Input: uinput/uhid - disallow control characters in phys paths --- commit 1a76e90e7acc09a84a52efddc46e598419020a19
Author: Peter Hutterer <[email protected]>
Input: uinput/uhid - disallow control characters in phys paths
This commit sanitizes the phys property in uinput and uhid devices to replace control characters with '?'. This prevents userspace from injecting malicious udev properties via newlines, which previously triggered CVE-2026-50292.
drivers/hid/uhid.c static int uhid_dev_create2(struct uhid_device *uhid, · line 523
Quoted 11 lines
drivers/hid/uhid.c +1
-0@@ -518,6 +518,7 @@ static int uhid_dev_create2(struct uhid_device *uhid,strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq));
[Severity: High]
This isn't a bug introduced by this patch, but while this successfully mitigates CVE-2026-50292 for the phys property, does it still leave the name and uniq properties vulnerable?
In uhid_dev_create2(), the user-controlled ev->u.create2.name and ev->u.create2.uniq strings are copied directly without passing through a similar sanitization function.
Additionally, in drivers/input/misc/uinput.c:uinput_dev_setup(), the name property is also set without sanitization:
dev->name = kstrndup(setup.name, UINPUT_MAX_NAME_SIZE, GFP_KERNEL);
If a user with write access to /dev/uinput or /dev/uhid sets the name or uniq properties to strings containing newlines, wouldn't this still allow the injection of arbitrary udev environment variables when INPUT_ADD_HOTPLUG_VAR formats them for uevents?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 40 lines · On Fri, Jul 17, 2026 at 05:07:47AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch provides an incomplete mitigation for CVE-2026-50292. It sanitizes thephysproperty to prevent udev property injection via control characters (newlines), but completely fails to sanitize thenameanduniqproperties, which are also exported to uevents and controlled by userspace. ----- Patch [1]: [PATCH] Input: uinput/uhid - disallow control characters in phys paths --- commit
1a76e90e7acc09a84a52efddc46e598419020a19
Author: Peter Hutterer <[email protected]>Input: uinput/uhid - disallow control characters in phys paths
This commit sanitizes the phys property in uinput and uhid devices to replace control characters with '?'. This prevents userspace from injecting malicious udev properties via newlines, which previously triggered CVE-2026-50292.
drivers/hid/uhid.c static int uhid_dev_create2(struct uhid_device *uhid, · line 523
Quoted 11 lines
drivers/hid/uhid.c +1
-0@@ -518,6 +518,7 @@ static int uhid_dev_create2(struct uhid_device *uhid,strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq));[Severity: High]
This isn't a bug introduced by this patch, but while this successfully mitigates CVE-2026-50292 for the phys property, does it still leave the name and uniq properties vulnerable?In
uhid_dev_create2(), the user-controlledev->u.create2.nameandev->u.create2.uniqstrings are copied directly without passing through a similar sanitization function.Additionally, in drivers/input/misc/uinput.c:uinput_dev_setup(), the name property is also set without sanitization:
Quoted 6 lines
dev->name = kstrndup(setup.name, UINPUT_MAX_NAME_SIZE, GFP_KERNEL);If a user with write access to
/dev/uinputor/dev/uhidsets the name or uniq properties to strings containing newlines, wouldn't this still allow the injection of arbitrary udev environment variables whenINPUT_ADD_HOTPLUG_VARformats them for uevents?
name and uniq are controlled by the firmware and thus by the vendor and control characters (or at least non-ascii) may be legitimately present. There is no such thing as a sanitized name.
Cheers,
Peter
Dmitry Torokhov
maintainerHi Peter,
Quoted 43 lines · Peter Hutterer
Quoted 42 lines · On Fri, Jul 17, 2026 at 05:07:47AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch provides an incomplete mitigation for CVE-2026-50292. It sanitizes thephysproperty to prevent udev property injection via control characters (newlines), but completely fails to sanitize thenameanduniqproperties, which are also exported to uevents and controlled by userspace. ----- Patch [1]: [PATCH] Input: uinput/uhid - disallow control characters in phys paths --- commit
1a76e90e7acc09a84a52efddc46e598419020a19
Author: Peter Hutterer <[email protected]>Input: uinput/uhid - disallow control characters in phys paths
This commit sanitizes the phys property in uinput and uhid devices to replace control characters with '?'. This prevents userspace from injecting malicious udev properties via newlines, which previously triggered CVE-2026-50292.
drivers/hid/uhid.c static int uhid_dev_create2(struct uhid_device *uhid, · line 523
Quoted 11 lines
drivers/hid/uhid.c +1
-0@@ -518,6 +518,7 @@ static int uhid_dev_create2(struct uhid_device *uhid,strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq));[Severity: High]
This isn't a bug introduced by this patch, but while this successfully mitigates CVE-2026-50292 for the phys property, does it still leave the name and uniq properties vulnerable?In
uhid_dev_create2(), the user-controlledev->u.create2.nameandev->u.create2.uniqstrings are copied directly without passing through a similar sanitization function.Additionally, in drivers/input/misc/uinput.c:uinput_dev_setup(), the name property is also set without sanitization:
dev->name = kstrndup(setup.name, UINPUT_MAX_NAME_SIZE, GFP_KERNEL);
Quoted 8 lines
Quoted 4 lines
If a user with write access to
/dev/uinputor/dev/uhidsets the name or uniq properties to strings containing newlines, wouldn't this still allow the injection of arbitrary udev environment variables whenINPUT_ADD_HOTPLUG_VARformats them for uevents?name and uniq are controlled by the firmware and thus by the vendor and control characters (or at least non-ascii) may be legitimately present. There is no such thing as a sanitized name.
I think if we sanitize phys we should also sanitize the others because it is not only hardware controlled, we do have uinput and uhid. Also USB hardware might be hostile...
Thanks.
Signature · 1 line
Dmitry
Hi Peter!
Quoted 78 lines · Peter Hutterer
There is no good reason to support those, no physical device will ever produce those. Allowing \n in phys previously triggered CVE-2026-50292 in libinput - there the PHYS udev property value was used as part of another udev property value. The linebreak then caused the property to be split across two lines, allowing uinput devices to inject malicious properties. While the bug is squarely inlibinput's court there still isn't a good reason for control characters in uinput/uhid.
Signed-off-by Peter Hutterer <[email protected]>--- drivers/hid/uhid.c | 1 + drivers/input/misc/uinput.c | 1 + include/linux/input.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+)drivers/hid/uhid.c +1
-0@@ -513,16 +513,17 @@ static int uhid_dev_create2(struct uhid_device *uhid, ret =PTR_ERR (hid); goto err_free; }BUILD_BUG_ON (sizeof (hid->name) !=sizeof (ev->u.create2.name));strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq)); hid->ll_driver = &uhid_hid_driver; hid->bus = ev->u.create2.bus; hid->vendor = ev->u.create2.vendor; hid->product = ev->u.create2.product; hid->version = ev->u.create2.version;drivers/input/misc/uinput.c +1
-0@@ -998,16 +998,17 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, phys =strndup_user (p,1024 );if (IS_ERR (phys)) { retval =PTR_ERR (phys); goto out; }kfree (udev->dev->phys); +input_sanitize_phys (phys); udev->dev->phys = phys; goto out;case UI_BEGIN_FF_UPLOAD : retval =uinput_ff_upload_from_user (p, &ff_up);if (retval) goto out;include/linux/input.h +5
-0@@ -527,16 +527,31 @@ int input_set_keycode(struct input_dev *dev,bool input_match_device_id (const struct input_dev *dev,const struct input_device_id *id);void input_enable_softrepeat (struct input_dev *dev,int delay,int period);bool input_device_enabled (struct input_dev *dev); +/** +* input_sanitize_phys - replace invalid characters in a phys string +* @phys: the phys path to sanitize (modified in place) +* +* Replaces any control characters and non-ASCII characters with '?'.
include/linux/input.h int input_set_keycode(struct input_dev *dev, · line 549
Quoted 10 lines
include/linux/input.h +10
-0+**/ +static inline void input_sanitize_phys (char *phys) +{ +char *p; + +for (p = phys; *p; p++) +if (*p <0x20 || *p >0x7e ) + *p ='?' ; +} +
I would also be fine to just reject them in uinput, but I guess this is the less intrusive option.
Thanks a lot!
David
Quoted 16 lines
include/linux/input.h +0
-1extern const struct class input_class;/** * struct ff_device - force-feedback part of an input device * @upload: Called to upload an new effect into device * @erase: Called to erase an effect from device * @playback: Called to request device to start playing specified effect * @set_gain: Called to set specified gain --- base-commit:
58717b2a1365d06c8c64b72aa948541b53fe31eb
change-id: 20260717-wip-uinput-sanitize-phys-abb6cf40e577Best regards,
Signature · 1 line
Peter Hutterer <[email protected]>
Jiri Kosina
maintainerQuoted 91 lines · David Rheinsberg
Quoted 78 lines
There is no good reason to support those, no physical device will ever produce those. Allowing \n in phys previously triggered CVE-2026-50292 in libinput - there the PHYS udev property value was used as part of another udev property value. The linebreak then caused the property to be split across two lines, allowing uinput devices to inject malicious properties. While the bug is squarely inlibinput's court there still isn't a good reason for control characters in uinput/uhid.
Signed-off-by Peter Hutterer <[email protected]>--- drivers/hid/uhid.c | 1 + drivers/input/misc/uinput.c | 1 + include/linux/input.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+)drivers/hid/uhid.c +1
-0@@ -513,16 +513,17 @@ static int uhid_dev_create2(struct uhid_device *uhid, ret =PTR_ERR (hid); goto err_free; }BUILD_BUG_ON (sizeof (hid->name) !=sizeof (ev->u.create2.name));strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq)); hid->ll_driver = &uhid_hid_driver; hid->bus = ev->u.create2.bus; hid->vendor = ev->u.create2.vendor; hid->product = ev->u.create2.product; hid->version = ev->u.create2.version;drivers/input/misc/uinput.c +1
-0@@ -998,16 +998,17 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, phys =strndup_user (p,1024 );if (IS_ERR (phys)) { retval =PTR_ERR (phys); goto out; }kfree (udev->dev->phys); +input_sanitize_phys (phys); udev->dev->phys = phys; goto out;case UI_BEGIN_FF_UPLOAD : retval =uinput_ff_upload_from_user (p, &ff_up);if (retval) goto out;include/linux/input.h +5
-0@@ -527,16 +527,31 @@ int input_set_keycode(struct input_dev *dev,bool input_match_device_id (const struct input_dev *dev,const struct input_device_id *id);void input_enable_softrepeat (struct input_dev *dev,int delay,int period);bool input_device_enabled (struct input_dev *dev); +/** +* input_sanitize_phys - replace invalid characters in a phys string +* @phys: the phys path to sanitize (modified in place) +* +* Replaces any control characters and non-ASCII characters with '?'. include/linux/input.h int input_set_keycode(struct input_dev *dev, · line 549
Quoted 10 lines
include/linux/input.h +10
-0+**/ +static inline void input_sanitize_phys (char *phys) +{ +char *p; + +for (p = phys; *p; p++) +if (*p <0x20 || *p >0x7e ) + *p ='?' ; +} +Reviewed-by David Rheinsberg <[email protected]>
Quoted 1 line
I would also be fine to just reject them in uinput, but I guess this is the less intrusive option.
Thanks for the fix.
Dmitry, can you please Ack the above addition to input.h?
Thank you,
Signature · 2 lines
Jiri Kosina SUSE Labs
Dmitry Torokhov
maintainerQuoted 93 lines · Jiri Kosina
Quoted 91 lines · David Rheinsberg
Quoted 78 lines
There is no good reason to support those, no physical device will ever produce those. Allowing \n in phys previously triggered CVE-2026-50292 in libinput - there the PHYS udev property value was used as part of another udev property value. The linebreak then caused the property to be split across two lines, allowing uinput devices to inject malicious properties. While the bug is squarely inlibinput's court there still isn't a good reason for control characters in uinput/uhid.
Signed-off-by Peter Hutterer <[email protected]>--- drivers/hid/uhid.c | 1 + drivers/input/misc/uinput.c | 1 + include/linux/input.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+)drivers/hid/uhid.c +1
-0@@ -513,16 +513,17 @@ static int uhid_dev_create2(struct uhid_device *uhid, ret =PTR_ERR (hid); goto err_free; }BUILD_BUG_ON (sizeof (hid->name) !=sizeof (ev->u.create2.name));strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq)); hid->ll_driver = &uhid_hid_driver; hid->bus = ev->u.create2.bus; hid->vendor = ev->u.create2.vendor; hid->product = ev->u.create2.product; hid->version = ev->u.create2.version;drivers/input/misc/uinput.c +1
-0@@ -998,16 +998,17 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, phys =strndup_user (p,1024 );if (IS_ERR (phys)) { retval =PTR_ERR (phys); goto out; }kfree (udev->dev->phys); +input_sanitize_phys (phys); udev->dev->phys = phys; goto out;case UI_BEGIN_FF_UPLOAD : retval =uinput_ff_upload_from_user (p, &ff_up);if (retval) goto out;include/linux/input.h +5
-0@@ -527,16 +527,31 @@ int input_set_keycode(struct input_dev *dev,bool input_match_device_id (const struct input_dev *dev,const struct input_device_id *id);void input_enable_softrepeat (struct input_dev *dev,int delay,int period);bool input_device_enabled (struct input_dev *dev); +/** +* input_sanitize_phys - replace invalid characters in a phys string +* @phys: the phys path to sanitize (modified in place) +* +* Replaces any control characters and non-ASCII characters with '?'. include/linux/input.h int input_set_keycode(struct input_dev *dev, · line 549
Quoted 10 lines
include/linux/input.h +10
-0+**/ +static inline void input_sanitize_phys (char *phys) +{ +char *p; + +for (p = phys; *p; p++) +if (*p <0x20 || *p >0x7e ) + *p ='?' ; +} +Reviewed-by David Rheinsberg <[email protected]>
Quoted 5 lines
Quoted 1 line
I would also be fine to just reject them in uinput, but I guess this is the less intrusive option.
Thanks for the fix.
Dmitry, can you please Ack the above addition to
input.h?
Jiri, as I mentioned I believe that if we need to sanitize phys we should also sanitize other fields, especially given that they can be set by userspace.
I also wonder why it needs to be inline? And what is wrong with using isprint() here?
Thanks.
Signature · 1 line
Dmitry
Quoted 96 lines · Dmitry Torokhov
Quoted 95 lines · Jiri Kosina
Quoted 92 lines · David Rheinsberg
Quoted 78 lines
There is no good reason to support those, no physical device will ever produce those. Allowing \n in phys previously triggered CVE-2026-50292 in libinput - there the PHYS udev property value was used as part of another udev property value. The linebreak then caused the property to be split across two lines, allowing uinput devices to inject malicious properties. While the bug is squarely inlibinput's court there still isn't a good reason for control characters in uinput/uhid.
Signed-off-by Peter Hutterer <[email protected]>--- drivers/hid/uhid.c | 1 + drivers/input/misc/uinput.c | 1 + include/linux/input.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+)drivers/hid/uhid.c +1
-0@@ -513,16 +513,17 @@ static int uhid_dev_create2(struct uhid_device *uhid, ret =PTR_ERR (hid); goto err_free; }BUILD_BUG_ON (sizeof (hid->name) !=sizeof (ev->u.create2.name));strscpy (hid->name, ev->u.create2.name,sizeof (hid->name));BUILD_BUG_ON (sizeof (hid->phys) !=sizeof (ev->u.create2.phys));strscpy (hid->phys, ev->u.create2.phys,sizeof (hid->phys)); +input_sanitize_phys (hid->phys);BUILD_BUG_ON (sizeof (hid->uniq) !=sizeof (ev->u.create2.uniq));strscpy (hid->uniq, ev->u.create2.uniq,sizeof (hid->uniq)); hid->ll_driver = &uhid_hid_driver; hid->bus = ev->u.create2.bus; hid->vendor = ev->u.create2.vendor; hid->product = ev->u.create2.product; hid->version = ev->u.create2.version;drivers/input/misc/uinput.c +1
-0@@ -998,16 +998,17 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, phys =strndup_user (p,1024 );if (IS_ERR (phys)) { retval =PTR_ERR (phys); goto out; }kfree (udev->dev->phys); +input_sanitize_phys (phys); udev->dev->phys = phys; goto out;case UI_BEGIN_FF_UPLOAD : retval =uinput_ff_upload_from_user (p, &ff_up);if (retval) goto out;include/linux/input.h +5
-0@@ -527,16 +527,31 @@ int input_set_keycode(struct input_dev *dev,bool input_match_device_id (const struct input_dev *dev,const struct input_device_id *id);void input_enable_softrepeat (struct input_dev *dev,int delay,int period);bool input_device_enabled (struct input_dev *dev); +/** +* input_sanitize_phys - replace invalid characters in a phys string +* @phys: the phys path to sanitize (modified in place) +* +* Replaces any control characters and non-ASCII characters with '?'. include/linux/input.h int input_set_keycode(struct input_dev *dev, · line 549
Quoted 10 lines
include/linux/input.h +10
-0+**/ +static inline void input_sanitize_phys (char *phys) +{ +char *p; + +for (p = phys; *p; p++) +if (*p <0x20 || *p >0x7e ) + *p ='?' ; +} +Reviewed-by David Rheinsberg <[email protected]>I would also be fine to just reject them in uinput, but I guess this is the less intrusive option.
Quoted 7 lines
Quoted 3 lines
Thanks for the fix.
Dmitry, can you please Ack the above addition to
input.h?Jiri, as I mentioned I believe that if we need to sanitize phys we should also sanitize other fields, especially given that they can be set by userspace.
fwiw it's on my list, just hasn't made it to the top yet
Quoted 2 lines
I also wonder why it needs to be inline? And what is wrong with using
isprint()here?
inline - it's only used in two specific instances, if it wasn't for the uhid/uinput overlap it'd be barely worth a function. Happy to change though.
isprint - good point, will use that in the next version.
In regards to sanitizing the name/uniq though: I have a device here that has the copyright symbol in the device name:
Microsoft Microsoft® 2.4GHz Transceiver v9.0
That is outside isprint() and IMO we shouldn't mess with device names more than absolutely necessary wo we should probably strictly reduce this to control characters only (or maybe just \n)?
Cheers,
Peter