nptl: initialize cpu_id_start and rseq area prio to registration
- nptl: initialize cpu_id_start prior to rseq registration
- nptl: initialize rseq area prior to registration
This commit is contained in:
parent
6acf3f9227
commit
cdd894e5de
@ -67,7 +67,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
Name: glibc
|
Name: glibc
|
||||||
Version: 2.38
|
Version: 2.38
|
||||||
Release: 44
|
Release: 45
|
||||||
Summary: The GNU libc libraries
|
Summary: The GNU libc libraries
|
||||||
License: %{all_license}
|
License: %{all_license}
|
||||||
URL: http://www.gnu.org/software/glibc/
|
URL: http://www.gnu.org/software/glibc/
|
||||||
@ -248,6 +248,8 @@ Patch158: backport-elf-Move-__rtld_malloc_init_stubs-call-into-_dl_star.patch
|
|||||||
Patch159: backport-elf-Handle-static-PIE-with-non-zero-load-address-BZ-.patch
|
Patch159: backport-elf-Handle-static-PIE-with-non-zero-load-address-BZ-.patch
|
||||||
Patch160: backport-elf-Introduce-_dl_relocate_object_no_relro.patch
|
Patch160: backport-elf-Introduce-_dl_relocate_object_no_relro.patch
|
||||||
Patch161: backport-elf-Switch-to-main-malloc-after-final-ld.so-self-rel.patch
|
Patch161: backport-elf-Switch-to-main-malloc-after-final-ld.so-self-rel.patch
|
||||||
|
Patch162: nptl-initialize-rseq-area-prior-to-registration.patch
|
||||||
|
Patch163: nptl-initialize-cpu_id_start-prior-to-rseq-registrat.patch
|
||||||
|
|
||||||
#openEuler patch list
|
#openEuler patch list
|
||||||
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
|
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
|
||||||
@ -1469,6 +1471,10 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Dec 7 2024 Qingqing Li <liqingqing3@huawei.com> - 2.38-45
|
||||||
|
- nptl: initialize cpu_id_start prior to rseq registration
|
||||||
|
- nptl: initialize rseq area prior to registration
|
||||||
|
|
||||||
* Fri Dec 06 2024 shixuantong <shixuantong@huawei.com> - 2.38-44
|
* Fri Dec 06 2024 shixuantong <shixuantong@huawei.com> - 2.38-44
|
||||||
- elf: Handle static PIE with non-zero load address
|
- elf: Handle static PIE with non-zero load address
|
||||||
- elf: Introduce _dl_relocate_object_no_relro
|
- elf: Introduce _dl_relocate_object_no_relro
|
||||||
|
|||||||
34
nptl-initialize-cpu_id_start-prior-to-rseq-registrat.patch
Normal file
34
nptl-initialize-cpu_id_start-prior-to-rseq-registrat.patch
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
From 37ded328c4240f5a84c69b8cb803f0652fa68d20 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Jeanson <mjeanson@efficios.com>
|
||||||
|
Date: Wed, 20 Nov 2024 14:15:42 -0500
|
||||||
|
Subject: [PATCH] nptl: initialize cpu_id_start prior to rseq registration
|
||||||
|
|
||||||
|
When adding explicit initialization of rseq fields prior to
|
||||||
|
registration, I glossed over the fact that 'cpu_id_start' is also
|
||||||
|
documented as initialized by user-space.
|
||||||
|
|
||||||
|
While current kernels don't validate the content of this field on
|
||||||
|
registration, future ones could.
|
||||||
|
|
||||||
|
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
|
||||||
|
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
||||||
|
(cherry picked from commit d9f40387d3305d97e30a8cf8724218c42a63680a)
|
||||||
|
---
|
||||||
|
sysdeps/unix/sysv/linux/rseq-internal.h | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
index 8fd26f335e..0ad79174bd 100644
|
||||||
|
--- a/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
+++ b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
@@ -56,6 +56,7 @@ rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
||||||
|
registration, there is no guarantee that struct pthread is
|
||||||
|
cleared on all architectures. */
|
||||||
|
THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_UNINITIALIZED);
|
||||||
|
+ THREAD_SETMEM (self, rseq_area.cpu_id_start, 0);
|
||||||
|
THREAD_SETMEM (self, rseq_area.rseq_cs, 0);
|
||||||
|
THREAD_SETMEM (self, rseq_area.flags, 0);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
61
nptl-initialize-rseq-area-prior-to-registration.patch
Normal file
61
nptl-initialize-rseq-area-prior-to-registration.patch
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From 9423cc5387d93de63be09740bfd86abd01dca7d1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Jeanson <mjeanson@efficios.com>
|
||||||
|
Date: Thu, 7 Nov 2024 22:23:49 +0100
|
||||||
|
Subject: [PATCH] nptl: initialize rseq area prior to registration
|
||||||
|
|
||||||
|
Per the rseq syscall documentation, 3 fields are required to be
|
||||||
|
initialized by userspace prior to registration, they are 'cpu_id',
|
||||||
|
'rseq_cs' and 'flags'. Since we have no guarantee that 'struct pthread'
|
||||||
|
is cleared on all architectures, explicitly set those 3 fields prior to
|
||||||
|
registration.
|
||||||
|
|
||||||
|
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
|
||||||
|
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
(cherry picked from commit 97f60abd25628425971f07e9b0e7f8eec0741235)
|
||||||
|
---
|
||||||
|
nptl/descr.h | 2 ++
|
||||||
|
sysdeps/unix/sysv/linux/rseq-internal.h | 10 ++++++++++
|
||||||
|
2 files changed, 12 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/nptl/descr.h b/nptl/descr.h
|
||||||
|
index 0171576c23..4ec2df7a26 100644
|
||||||
|
--- a/nptl/descr.h
|
||||||
|
+++ b/nptl/descr.h
|
||||||
|
@@ -414,6 +414,8 @@ struct pthread
|
||||||
|
{
|
||||||
|
uint32_t cpu_id_start;
|
||||||
|
uint32_t cpu_id;
|
||||||
|
+ uint64_t rseq_cs;
|
||||||
|
+ uint32_t flags;
|
||||||
|
};
|
||||||
|
char pad[32]; /* Original rseq area size. */
|
||||||
|
} rseq_area __attribute__ ((aligned (32)));
|
||||||
|
diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
index 226ba59a24..8fd26f335e 100644
|
||||||
|
--- a/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
+++ b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||||
|
@@ -51,11 +51,21 @@ rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
||||||
|
/* The initial implementation used only 20 bytes out of 32,
|
||||||
|
but still expected size 32. */
|
||||||
|
size = RSEQ_AREA_SIZE_INITIAL;
|
||||||
|
+
|
||||||
|
+ /* Initialize the rseq fields that are read by the kernel on
|
||||||
|
+ registration, there is no guarantee that struct pthread is
|
||||||
|
+ cleared on all architectures. */
|
||||||
|
+ THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_UNINITIALIZED);
|
||||||
|
+ THREAD_SETMEM (self, rseq_area.rseq_cs, 0);
|
||||||
|
+ THREAD_SETMEM (self, rseq_area.flags, 0);
|
||||||
|
+
|
||||||
|
int ret = INTERNAL_SYSCALL_CALL (rseq, &self->rseq_area,
|
||||||
|
size, 0, RSEQ_SIG);
|
||||||
|
if (!INTERNAL_SYSCALL_ERROR_P (ret))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
+ /* When rseq is disabled by tunables or the registration fails, inform
|
||||||
|
+ userspace by setting 'cpu_id' to RSEQ_CPU_ID_REGISTRATION_FAILED. */
|
||||||
|
THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user