Message ID | 20240801065116.2088582-5-aruna.ramakrishna@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A36C49EA1 for <linux-mm@archiver.kernel.org>; Thu, 1 Aug 2024 06:51:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D0A56B00BF; Thu, 1 Aug 2024 02:51:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60A8D6B00BD; Thu, 1 Aug 2024 02:51:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 421136B00BF; Thu, 1 Aug 2024 02:51:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E520F6B00B7 for <linux-mm@kvack.org>; Thu, 1 Aug 2024 02:51:42 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A52BF12058F for <linux-mm@kvack.org>; Thu, 1 Aug 2024 06:51:42 +0000 (UTC) X-FDA: 82402756044.16.FA2B480 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf12.hostedemail.com (Postfix) with ESMTP id B161640019 for <linux-mm@kvack.org>; Thu, 1 Aug 2024 06:51:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QmuxIMEs; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of aruna.ramakrishna@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=aruna.ramakrishna@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722495054; a=rsa-sha256; cv=none; b=Q3TI9SsynMaRpAo4fjequoA8wgNPR6Y1HWl8ivDm85hi4Ng1zKBofyZ3VTfj4Uk8S0eA96 U55sasxpmMKq2CSLXWKnpO0CCFTDyIZ2ETRAcM5T465asI70GZ95ojRfnnRi0s5tkahyEY jFCfyrCLBOT4uw/X6LrKN3w+xL2uhZ0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QmuxIMEs; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of aruna.ramakrishna@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=aruna.ramakrishna@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722495054; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TiPmGpJvBPhD8zSOmWsEhmg/C+5nGFb/MfYfG1gbkVA=; b=xQ2qJGh7jpj8ZhnyU23UEZu3+OrMoQMU9f2qMs/crdEbPPpCZ47CC5+1yp2jVVVKP7j5zs 9QshWsgSudrlrCnEcPXqgn+TofPVeIZzzVtXeqnqlrMAW7oBgcr2Dzg/z3AyGwKYEYSHwB EgEK1NUyzvn9WXscFyVUs0B5da6j1MQ= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46VLGvI7005722; Thu, 1 Aug 2024 06:51:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=T iPmGpJvBPhD8zSOmWsEhmg/C+5nGFb/MfYfG1gbkVA=; b=QmuxIMEsmOylZZHcp 3tB7pf/SfuPM5WipqYh3HAoXRqtrnnXPp//shK3e/NIeFTAiweK9nlSdeT5Guj2T R003eLscY/xiMw9Oe+l4jvZHxzkjVIbd4P2cpxbhKF1Yyk53r6iSLRYEgZiHQNCD vRW0eu3c757IPbM5JyJ+wcHEo1LkBT4ozT+Q6/TZmYCzUa8TzgNnVhiAxjSQw6LV pnWnexgkhnvucZNENRymoDrH4hpMz5666W26UY00gVUBC+EvBbER4n+iuOg3ksLG o7jJ0H7Ambgda4XobKsSmCzeGJ3xWRCwxd8Y6XqWoDgfLYsdFwOiM7mWXKi92jct //lgg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqp214nb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 06:51:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4716KoVS030932; Thu, 1 Aug 2024 06:51:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40nehveh80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 06:51:19 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4716pHNK033596; Thu, 1 Aug 2024 06:51:19 GMT Received: from aruramak-dev.osdevelopmeniad.oraclevcn.com (aruramak-dev.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.253.155]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 40nehveh6x-5; Thu, 01 Aug 2024 06:51:19 +0000 From: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, dave.hansen@linux.intel.com, tglx@linutronix.de, mingo@kernel.org, linux-mm@kvack.org, keith.lucas@oracle.com, jeffxu@chromium.org, rick.p.edgecombe@intel.com, jorgelo@chromium.org, keescook@chromium.org, sroettger@google.com, jannh@google.com, aruna.ramakrishna@oracle.com Subject: [PATCH v7 4/5] x86/pkeys: Restore altstack before sigcontext Date: Thu, 1 Aug 2024 06:51:15 +0000 Message-Id: <20240801065116.2088582-5-aruna.ramakrishna@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240801065116.2088582-1-aruna.ramakrishna@oracle.com> References: <20240801065116.2088582-1-aruna.ramakrishna@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-01_04,2024-07-31_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=853 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010038 X-Proofpoint-ORIG-GUID: z5XWOE0O2Xt7mvn-1DCV-HJyBg0uYceS X-Proofpoint-GUID: z5XWOE0O2Xt7mvn-1DCV-HJyBg0uYceS X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B161640019 X-Stat-Signature: mmek1ap9foqzq1snsuu13q65q4wg9uqt X-Rspam-User: X-HE-Tag: 1722495100-599869 X-HE-Meta: U2FsdGVkX1/GRmi8Va/n2smTLkYz/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NHNdBgtRDYPlsj2Z9glYcFFaSRGnqN2NCfOBn3Q7wAiOxSK+GocKWifaeqUN9+CLvkC/RlcObBWxvPIA/A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
x86/pkeys: update PKRU to enable pkey 0 before
|
expand
|
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c index 8a94053c5444..ee9453891901 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;
A process can disable access to the alternate signal stack and still expect signals to be delivered correctly. get_sigframe() updates the PKRU value to enable access to the altstack, and makes sure that the value on the sigframe is the user-defined PKRU value so that it is correctly restored. However, in sigreturn(), restore_altstack() needs read access to the altstack. But the PKRU has already been restored from the sigframe (in restore_sigcontext()) which will disable access to the altstack, resulting in a SIGSEGV. Fix this by restoring altstack before restoring PKRU. Signed-off-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> --- arch/x86/kernel/signal_64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)