mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ARM: allocate the signal page at boot
Date: Mon, 16 Nov 2026 13:04:58 -0500	[thread overview]
Message-ID: <20261116180458.3432038-1-sashal@kernel.org> (raw)

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


                 reply	other threads:[~2026-11-16 18:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116180458.3432038-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®