Re: efivar-39 build failed against glibc-2.43 and gcc-15.2.0

"Xi Ruoyao" ([email protected] via blfs-dev Mailing List) <[email protected]> Sat, 14 Feb 2026 02:01:01 +0800
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On Fri, 2026-02-13 at 11:04 -0600, Douglas R. Reno wrote:

/* snip */

> I advise against adding -Wno-discarded-qualifiers because while it may
> allow the package to build, it's still hiding a type system violation
> which could lead to undefined behavior or possibly a critical security
> issue (known as Type Confusion). We'll try to fix these as we come
> across them. It doesn't look like upstream is aware of this yet, so
> we'll also let them know about it as well!

The fix is trivial (comparing to some difficult cases where one pointer
may point to an immutable string literal or a mutable buffer depending
on the control flow).

find_parent_devpath() really modifies the string pointed by the argument
so the argument shouldn't be a const-qualified pointer at all.

For other cases just simply add the missing "const" qualifiers.

diff --color -Naur efivar-39.orig/src/linux-acpi-root.c efivar-39.patched/src/linux-acpi-root.c
--- efivar-39.orig/src/linux-acpi-root.c	2024-02-01 04:08:46.000000000 +0800
+++ efivar-39.patched/src/linux-acpi-root.c	2026-02-14 01:57:01.620378791 +0800
@@ -35,7 +35,7 @@
 	uint16_t pad0;
 	uint8_t pad1;
 	char *acpi_header = NULL;
-	char *colon;
+	const char *colon;
 
 	debug("entry");
 
diff --color -Naur efivar-39.orig/src/linux-ata.c efivar-39.patched/src/linux-ata.c
--- efivar-39.orig/src/linux-ata.c	2024-02-01 04:08:46.000000000 +0800
+++ efivar-39.patched/src/linux-ata.c	2026-02-14 01:57:01.588201975 +0800
@@ -95,7 +95,7 @@
 		return 0;
 	}
 
-	char *host = strstr(path, "/host");
+	const char *host = strstr(path, "/host");
 	if (!host)
 		return -1;
 
@@ -113,7 +113,7 @@
 	dev->ata_info.scsi_target = scsi_target;
 	dev->ata_info.scsi_lun = scsi_lun;
 
-	char *block = strstr(current, "/block/");
+	const char *block = strstr(current, "/block/");
 	if (block)
 		current += block + 1 - current;
 	debug("current:'%s' sz:%zd", current, current - path);
diff --color -Naur efivar-39.orig/src/linux.c efivar-39.patched/src/linux.c
--- efivar-39.orig/src/linux.c	2024-02-01 04:08:46.000000000 +0800
+++ efivar-39.patched/src/linux.c	2026-02-14 01:57:01.613402412 +0800
@@ -31,7 +31,7 @@
 #include "efiboot.h"
 
 int HIDDEN
-find_parent_devpath(const char * const child, char **parent)
+find_parent_devpath(char * const child, char **parent)
 {
 	int ret;
 	char *node;
diff --color -Naur efivar-39.orig/src/linux.h efivar-39.patched/src/linux.h
--- efivar-39.orig/src/linux.h	2024-02-01 04:08:46.000000000 +0800
+++ efivar-39.patched/src/linux.h	2026-02-14 01:57:01.621322707 +0800
@@ -161,7 +161,7 @@
 
 int HIDDEN get_sector_size(int filedes);
 
-extern int HIDDEN find_parent_devpath(const char * const child,
+extern int HIDDEN find_parent_devpath(char * const child,
 				      char **parent);
 
 extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size,
diff --color -Naur efivar-39.orig/src/linux-i2o.c efivar-39.patched/src/linux-i2o.c
--- efivar-39.orig/src/linux-i2o.c	2024-02-01 04:08:46.000000000 +0800
+++ efivar-39.patched/src/linux-i2o.c	2026-02-14 01:57:01.622224299 +0800
@@ -32,7 +32,7 @@
 	        return 0;
 	}
 
-	char *block = strstr(current, "/block/");
+	const char *block = strstr(current, "/block/");
 	ssize_t sz = block ? block + 1 - current : -1;
 	debug("current:'%s' sz:%zd", current, sz);
 	return sz;

-- 
Xi Ruoyao <[email protected]>

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page