Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2399232yba; Thu, 25 Apr 2019 16:03:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzciPkdYRkjJGd/fbpBPpR8jTY5sPE2Fq93DudPUVIZyzXBxPo4sGb2ys4S7aNpMLk/E7MO X-Received: by 2002:a63:6849:: with SMTP id d70mr38807413pgc.21.1556233436966; Thu, 25 Apr 2019 16:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556233436; cv=none; d=google.com; s=arc-20160816; b=ZMeqNPa13wiI2HJzL7WO1bC8TdphjwEOgcLoUo5bLUOkv2Sd37DCBbWlLaIQma06C/ goYQiEs3b3icMAVeGPOj15To+QADztKQlCyX19P6Sp2WpXq+5Ax2qZ0z9v1x3NBqkWSQ TU/coRAUSut4CmM19bOWCXObliQjJWM6EJ41WFw3GBcl7UpFraWF2C0Pkel7zF30MC1U OjOGctO0zFJhAt10+HC2A37OBfgkJ6sQ61mJPEAm3dh7y0pionYT1zeh1M/XO6t2kO4v nIHMakLvkfFmAViLxM8HyttqqKnNVeODT4rP4wyvqGkd+K2as57HxJ/eo5dUHRDk+akd pTVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=eOsJDCQYnDhxIgZUo3pOOqasW3JRJUKG00CA3rD/iBs=; b=TErVHM+cSJFLeLEb3cX9XPaybU4/Z+odXKy7kGKaJPxL5d7/hsQ87gZPOI2mZ80OXY 0sUBNZ3G1B29j+QvNIcp0MBwXiDzmikAjaZTzQ2j1so38F1qUVz730z6y/tQiwd1nr3x HROrwKSpkOfRDGBfy1ct0B2jBQVyBmlDqOtny76kX70++iPwsXhx0TpelIGdfRE/Gthd 8tLjk/CwRWpMJhkmk8jQ+FyeFXQi7mSTjG3DQ/9VndpWCbMXkB/XLVA+JfIQ3X+SoJbN Gyx7iO8sw8hGO8AZW0YPZfxqLrrJJzEvs/7SrlmINHc4bcNgJdft8Lgdc3xWVBERFk7M 5XAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si13459201pgy.134.2019.04.25.16.03.39; Thu, 25 Apr 2019 16:03:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388237AbfDYVqb (ORCPT + 99 others); Thu, 25 Apr 2019 17:46:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48226 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388205AbfDYVq2 (ORCPT ); Thu, 25 Apr 2019 17:46:28 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3PLY6SE137750 for ; Thu, 25 Apr 2019 17:46:28 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s3metsejw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Apr 2019 17:46:27 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Apr 2019 22:46:26 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Apr 2019 22:46:20 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3PLkJQT61538416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Apr 2019 21:46:19 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA28142041; Thu, 25 Apr 2019 21:46:19 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50F4B42049; Thu, 25 Apr 2019 21:46:17 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.204.209]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 25 Apr 2019 21:46:17 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Fri, 26 Apr 2019 00:46:16 +0300 From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexandre Chartre , Andy Lutomirski , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , James Bottomley , Jonathan Adams , Kees Cook , Paul Turner , Peter Zijlstra , Thomas Gleixner , linux-mm@kvack.org, linux-security-module@vger.kernel.org, x86@kernel.org, Mike Rapoport Subject: [RFC PATCH 5/7] x86/mm/fault: hook up SCI verification Date: Fri, 26 Apr 2019 00:45:52 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556228754-12996-1-git-send-email-rppt@linux.ibm.com> References: <1556228754-12996-1-git-send-email-rppt@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042521-0016-0000-0000-000002750F36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042521-0017-0000-0000-000032D18954 Message-Id: <1556228754-12996-6-git-send-email-rppt@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-25_18:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=453 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904250133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a system call runs in isolated context, it's accesses to kernel code and data will be verified by SCI susbsytem. Signed-off-by: Mike Rapoport --- arch/x86/mm/fault.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9d5c75f..baa2a2f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -18,6 +18,7 @@ #include /* faulthandler_disabled() */ #include /* efi_recover_from_page_fault()*/ #include +#include /* sci_verify_and_map() */ #include /* boot_cpu_has, ... */ #include /* dotraplinkage, ... */ @@ -1254,6 +1255,30 @@ static int fault_in_kernel_space(unsigned long address) return address >= TASK_SIZE_MAX; } +#ifdef CONFIG_SYSCALL_ISOLATION +static int sci_fault(struct pt_regs *regs, unsigned long hw_error_code, + unsigned long address) +{ + struct task_struct *tsk = current; + + if (!tsk->in_isolated_syscall) + return 0; + + if (!sci_verify_and_map(regs, address, hw_error_code)) { + this_cpu_write(cpu_sci.sci_syscall, 0); + no_context(regs, hw_error_code, address, SIGKILL, 0); + } + + return 1; +} +#else +static inline int sci_fault(struct pt_regs *regs, unsigned long hw_error_code, + unsigned long address) +{ + return 0; +} +#endif + /* * Called for all faults where 'address' is part of the kernel address * space. Might get called for faults that originate from *code* that @@ -1301,6 +1326,9 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code, if (kprobes_fault(regs)) return; + if (sci_fault(regs, hw_error_code, address)) + return; + /* * Note, despite being a "bad area", there are quite a few * acceptable reasons to get here, such as erratum fixups -- 2.7.4