mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ARM: allocate the signal page at boot
@ 2026-11-16 18:04 Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2026-11-16 18:04 UTC (permalink / raw)
  To: Russell King; +Cc: linux-arm-kernel, linux-kernel

arch_setup_additional_pages() allocates the signal page on the first
exec, without any locking:

	if (!signal_page)
		signal_page = get_signal_page();

get_signal_page() also picks the random offset of the sigreturn code
within the page and stores it in signal_return_offset.

If two tasks exec at the same time before the page exists, both allocate
one. When the task that picked its offset first is the last one to set
signal_page, signal_page points to that task's page while
signal_return_offset holds the offset used in the other one. Every
signal handler that returns through the signal page then lands in the
wrong place, nearly always on the poison that fills the rest of the
page, and the task gets a SIGILL.

Only handlers installed without SA_RESTORER return through the signal
page. glibc always sets SA_RESTORER, klibc doesn't. With an initramfs
that runs /init with klibc's sh, init dies on its first SIGCHLD:

	Run /init as init process
	Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004

On i.MX6Q SABRE Lite the first execs come in parallel on every boot:
the two SD hosts probe at the same time, each requests ledtrig:mmcN, and
the two modprobe helpers exec together. KernelCI hits the panic in about
1 of 400 boots of that board with a klibc initramfs.

Allocate the page from an arch_initcall instead, which is what the other
architectures do for their signal trampoline and vdso pages, arm64's
sigpage for 32-bit tasks included.

Fixes: 48be69a026b2 ("ARM: move signal handlers into a vdso-like page")
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

 arch/arm/kernel/process.c | 10 ++++++++--
 arch/arm/kernel/signal.c  |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index d7aa95225c70b..615a8fbd61bc7 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -379,6 +379,14 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,
 static struct page *signal_page;
 extern struct page *get_signal_page(void);
 
+static int __init signal_page_init(void)
+{
+	signal_page = get_signal_page();
+
+	return signal_page ? 0 : -ENOMEM;
+}
+arch_initcall(signal_page_init);
+
 static int sigpage_mremap(const struct vm_special_mapping *sm,
 		struct vm_area_struct *new_vma)
 {
@@ -401,8 +409,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 	unsigned long hint;
 	int ret = 0;
 
-	if (!signal_page)
-		signal_page = get_signal_page();
 	if (!signal_page)
 		return -ENOMEM;
 
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 763e1930a1ea3..2b8ccebd33b65 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -648,7 +648,7 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
 	return 0;
 }
 
-struct page *get_signal_page(void)
+struct page * __init get_signal_page(void)
 {
 	unsigned long ptr;
 	unsigned offset;

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-16 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 18:04 [PATCH] ARM: allocate the signal page at boot Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®