mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Aruna Ramakrishna" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/mm] x86/pkeys: Restore altstack access in sigreturn()
Date: Fri, 02 Aug 2024 13:01:11 -0000	[thread overview]
Message-ID: <172260367109.2215.3503021469640609513.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240802061318.2140081-5-aruna.ramakrishna@oracle.com>

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     d10b554919d4cc8fa8fe2e95b57ad2624728c8e4
Gitweb:        https://git.kernel.org/tip/d10b554919d4cc8fa8fe2e95b57ad2624728c8e4
Author:        Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
AuthorDate:    Fri, 02 Aug 2024 06:13:17 
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 02 Aug 2024 14:12:21 +02:00

x86/pkeys: Restore altstack access in sigreturn()

A process can disable access to the alternate signal stack by not
enabling the altstack's PKEY in the PKRU register.

Nevertheless, the kernel updates the PKRU temporarily for signal
handling. However, in sigreturn(), restore_sigcontext() will restore the
PKRU to the user-defined PKRU value.

This will cause restore_altstack() to fail with a SIGSEGV as it needs read
access to the altstack which is prohibited by the user-defined PKRU value.

Fix this by restoring altstack before restoring PKRU.

Signed-off-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240802061318.2140081-5-aruna.ramakrishna@oracle.com

---
 arch/x86/kernel/signal_64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index 8a94053..ee94538 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -260,13 +260,13 @@ SYSCALL_DEFINE0(rt_sigreturn)
 
 	set_current_blocked(&set);
 
-	if (!restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
+	if (restore_altstack(&frame->uc.uc_stack))
 		goto badframe;
 
-	if (restore_signal_shadow_stack())
+	if (!restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
 		goto badframe;
 
-	if (restore_altstack(&frame->uc.uc_stack))
+	if (restore_signal_shadow_stack())
 		goto badframe;
 
 	return regs->ax;

  reply	other threads:[~2024-08-02 13:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  6:13 [PATCH v8 0/5] x86/pkeys: update PKRU to enable all pkeys before XSAVE Aruna Ramakrishna
2024-08-02  6:13 ` [PATCH v8 1/5] x86/pkeys: Add PKRU as a parameter in signal handling functions Aruna Ramakrishna
2024-08-02 13:01   ` [tip: x86/mm] " tip-bot2 for Aruna Ramakrishna
2024-08-09 17:16   ` [PATCH v8 1/5] " Jeff Xu
2024-08-02  6:13 ` [PATCH v8 2/5] x86/pkeys: Add helper functions to update PKRU on the sigframe Aruna Ramakrishna
2024-08-02 13:01   ` [tip: x86/mm] " tip-bot2 for Aruna Ramakrishna
2024-08-02  6:13 ` [PATCH v8 3/5] x86/pkeys: Update PKRU to enable all pkeys before XSAVE Aruna Ramakrishna
2024-08-02 13:01   ` [tip: x86/mm] " tip-bot2 for Aruna Ramakrishna
2024-08-09 17:30   ` [PATCH v8 3/5] " Jeff Xu
2024-08-27  0:53     ` Jeff Xu
2024-10-03 23:29       ` Aruna Ramakrishna
2024-10-04  4:20         ` Jeff Xu
2025-02-04 10:01   ` Dmitry Vyukov
2025-02-06 18:06     ` Dmitry Vyukov
2025-02-10 22:46       ` Jeff Xu
2025-02-11  6:47         ` Dmitry Vyukov
2025-02-06 18:21     ` Dave Hansen
2025-02-06 18:35       ` Dmitry Vyukov
2024-08-02  6:13 ` [PATCH v8 4/5] x86/pkeys: Restore altstack access in sigreturn() Aruna Ramakrishna
2024-08-02 13:01   ` tip-bot2 for Aruna Ramakrishna [this message]
2024-08-02  6:13 ` [PATCH v8 5/5] selftests/mm: Add new testcases for pkeys Aruna Ramakrishna
2024-08-02  8:16   ` Thomas Gleixner
2024-08-02  8:22   ` Thomas Gleixner
2024-08-02 12:04   ` Thomas Gleixner
2024-08-02 13:01   ` [tip: x86/mm] " tip-bot2 for Keith Lucas

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=172260367109.2215.3503021469640609513.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=aruna.ramakrishna@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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®