Skip to contentSkip to conversation

package/libblockdev: patch CVE-2026-111581

PATCH Applied Thomas Perale via buildroot 1 participant 2 messages Nov 16 – Nov 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libblockdev: patch CVE-2026-111581

This fixes the following vulnerability:

- CVE-2026-111581:
A flaw was found in libblockdev. The bd_fs_ntfs_set_label() and bd_fs_vfat_set_label() functions pass caller-supplied label values as bare positional arguments to the ntfslabel and fatlabel utilities without end-of-options separators or input validation for values beginning with a dash. This allows a label starting with '-' to be interpreted as a command-line flag by the spawned tool, potentially bypassing safety checks or causing unintended operations. This is reachable by unprivileged local users through the udisks2 Filesystem.SetLabel() D-Bus method without administrator authentication.

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-111581
- https://github.com/storaged-project/libblockdev/commit/4ef6b2b4798a46566fe8815eaabd163205be20bd
- https://github.com/storaged-project/libblockdev/commit/bf990ef6d720b4a0d3cb22c572f473fc5dc7f83c

---
 ...ect-NTFS-labels-starting-with-a-dash.patch | 49 ++++++++++++
 ...ls-from-being-interpreted-as-options.patch | 78 +++++++++++++++++++
 package/libblockdev/libblockdev.mk            |  4 +
 3 files changed, 131 insertions(+)
 create mode 100644 package/libblockdev/0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch
 create mode 100644 package/libblockdev/0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch
package/libblockdev/0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch new file +49 -0
new file mode 100644
index 0000000000..9a4613f421
@@ -0,0 +1,49 @@
+From 4ef6b2b4798a46566fe8815eaabd163205be20bd Mon Sep 17 00:00:00 2001
+From: Vojtech Trefny <[email protected]>
+Date: Tue, 3 Nov 2026 15:39:58 +0100
+Subject: [PATCH] fs: Reject NTFS labels starting with a dash
+
+Fixes CVE-2026-111581.
+
+CVE: CVE-2026-111581
+Upstream: https://github.com/storaged-project/libblockdev/commit/4ef6b2b4798a46566fe8815eaabd163205be20bd
+[thomas: drop tests and backport context]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/plugins/fs/ntfs.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/src/plugins/fs/ntfs.c b/src/plugins/fs/ntfs.c
+index 424f606..78b56d0 100644
+--- a/src/plugins/fs/ntfs.c
++++ b/src/plugins/fs/ntfs.c
+@@ -221,6 +221,9 @@ gboolean bd_fs_ntfs_set_label (const gchar *device, const gchar *label, GError *
+     if (!check_deps (&avail_deps, DEPS_NTFSLABEL_MASK, deps, DEPS_LAST, &deps_check_lock, error))
+         return FALSE;
+ 
++    if (!bd_fs_ntfs_check_label (label, error))
++        return FALSE;
++
+     return bd_utils_exec_and_report_error (args, NULL, error);
+ }
+ 
+@@ -235,6 +238,19 @@ gboolean bd_fs_ntfs_set_label (const gchar *device, const gchar *label, GError *
+  * Tech category: always available
+  */
+ gboolean bd_fs_ntfs_check_label (const gchar *label, GError **error) {
++    if (!label) {
++        g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
++                             "Label cannot be NULL.");
++        return FALSE;
++    }
++
++    /* ntfslabel does not reliably support '--' to terminate option parsing. */
++    if (label[0] == '-') {
++        g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
++                             "Label for NTFS filesystem cannot start with '-'.");
++        return FALSE;
++    }
++
+     if (strlen (label) > 128) {
+         g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
+                      "Label for NTFS filesystem must be at most 128 characters long.");
package/libblockdev/0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch new file +78 -0

78 lines not on this page · raw message

package/libblockdev/libblockdev.mk +4 -0
index ecee8dee24..d1bd9a0f08 100644
@@ -13,6 +13,10 @@ LIBBLOCKDEV_DEPENDENCIES = host-pkgconf libglib2 kmod udev
 # 0001-Provide-replacement-function-for-strerror_l.patch
 LIBBLOCKDEV_AUTORECONF = YES
 
+# 0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch
+# 0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch
+LIBBLOCKDEV_IGNORE_CVES += CVE-2026-111581
+
 LIBBLOCKDEV_CONF_OPTS = \
 	--disable-introspection \
 	--with-loop \
Signature · 6 lines
2.56.1

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

In reply of:

Quoted 14 lines

This fixes the following vulnerability:

- CVE-2026-111581:
A flaw was found in libblockdev. The bd_fs_ntfs_set_label() and bd_fs_vfat_set_label() functions pass caller-supplied label values as bare positional arguments to the ntfslabel and fatlabel utilities without end-of-options separators or input validation for values beginning with a dash. This allows a label starting with '-' to be interpreted as a command-line flag by the spawned tool, potentially bypassing safety checks or causing unintended operations. This is reachable by unprivileged local users through the udisks2 Filesystem.SetLabel() D-Bus method without administrator authentication.

Quoted 6 lines

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-111581
- https://github.com/storaged-project/libblockdev/commit/4ef6b2b4798a46566fe8815eaabd163205be20bd
- https://github.com/storaged-project/libblockdev/commit/bf990ef6d720b4a0d3cb22c572f473fc5dc7f83c

Applied to 2025.02.x. Thanks

Quoted 152 lines
---
 ...ect-NTFS-labels-starting-with-a-dash.patch | 49 ++++++++++++
 ...ls-from-being-interpreted-as-options.patch | 78 +++++++++++++++++++
 package/libblockdev/libblockdev.mk            |  4 +
 3 files changed, 131 insertions(+)
 create mode 100644 package/libblockdev/0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch
 create mode 100644 package/libblockdev/0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch
package/libblockdev/0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch new file +49 -0
new file mode 100644
index 0000000000..9a4613f421
@@ -0,0 +1,49 @@
+From 4ef6b2b4798a46566fe8815eaabd163205be20bd Mon Sep 17 00:00:00 2001
+From: Vojtech Trefny <[email protected]>
+Date: Tue, 3 Nov 2026 15:39:58 +0100
+Subject: [PATCH] fs: Reject NTFS labels starting with a dash
+
+Fixes CVE-2026-111581.
+
+CVE: CVE-2026-111581
+Upstream: https://github.com/storaged-project/libblockdev/commit/4ef6b2b4798a46566fe8815eaabd163205be20bd
+[thomas: drop tests and backport context]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/plugins/fs/ntfs.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/src/plugins/fs/ntfs.c b/src/plugins/fs/ntfs.c
+index 424f606..78b56d0 100644
+--- a/src/plugins/fs/ntfs.c
++++ b/src/plugins/fs/ntfs.c
+@@ -221,6 +221,9 @@ gboolean bd_fs_ntfs_set_label (const gchar *device, const gchar *label, GError *
+     if (!check_deps (&avail_deps, DEPS_NTFSLABEL_MASK, deps, DEPS_LAST, &deps_check_lock, error))
+         return FALSE;
+ 
++    if (!bd_fs_ntfs_check_label (label, error))
++        return FALSE;
++
+     return bd_utils_exec_and_report_error (args, NULL, error);
+ }
+ 
+@@ -235,6 +238,19 @@ gboolean bd_fs_ntfs_set_label (const gchar *device, const gchar *label, GError *
+  * Tech category: always available
+  */
+ gboolean bd_fs_ntfs_check_label (const gchar *label, GError **error) {
++    if (!label) {
++        g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
++                             "Label cannot be NULL.");
++        return FALSE;
++    }
++
++    /* ntfslabel does not reliably support '--' to terminate option parsing. */
++    if (label[0] == '-') {
++        g_set_error_literal (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
++                             "Label for NTFS filesystem cannot start with '-'.");
++        return FALSE;
++    }
++
+     if (strlen (label) > 128) {
+         g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_LABEL_INVALID,
+                      "Label for NTFS filesystem must be at most 128 characters long.");
package/libblockdev/0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch new file +78 -0
new file mode 100644
index 0000000000..9594d16ad3
@@ -0,0 +1,78 @@
+From bf990ef6d720b4a0d3cb22c572f473fc5dc7f83c Mon Sep 17 00:00:00 2001
+From: Vojtech Trefny <[email protected]>
+Date: Tue, 3 Nov 2026 16:07:59 +0100
+Subject: [PATCH] fs: Prevent VFAT labels from being interpreted as options
+
+Fixes CVE-2026-111581.
+
+This also requires dosfstools >= 4.2 for setting label from now
+because the "--" option doesn't work with older versions. 4.2 was
+released in 2021 and is now available in all major distributions
+including Debian 11 (oldoldstable) and CentOS/RHEL 9 so it's not
+a problem.
+
+CVE: CVE-2026-111581
+Upstream: https://github.com/storaged-project/libblockdev/commit/bf990ef6d720b4a0d3cb22c572f473fc5dc7f83c
+[thomas: drop tests]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/plugins/fs/vfat.c | 31 +++++++++---------------
+ 1 file changed, 11 insertions(+), 20 deletions(-)
+
+diff --git a/src/plugins/fs/vfat.c b/src/plugins/fs/vfat.c
+index 744bc9f..7866964 100644
+--- a/src/plugins/fs/vfat.c
++++ b/src/plugins/fs/vfat.c
+@@ -46,7 +46,7 @@ static GMutex deps_check_lock;
+ 
+ static const UtilDep deps[DEPS_LAST] = {
+     {"mkfs.vfat", NULL, NULL, NULL},
+-    {"fatlabel", NULL, NULL, NULL},
++    {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"},
+     {"fsck.vfat", NULL, NULL, NULL},
+     {"vfat-resize", NULL, NULL, NULL},
+     {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"},
+@@ -281,33 +281,24 @@ gboolean bd_fs_vfat_repair (const gchar *device, const BDExtraArg **extra, GErro
+  * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_SET_LABEL
+  */
+ gboolean bd_fs_vfat_set_label (const gchar *device, const gchar *label, GError **error) {
+-    const gchar *args[4] = {"fatlabel", device, NULL, NULL};
+-    UtilDep dep = {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"};
+-    gchar *label_up = NULL;
+-    gboolean new_vfat = FALSE;
+-    gboolean ret;
++    const gchar *args[5] = {"fatlabel", "--", device, label, NULL};
++    g_autofree gchar *label_up = NULL;
+ 
+     if (!check_deps (&avail_deps, DEPS_FATLABEL_MASK, deps, DEPS_LAST, &deps_check_lock, error))
+         return FALSE;
+ 
+     if (!label || g_strcmp0 (label, "") == 0) {
+-        /* fatlabel >= 4.2 refuses to set empty label */
+-        new_vfat = bd_utils_check_util_version (dep.name, dep.version,
+-                                                dep.ver_arg, dep.ver_regexp,
+-                                                NULL);
+-        if (new_vfat)
+-            args[2] = "--reset";
+-    }
+-
+-    /* forcefully convert the label uppercase in case no reset was requested */
+-    if (label && args[2] == NULL) {
++        /* fatlabel >= 4.2 refuses to set an empty label, use --reset instead */
++        args[1] = "--reset";
++        args[2] = "--";
++        args[3] = device;
++    } else {
++        /* forcefully convert a non-empty label uppercase */
+         label_up = g_ascii_strup (label, -1);
+-        args[2] = label_up;
++        args[3] = label_up;
+     }
+-    ret = bd_utils_exec_and_report_error (args, NULL, error);
+-    g_free (label_up);
+ 
+-    return ret;
++    return bd_utils_exec_and_report_error (args, NULL, error);
+ }
+ 
+ /**
package/libblockdev/libblockdev.mk +0 -0
index ecee8dee24..d1bd9a0f08 100644

package/libblockdev/libblockdev.mk LIBBLOCKDEV_DEPENDENCIES = host-pkgconf libglib2 kmod udev · line 22

Quoted 10 lines
package/libblockdev/libblockdev.mk +4 -0
@@ -13,6 +13,10 @@ LIBBLOCKDEV_DEPENDENCIES = host-pkgconf libglib2 kmod udev
 # 0001-Provide-replacement-function-for-strerror_l.patch
 LIBBLOCKDEV_AUTORECONF = YES
 
+# 0002-fs-Reject-NTFS-labels-starting-with-a-dash.patch
+# 0003-fs-Prevent-VFAT-labels-from-being-interpreted-as-options.patch
+LIBBLOCKDEV_IGNORE_CVES += CVE-2026-111581
+
 LIBBLOCKDEV_CONF_OPTS = \
 	--disable-introspection \
 	--with-loop \

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