Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp294968pxb; Thu, 21 Jan 2021 07:19:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJydTMggnwc3TEbVIAww3MHdG5/UY6s4PWsoC7zltaSsCr7QXJGLImfxZNFsO+nJu61jXn4H X-Received: by 2002:a05:6402:1c8b:: with SMTP id cy11mr11965856edb.256.1611242364523; Thu, 21 Jan 2021 07:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611242364; cv=none; d=google.com; s=arc-20160816; b=JCfqNKmY03FvDHp+qoFSivMM6D9XIQjCYbHjBTDaWgbv90vXDLqy1Ydj65UIaJSb7+ 3yqPpqMSnxhKgawAhYRshhjiqk4LwPmBVwusaHE2jW3e1ITC1mlmqIYZuEGrRJRjNtB7 49pJ53w6DSlDlCovK4dfY7n+LzdcydN7sCMY/xqNVY06QggMDQXKr39/p5DLcUy+byaR tdeGNsh/jFBIRyQUfv0axjyVbwAYRTcxX4kdriJvcY8JI5h9gfEdEbu9CyD5G281YEap ouUkGxHNSbaqCY/561mcFImIB6b2R4xuvBw8luAa4b/WafqJtgpJlwCYBaWMM58GJjGw Kv3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f/iVi2BnD5qrsshoRRjT0AaZeRvDrPk45GZQX1577jQ=; b=qJUGukh/xGFo9rjbipH8SFYWI63NY4bsHB1j5TFzHMVkFnVa8P20VWmbLuSiLx9pmD fORtn2BUCfCYmnNROJ+M4QFk9T3EayFid3fNUhi5ILXF3sCkY0WtDg8DcGbyfI48IdpZ 6VNxznVb/07evQy05SnJb3Pvy4H2mQZCiVU92KYTP4agRu/Cw5SO+NhEjboEb0Kf5dob +n27AdatZWUe1n5o3BXNDky0kYhQZtFVgKRuEmLxNMXymnCVbOXncM0RbSIjrthZ/xvo dcF9vvf1EN7gNRA8y+M2xHgs6kPkao0vZnOI+6gIwdGY9t36qsDnB3z9UXTHRNqRAbhd lx8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DwWixBXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si1873027ejw.662.2021.01.21.07.19.00; Thu, 21 Jan 2021 07:19:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DwWixBXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732720AbhAUPRt (ORCPT + 99 others); Thu, 21 Jan 2021 10:17:49 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34910 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732297AbhAUPPs (ORCPT ); Thu, 21 Jan 2021 10:15:48 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10LF3NdL038914; Thu, 21 Jan 2021 10:15:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f/iVi2BnD5qrsshoRRjT0AaZeRvDrPk45GZQX1577jQ=; b=DwWixBXsPqUV5I3ptePSD9NK64IXHChx2hhQ1eH+QXdL4qPiiZv6UCZTDNoKtiWh7rdL fcbN8ypG05iq7pXlzPhW/FmLnmp8tPmrIoJs4R0dCxYSI1yU6Lpwv9yYX1ssaLa3Oy4u rp+cubA42isxv7sUGtlgJJhJUHDzNxvn06MonVbOLYnFVE8hKv/cOocon0c5ahKb/PNb 4Uh5qVWs1s9XwIL9CwZJUwxEbz0FQdArM+am4lnIxv1SBy0WIupGQOPuYLo5X2cBwmDb 4fPB8a1en9wVMYB2a7ikk5d7v23F9LAIE5nJCJPPOPxS4xyyZBQ/P2nId21tSMppyJLp 3A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 367bc2hveq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jan 2021 10:15:07 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 10LF3k2M040701; Thu, 21 Jan 2021 10:15:06 -0500 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 367bc2hvd4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jan 2021 10:15:06 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10LFDKYA018797; Thu, 21 Jan 2021 15:15:04 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3668nwss47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jan 2021 15:15:04 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10LFF1sS44499390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Jan 2021 15:15:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E44A11C05C; Thu, 21 Jan 2021 15:15:01 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13F4211C066; Thu, 21 Jan 2021 15:15:00 +0000 (GMT) Received: from linux01.pok.stglabs.ibm.com (unknown [9.114.17.81]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 21 Jan 2021 15:14:59 +0000 (GMT) From: Janosch Frank To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, thuth@redhat.com, david@redhat.com, borntraeger@de.ibm.com, imbrenda@linux.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, gor@linux.ibm.com, hca@linux.ibm.com, mihajlov@linux.ibm.com Subject: [PATCH v2 2/2] s390: mm: Fix secure storage access exception handling Date: Thu, 21 Jan 2021 10:14:35 -0500 Message-Id: <20210121151436.417240-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210121151436.417240-1-frankja@linux.ibm.com> References: <20210121151436.417240-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-21_08:2021-01-21,2021-01-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101210081 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Turns out that the bit 61 in the TEID is not always 1 and if that's the case the address space ID and the address are unpredictable. Without an address and its address space ID we can't export memory and hence we can only send a SIGSEGV to the process or panic the kernel depending on who caused the exception. Signed-off-by: Janosch Frank Fixes: 084ea4d611a3d ("s390/mm: add (non)secure page access exceptions handlers") Cc: stable@vger.kernel.org --- arch/s390/mm/fault.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index e30c7c781172..3e8685ad938d 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -791,6 +791,20 @@ void do_secure_storage_access(struct pt_regs *regs) struct page *page; int rc; + /* There are cases where we don't have a TEID. */ + if (!(regs->int_parm_long & 0x4)) { + /* + * When this happens, userspace did something that it + * was not supposed to do, e.g. branching into secure + * memory. Trigger a segmentation fault. + */ + if (user_mode(regs)) { + send_sig(SIGSEGV, current, 0); + return; + } else + panic("Unexpected PGM 0x3d with TEID bit 61=0"); + } + switch (get_fault_type(regs)) { case USER_FAULT: mm = current->mm; -- 2.25.1