Skip to contentSkip to conversation

package/libinput: backport patch CVE-2026-50292

PATCH Applied Thomas Perale via buildroot 1 participant 2 messages Jun 11 – Jun 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libinput: backport patch CVE-2026-50292

- CVE-2026-50292:
In libinput before 1.30.4 and 1.31.x before 1.31.3, libinput-device- group unescaped phys output can inject udev properties leading to arbitrary root code execution

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-50292
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/8c15a01d1692cf0301b25ec2ead1d15d8176ad29
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/fc2262e1c1847021239065e84f39f15492ef05cc
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/b2bde9504d42a5976d76e1f27c640dc561fbd99b

---
 ...dont-call-function-in-macro-argument.patch | 30 +++++++
 ...e-control-characters-in-str-sanitize.patch | 90 +++++++++++++++++++
 ...oup-sanitize-phys-before-printing-it.patch | 90 +++++++++++++++++++
 package/libinput/libinput.mk                  |  5 ++
 4 files changed, 215 insertions(+)
 create mode 100644 package/libinput/0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch
 create mode 100644 package/libinput/0002-util-sanitize-control-characters-in-str-sanitize.patch
 create mode 100644 package/libinput/0003-libinput-device-group-sanitize-phys-before-printing-it.patch
package/libinput/0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch new file +30 -0
new file mode 100644
index 0000000000..61791278d0
@@ -0,0 +1,30 @@
+From 8c15a01d1692cf0301b25ec2ead1d15d8176ad29 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kacper=20Piwi=C5=84ski?= <[email protected]>
+Date: Sun, 29 Jun 2025 07:21:27 +0000
+Subject: [PATCH] util: don't call function in macro argument
+
+Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1252>
+Upstream: https://gitlab.freedesktop.org/libinput/libinput/-/commit/8c15a01d1692cf0301b25ec2ead1d15d8176ad29
+CVE: CVE-2026-50292
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/util-strings.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/util-strings.h b/src/util-strings.h
+index 870995f5..fc37ac4b 100644
+--- a/src/util-strings.h
++++ b/src/util-strings.h
+@@ -480,7 +480,8 @@ str_sanitize(const char *str)
+ 	if (!strchr(str, '%'))
+ 		return strdup(str);
+ 
+-	size_t slen = min(strlen(str), 512);
++	size_t slen = strlen(str);
++	slen = min(slen, 512);
+ 	char *sanitized = zalloc(2 * slen + 1);
+ 	const char *src = str;
+ 	char *dst = sanitized;
+-- 
+GitLab
+
package/libinput/0002-util-sanitize-control-characters-in-str-sanitize.patch new file +90 -0

90 lines not on this page · raw message

package/libinput/0003-libinput-device-group-sanitize-phys-before-printing-it.patch new file +90 -0

90 lines not on this page · raw message

package/libinput/libinput.mk +5 -0
index 1930a8cea5..bb7589e502 100644
@@ -19,6 +19,11 @@ LIBINPUT_CONF_OPTS = -Dtests=false -Dlibwacom=false -Ddocumentation=false
 # https://gitlab.freedesktop.org/libinput/libinput/-/commit/9e37bc0cfa4d975291e5a2899e148fb83526d4a2
 LIBINPUT_IGNORE_CVES += CVE-2026-35093 CVE-2026-35094
 
+# 0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch
+# 0002-util-sanitize-control-characters-in-str-sanitize.patch
+# 0003-libinput-device-group-sanitize-phys-before-printing-it.patch
+LIBINPUT_IGNORE_CVES += CVE-2026-50292
+
 ifeq ($(BR2_PACKAGE_LIBGTK3),y)
 LIBINPUT_CONF_OPTS += -Ddebug-gui=true
 LIBINPUT_DEPENDENCIES += libgtk3
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

In reply of:

Quoted 5 lines

- CVE-2026-50292:
In libinput before 1.30.4 and 1.31.x before 1.31.3, libinput-device- group unescaped phys output can inject udev properties leading to arbitrary root code execution

Quoted 7 lines

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-50292
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/8c15a01d1692cf0301b25ec2ead1d15d8176ad29
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/fc2262e1c1847021239065e84f39f15492ef05cc
- https://gitlab.freedesktop.org/libinput/libinput/-/commit/b2bde9504d42a5976d76e1f27c640dc561fbd99b

Applied to 2025.02.x. Thanks

Quoted 261 lines
---
 ...dont-call-function-in-macro-argument.patch | 30 +++++++
 ...e-control-characters-in-str-sanitize.patch | 90 +++++++++++++++++++
 ...oup-sanitize-phys-before-printing-it.patch | 90 +++++++++++++++++++
 package/libinput/libinput.mk                  |  5 ++
 4 files changed, 215 insertions(+)
 create mode 100644 package/libinput/0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch
 create mode 100644 package/libinput/0002-util-sanitize-control-characters-in-str-sanitize.patch
 create mode 100644 package/libinput/0003-libinput-device-group-sanitize-phys-before-printing-it.patch
package/libinput/0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch new file +30 -0
new file mode 100644
index 0000000000..61791278d0
@@ -0,0 +1,30 @@
+From 8c15a01d1692cf0301b25ec2ead1d15d8176ad29 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kacper=20Piwi=C5=84ski?= <[email protected]>
+Date: Sun, 29 Jun 2025 07:21:27 +0000
+Subject: [PATCH] util: don't call function in macro argument
+
+Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1252>
+Upstream: https://gitlab.freedesktop.org/libinput/libinput/-/commit/8c15a01d1692cf0301b25ec2ead1d15d8176ad29
+CVE: CVE-2026-50292
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/util-strings.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/util-strings.h b/src/util-strings.h
+index 870995f5..fc37ac4b 100644
+--- a/src/util-strings.h
++++ b/src/util-strings.h
+@@ -480,7 +480,8 @@ str_sanitize(const char *str)
+ 	if (!strchr(str, '%'))
+ 		return strdup(str);
+ 
+-	size_t slen = min(strlen(str), 512);
++	size_t slen = strlen(str);
++	slen = min(slen, 512);
+ 	char *sanitized = zalloc(2 * slen + 1);
+ 	const char *src = str;
+ 	char *dst = sanitized;
+-- 
+GitLab
+
package/libinput/0002-util-sanitize-control-characters-in-str-sanitize.patch new file +90 -0
new file mode 100644
index 0000000000..11107cc270
@@ -0,0 +1,90 @@
+From fc2262e1c1847021239065e84f39f15492ef05cc Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <[email protected]>
+Date: Mon, 1 Jun 2026 10:12:29 +1000
+Subject: [PATCH] util: sanitize control characters in str_sanitize()
+
+str_sanitize() only escaped '%' characters for format string safety.
+Device names from uinput devices can contain arbitrary bytes including
+ANSI escape sequences (ESC, 0x1b) and other control characters. When
+these strings are included in log messages and printed to a terminal,
+the escape sequences are interpreted by the terminal emulator. This
+could allow an attacker to manipulate terminal output (change colors,
+set window title, clear screen) when an administrator views libinput
+logs.
+
+Replace all control characters (0x00-0x1f and 0x7f) with '?' in
+addition to the existing '%' escaping. This prevents terminal escape
+sequence injection through device names in log output.
+
+Assisted-by: Claude:claude-opus-4-6
+(cherry picked from commit 71a2c5cae2a80a1e3bb29e3f3a07ccc3f3de5acb)
+
+Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1489>
+Upstream: https://gitlab.freedesktop.org/libinput/libinput/-/commit/fc2262e1c1847021239065e84f39f15492ef05cc
+CVE: CVE-2026-50292
+[thomas: remove tests]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/util-strings.h | 30 ++++++++++++++++++++++++------
+ test/test-utils.c  | 10 ++++++++++
+ 2 files changed, 34 insertions(+), 6 deletions(-)
+
+diff --git a/src/util-strings.h b/src/util-strings.h
+index 94236c48..3c662633 100644
+--- a/src/util-strings.h
++++ b/src/util-strings.h
+@@ -469,7 +469,10 @@ trunkname(const char *filename);
+ 
+ /**
+  * Return a copy of str with all % converted to %% to make the string
+- * acceptable as printf format.
++ * acceptable as printf format, and all non-NUL control characters
++ * (bytes 0x01-0x1f, 0x7f) replaced with '?' to prevent terminal
++ * escape sequence injection. NUL bytes are excluded implicitly
++ * because the string is null-terminated.
+  */
+ static inline char *
+ str_sanitize(const char *str)
+@@ -477,19 +480,34 @@ str_sanitize(const char *str)
+ 	if (!str)
+ 		return NULL;
+ 
+-	if (!strchr(str, '%'))
+-		return strdup(str);
+-
+ 	size_t slen = strlen(str);
+ 	slen = min(slen, 512);
++
++	bool needs_sanitization = false;
++	for (size_t i = 0; i < slen; i++) {
++		unsigned char c = str[i];
++		if (c == '%' || c < 0x20 || c == 0x7f) {
++			needs_sanitization = true;
++			break;
++		}
++	}
++	if (!needs_sanitization)
++		return strdup(str);
++
+ 	char *sanitized = zalloc(2 * slen + 1);
+ 	const char *src = str;
+ 	char *dst = sanitized;
+ 
+ 	for (size_t i = 0; i < slen; i++) {
+-		if (*src == '%')
++		unsigned char c = *src++;
++		if (c == '%') {
+ 			*dst++ = '%';
+-		*dst++ = *src++;
++			*dst++ = '%';
++		} else if (c < 0x20 || c == 0x7f) {
++			*dst++ = '?';
++		} else {
++			*dst++ = c;
++		}
+ 	}
+ 	*dst = '\0';
+ 
+-- 
+GitLab
+
package/libinput/0003-libinput-device-group-sanitize-phys-before-printing-it.patch new file +90 -0
new file mode 100644
index 0000000000..24ed91eae6
@@ -0,0 +1,90 @@
+From b2bde9504d42a5976d76e1f27c640dc561fbd99b Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <[email protected]>
+Date: Mon, 1 Jun 2026 10:48:24 +1000
+Subject: [PATCH] libinput-device-group: sanitize phys before printing it
+
+A malicious uinput device could set the phys value (via UI_SET_PHYS)
+to contain a '\n'. When the value is printed as part of the device group
+the udev rules will interpret it as separate property.
+
+Depending on the property this can cause local privilege escalation.
+
+Closes #1296
+
+Found-by: Csome
+(cherry picked from commit 76f0d8a7f57e2868882864b4611281f12f704b55)
+
+Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1489>
+Upstream: https://gitlab.freedesktop.org/libinput/libinput/-/commit/b2bde9504d42a5976d76e1f27c640dc561fbd99b
+CVE: CVE-2026-50292
+[thomas: backport]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ udev/libinput-device-group.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c
+index cdb38c0b..f9188406 100644
+--- a/udev/libinput-device-group.c
++++ b/udev/libinput-device-group.c
+@@ -109,7 +109,8 @@ wacom_handle_ekr(struct udev_device *device,
+ 
+ 	udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
+ 		struct udev_device *d;
+-		const char *path, *phys;
++		char *phys = NULL;
++		const char *path;
+ 		const char *pidstr, *vidstr;
+ 		int pid, vid, dist;
+ 
+@@ -124,7 +125,7 @@ wacom_handle_ekr(struct udev_device *device,
+ 
+ 		vidstr = udev_device_get_property_value(d, "ID_VENDOR_ID");
+ 		pidstr = udev_device_get_property_value(d, "ID_MODEL_ID");
+-		phys = udev_device_get_sysattr_value(d, "phys");
++		phys = str_sanitize(udev_device_get_sysattr_value(d, "phys"));
+ 
+ 		if (vidstr && pidstr && phys &&
+ 		    safe_atoi_base(vidstr, &vid, 16) &&
+@@ -142,6 +143,9 @@ wacom_handle_ekr(struct udev_device *dev
+ 			}
+ 		}
+ 
++		free(phys);
++		phys = NULL;
++
+ 		udev_device_unref(d);
+ 	}
+ 
+@@ -154,8 +154,8 @@ int main(int argc, char **argv)
+ 	int rc = 1;
+ 	struct udev *udev = NULL;
+ 	struct udev_device *device = NULL;
+-	const char *syspath,
+-	           *phys = NULL;
++	const char *syspath;
++	char *phys = NULL;
+ 	const char *product;
+ 	int bustype, vendor_id, product_id, version;
+ 	char group[1024];
+@@ -179,8 +180,7 @@ main(int argc, char **argv)
+ 	 * bit and use the remainder as device group identifier */
+ 	while (device != NULL) {
+ 		struct udev_device *parent;
+-
+-		phys = udev_device_get_sysattr_value(device, "phys");
++		phys = str_sanitize(udev_device_get_sysattr_value(device, "phys"));
+ 		if (phys)
+ 			break;
+ 
+@@ -251,6 +272,7 @@ int main(int argc, char **argv)
+ 
+ 	rc = 0;
+ out:
++	free(phys);
+ 	if (device)
+ 		udev_device_unref(device);
+ 	if (udev)
+-- 
+GitLab
+
package/libinput/libinput.mk +5 -0
index 1930a8cea5..bb7589e502 100644
@@ -19,6 +19,11 @@ LIBINPUT_CONF_OPTS = -Dtests=false -Dlibwacom=false -Ddocumentation=false
 # https://gitlab.freedesktop.org/libinput/libinput/-/commit/9e37bc0cfa4d975291e5a2899e148fb83526d4a2
 LIBINPUT_IGNORE_CVES += CVE-2026-35093 CVE-2026-35094
 
+# 0001-util-sanitize-control-characters-in-str-sanitize.patchdont-call-function-in-macro-argument.patch
+# 0002-util-sanitize-control-characters-in-str-sanitize.patch
+# 0003-libinput-device-group-sanitize-phys-before-printing-it.patch
+LIBINPUT_IGNORE_CVES += CVE-2026-50292
+
 ifeq ($(BR2_PACKAGE_LIBGTK3),y)
 LIBINPUT_CONF_OPTS += -Ddebug-gui=true
 LIBINPUT_DEPENDENCIES += libgtk3
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot