[PATCH] gnu: glibc: Handle failure to find $ORIGIN.

  • Done
  • quality assurance status badge
Details
3 participants
  • Ivan Kozlov
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Ivan Kozlov
Severity
normal
I
I
Ivan Kozlov wrote on 21 Dec 2021 02:25
(address . guix-patches@gnu.org)
12919001640049950@myt6-27f58919b1c4.qloud-c.yandex.net

* gnu/packages/patches/glibc-dl-cache.patch: Check pointer returned by '_dl_get_origin' for failure indication.
---
gnu/packages/patches/glibc-dl-cache.patch | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Toggle diff (38 lines)
diff --git a/gnu/packages/patches/glibc-dl-cache.patch b/gnu/packages/patches/glibc-dl-cache.patch
index 68c3a94846..1535e8e9c9 100644
--- a/gnu/packages/patches/glibc-dl-cache.patch
+++ b/gnu/packages/patches/glibc-dl-cache.patch
@@ -3,10 +3,10 @@ from /etc/ld.so.cache. Also arrange so that this cache takes
precedence over RUNPATH.

diff --git a/elf/dl-cache.c b/elf/dl-cache.c
-index 93d185e788..e0760a1f40 100644
+index 93d185e788..801452692d 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
-@@ -171,6 +171,51 @@ _dl_cache_libcmp (const char *p1, const char *p2)
+@@ -171,6 +171,52 @@ _dl_cache_libcmp (const char *p1, const char *p2)
return *p1 - *p2;
}

@@ -27,7 +27,8 @@ index 93d185e788..e0760a1f40 100644
+ const char *origin = _dl_get_origin ();
+
+ /* Check whether ORIGIN is something like "/gnu/store/…-foo/bin". */
-+ if (strncmp (store, origin, strlen (store)) == 0
++ if (origin != (char *)-1 /* _dl_get_origin reported failure */
++ && strncmp (store, origin, strlen (store)) == 0
+ && origin[sizeof store - 1] == '/')
+ {
+ char *store_item_end = strchr (origin + sizeof store, '/');
@@ -58,7 +59,7 @@ index 93d185e788..e0760a1f40 100644

/* Look up NAME in ld.so.cache and return the file name stored there, or null
if none is found. The cache is loaded if it was not already. If loading
-@@ -190,12 +235,15 @@ _dl_load_cache_lookup (const char *name)
+@@ -190,12 +236,15 @@ _dl_load_cache_lookup (const char *name)

/* Print a message if the loading of libs is traced. */
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))

base-commit: 88b4dcdabe512992ae79a50fc333e4e463d91634
--
2.28.0
L
L
Ludovic Courtès wrote on 14 Jan 2022 09:20
(name . Ivan Kozlov)(address . kanichos@yandex.ru)
87a6fy684t.fsf@gnu.org
Hello,

Ivan Kozlov <kanichos@yandex.ru> skribis:

Toggle quote (4 lines)
>
> * gnu/packages/patches/glibc-dl-cache.patch: Check pointer returned by '_dl_get_origin' for failure indication.

Perfect, thank you Ivan.

Maxim, should we include it in ‘version-1.4.0’?

I’m fine either way (it’s a much welcome fix but it’s not critical IMO).

Ludo’.
M
M
Maxim Cournoyer wrote on 14 Jan 2022 23:40
(name . Ludovic Courtès)(address . ludo@gnu.org)
87wnj29c0j.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (9 lines)
> Hello,
>
> Ivan Kozlov <kanichos@yandex.ru> skribis:
>
>> Fixes <https://issues.guix.gnu.org/52671>.
>>
>> * gnu/packages/patches/glibc-dl-cache.patch: Check pointer returned
>> by '_dl_get_origin' for failure indication.

Is this a world rebuilding change? If so, I'm afraid it'll have to wait
until the next rebuild cycle comes as we're already far into building
the version-1.4.0 branch.

Thanks,

Maxim
L
L
Ludovic Courtès wrote on 17 Jan 2022 15:59
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
875yqio1b2.fsf@gnu.org
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (13 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hello,
>>
>> Ivan Kozlov <kanichos@yandex.ru> skribis:
>>
>>> Fixes <https://issues.guix.gnu.org/52671>.
>>>
>>> * gnu/packages/patches/glibc-dl-cache.patch: Check pointer returned
>>> by '_dl_get_origin' for failure indication.
>
> Is this a world rebuilding change?

Yes.

Toggle quote (3 lines)
> If so, I'm afraid it'll have to wait until the next rebuild cycle
> comes as we're already far into building the version-1.4.0 branch.

Sounds good, no worries.

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 30 Jan 2023 00:34
(name . Ivan Kozlov)(address . kanichos@yandex.ru)
878rhk3ofj.fsf@gnu.org
Hi Ivan,

Ivan Kozlov <kanichos@yandex.ru> skribis:

Toggle quote (4 lines)
>
> * gnu/packages/patches/glibc-dl-cache.patch: Check pointer returned by '_dl_get_origin' for failure indication.

Somehow we forgot about this patch for a whole year, and it turns out I
stumbled upon the bug again just hours ago¹.

Now pushed to ‘core-updates’ as
edb8c09addd186d9538d43b12af74d6c7aeea082.

Thanks again, and apologies for the delay!

Ludo’.

Closed
?