diff mbox series

[scarthgap] glibc: Fix missing randomness in __gen_tempname

Message ID 20241021100352.56570-1-olani@axis.com
State Rejected
Delegated to: Steve Sakoman
Headers show
Series [scarthgap] glibc: Fix missing randomness in __gen_tempname | expand

Commit Message

Ola x Nilsson Oct. 21, 2024, 10:03 a.m. UTC
From: Ola x Nilsson <olani@axis.com>

Backport the fix for glibc bug 32214.

The missing randomness in early boot may cause some systemd services
to fail when they occasionally try to create tempdirs like
/run/systemd/namespace-aaaaaa at the same time.
The error messages can contain things like
"Failed to set up mount namespacing".

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 ...ndomness-in-__gen_tempname-bug-32214.patch | 29 +++++++++++++++++++
 meta/recipes-core/glibc/glibc_2.39.bb         |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch

Comments

Ola x Nilsson Oct. 21, 2024, 2:37 p.m. UTC | #1
Please ignore this patch.  I was supposed to send it for styhead but got
mixed up.

/Ola


On Mon, Oct 21 2024, Ola x Nilsson wrote:

> From: Ola x Nilsson <olani@axis.com>
>
> Backport the fix for glibc bug 32214.
>
> The missing randomness in early boot may cause some systemd services
> to fail when they occasionally try to create tempdirs like
> /run/systemd/namespace-aaaaaa at the same time.
> The error messages can contain things like
> "Failed to set up mount namespacing".
>
> Signed-off-by: Ola x Nilsson <olani@axis.com>
> ---
>  ...ndomness-in-__gen_tempname-bug-32214.patch | 29 +++++++++++++++++++
>  meta/recipes-core/glibc/glibc_2.39.bb         |  1 +
>  2 files changed, 30 insertions(+)
>  create mode 100644 meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch
>
> diff --git a/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch b/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch
> new file mode 100644
> index 0000000000..c9f3e32f58
> --- /dev/null
> +++ b/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch
> @@ -0,0 +1,29 @@
> +From 9d30d58c32fe9d5f8ec6cda79fb11159e6789bcf Mon Sep 17 00:00:00 2001
> +From: Andreas Schwab <schwab@suse.de>
> +Date: Wed, 25 Sep 2024 11:49:30 +0200
> +Subject: [PATCH] Fix missing randomness in __gen_tempname (bug 32214)
> +
> +Make sure to update the random value also if getrandom fails.
> +
> +Fixes: 686d542025 ("posix: Sync tempname with gnulib")
> +
> +Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=5f62cf88c4530c11904482775b7582bd7f6d80d2]
> +
> +Signed-off-by: Ola x Nilsson <olani@axis.com>
> +---
> + sysdeps/posix/tempname.c | 2 ++
> + 1 file changed, 2 insertions(+)
> +
> +diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
> +index c00fe0c181..fc30958a0c 100644
> +--- a/sysdeps/posix/tempname.c
> ++++ b/sysdeps/posix/tempname.c
> +@@ -117,6 +117,8 @@ random_bits (random_value *r, random_value s)
> +      succeed.  */
> + #if !_LIBC
> +   *r = mix_random_values (v, clock ());
> ++#else
> ++  *r = v;
> + #endif
> +   return false;
> + }
> diff --git a/meta/recipes-core/glibc/glibc_2.39.bb b/meta/recipes-core/glibc/glibc_2.39.bb
> index 2484ae1cd9..2db18251e3 100644
> --- a/meta/recipes-core/glibc/glibc_2.39.bb
> +++ b/meta/recipes-core/glibc/glibc_2.39.bb
> @@ -53,6 +53,7 @@ SRC_URI =  "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
>             file://0021-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \
>             file://0022-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \
>             file://0023-qemu-stale-process.patch \
> +           file://0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch \
>  "
>  S = "${WORKDIR}/git"
>  B = "${WORKDIR}/build-${TARGET_SYS}"
diff mbox series

Patch

diff --git a/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch b/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch
new file mode 100644
index 0000000000..c9f3e32f58
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch
@@ -0,0 +1,29 @@ 
+From 9d30d58c32fe9d5f8ec6cda79fb11159e6789bcf Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab@suse.de>
+Date: Wed, 25 Sep 2024 11:49:30 +0200
+Subject: [PATCH] Fix missing randomness in __gen_tempname (bug 32214)
+
+Make sure to update the random value also if getrandom fails.
+
+Fixes: 686d542025 ("posix: Sync tempname with gnulib")
+
+Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=5f62cf88c4530c11904482775b7582bd7f6d80d2]
+
+Signed-off-by: Ola x Nilsson <olani@axis.com>
+---
+ sysdeps/posix/tempname.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
+index c00fe0c181..fc30958a0c 100644
+--- a/sysdeps/posix/tempname.c
++++ b/sysdeps/posix/tempname.c
+@@ -117,6 +117,8 @@ random_bits (random_value *r, random_value s)
+      succeed.  */
+ #if !_LIBC
+   *r = mix_random_values (v, clock ());
++#else
++  *r = v;
+ #endif
+   return false;
+ }
diff --git a/meta/recipes-core/glibc/glibc_2.39.bb b/meta/recipes-core/glibc/glibc_2.39.bb
index 2484ae1cd9..2db18251e3 100644
--- a/meta/recipes-core/glibc/glibc_2.39.bb
+++ b/meta/recipes-core/glibc/glibc_2.39.bb
@@ -53,6 +53,7 @@  SRC_URI =  "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://0021-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \
            file://0022-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \
            file://0023-qemu-stale-process.patch \
+           file://0024-Fix-missing-randomness-in-__gen_tempname-bug-32214.patch \
 "
 S = "${WORKDIR}/git"
 B = "${WORKDIR}/build-${TARGET_SYS}"