From patchwork Mon Mar 6 13:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 13161113 Return-Path: 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 95A4CC61DA4 for ; Mon, 6 Mar 2023 13:55:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06720280002; Mon, 6 Mar 2023 08:55:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 016C5280001; Mon, 6 Mar 2023 08:55:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2086280002; Mon, 6 Mar 2023 08:55:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D4EC2280001 for ; Mon, 6 Mar 2023 08:55:32 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 815E41A0523 for ; Mon, 6 Mar 2023 13:55:32 +0000 (UTC) X-FDA: 80538620904.06.BDB45F8 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf26.hostedemail.com (Postfix) with ESMTP id 3916D140010 for ; Mon, 6 Mar 2023 13:55:30 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=m6V+7NL6; spf=pass (imf26.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678110930; 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:references:dkim-signature; bh=gRD8JJYANQoaDeDDLwQmfnykMhkvwfwnnj9U9gA27mA=; b=Hngt8t2zatqbAQvnknv8qY1FBNRkCBitp37Z0lwhTuNLVtnDRcLAeGABioSOZHPLRP+LA/ MiUk8LsJUxwCANbr1lKOiw7wjhWkj0AA3Kg5ZjOnjQnNeNeke0zmDtkwtbOF6zG6vdUKw9 jLxMo5N9+hHDPW7Oc3XF+FaqGtf/iNY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=m6V+7NL6; spf=pass (imf26.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678110930; a=rsa-sha256; cv=none; b=0dcWxE1sTVRmJYyAlhWX/nZR6HjLsxX1dKK0dwbc3euCk39AwFXVg0Rfeq9ZiW0NCULo2v 2ZOrAwkHKjZpX64O+8AH/+ridrO5IH40QtkFysdXJmF3Q9e/oUEX7e753dGZiJ8W6DSGUz Q2n+u292UO0bncE9A+LG9rXBoVIiYAQ= Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 326D59jg018320; Mon, 6 Mar 2023 13:55:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=gRD8JJYANQoaDeDDLwQmfnykMhkvwfwnnj9U9gA27mA=; b=m6V+7NL6ucr8BkYk9y+2W8uMUK50NAyeDGOY6X9ZF0aBaUmJDmWFE2MwDhQA6R4PFGCA ogtqy8M1Ib7Ou8a5wg945i8rVgiVzzhLysZb7QUs/ll93cAPb0u0fAONqwcKcsUmzx7R i/57EqO8Sr5/PgohMQ9UyEZY9EM7qYDPsby50LOH7sZEZKzr5KAh9P0q+E/4WQDXSas2 TbnJlyH9fXEWhjXTSt3ahyOaIhSVzt0XiPxzL6xfr1+nqlX8ALfmdTWgFQAnzb/rD8i2 rtrgcNS6d5f46AHO9IxBuRQ0GzfR5wAQE5+mJ2nsEBBAYzu5/X1yjLbQ8WG1vyY8DjXu Hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p4vp20636-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 13:55:28 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 326D9B4R024378; Mon, 6 Mar 2023 13:55:28 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p4vp2062g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 13:55:28 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3266D2uk008169; Mon, 6 Mar 2023 13:55:26 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3p419ka7dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 13:55:25 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 326DtLHF19792456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Mar 2023 13:55:21 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28ABE2006A; Mon, 6 Mar 2023 13:55:21 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4B7920067; Mon, 6 Mar 2023 13:55:20 +0000 (GMT) Received: from localhost.localdomain (unknown [9.101.4.33]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Mar 2023 13:55:20 +0000 (GMT) From: Laurent Dufour To: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Sachin Sant , Suren Baghdasaryan Subject: [PATCH] powerpc/mm: fix mmap_lock bad unlock Date: Mon, 6 Mar 2023 14:55:20 +0100 Message-Id: <20230306135520.4222-1-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.39.2 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -mfselKxpsUFz8XBPm9kLaG4aVfl3jwU X-Proofpoint-GUID: OchV6nD80rsjtI295AnTPoQEGnRuyelA X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_05,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060120 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3916D140010 X-Stat-Signature: crkupafyx5a7nj7c35mh64kaoa97aece X-Rspam-User: X-HE-Tag: 1678110930-302064 X-HE-Meta: U2FsdGVkX19RQjqVQVtgRK0wHwNb5TeXqlqKm9pTPm4v3+8Qf3B5EtWCioktH1ibQtjPd7ISpM65tfCmmkvurRb1srIC7v8ICi/asq50wslXONgmSh24NWWLmPAgv9NZ4qg6l7CXKila1BqB4WFI6UehpC80cZpml6jttgxiKjgsgGXW9kVAMjCg+pr34WoMruNJdOYUh1jOjpyeox87aCLA2HOPSyKYLMrLYA+1PV4kFOtXxz2HYWcCgVMmxhWs8jlZJ+sVImIlYOFNphBPpSu/MQ/1+ozaKBxcbdXOThvX5YRMe2oQNEUr6EciCOBea1IqE9V6787TTWGU6iF0158iW95k7YTN9rb8NQhHg2O9rV46mJTzS6GJHXlmTFXl98roasZyDT77T96gJClybgTDF9bo3LmfitYR3ugdmQqU7JgGb8WwILCDOPT8xe9cjMpbfIdmKv9JqrDu3nRS7TzozTnu8ejAcwgjaDIxhTvfjBHG1QUxB1Et7F2hix9WcGtvPMFfMyUrHFKjZlMl0wycHBuf8zrW8cMeNT12PiVhHc2wM36qXh/xjbECta5Bcy+UEdg/+IPBY2St0JYv0QI/30ycFCxGHeEA9qmP+EUTKU8hCMPykLYckXBN1+wnbprdKZTNLsOCEf8Zp+DspKYa4/Yv3sfz57Fo72Gf65uM16Gr18cH4iPLkk1P6/GLQNu+4sNffkI7gxUd1weSlezfnaRdFdKpQVlXwWs6xBSNF8o57XLxGPoyhpUjCn9cX9VJLtOae/dWA4uGf35zpcHy8fRsruu4OMNHqxrhXqUUKcUU19JlhCae/OeeGwdneAf8qMWfLKPzKxEE5jSDGzk5kahOenmr75u4i4vrVTbCdqFsNFBwVXBBqcH3d+MPDieTGZ8F7LCtn6hzhdsBoffsRxq7Cpc93ommYYDD2HYd8g7BzhsHUoRJ80T8L685lLJuNTXe0lpCzAhhucb l7freKmO /gWRctHEpkdKr2PTg8E2DjtBAYXIHPl+SpazGAXuHgwxa0MrC43Ong8yNautdJWRCLJTdIV33kjatg/+1iSpOAgOCqku0Mt98CABKRgD5+ncIcxeLzLycWPqPliLgSM7SzoycWJoJOl+NTE30/l8XvtSjX+inqx+d1cfil1Hu3Rjgd+wGjIsnh48opuh5HFkQSBXBvUQi2dmPZ+Zdb5ois8Q31xIBFlS/gzn+oZPzf5Q7NcFjpzURh4Z1z0P9rnZJ0PahnycOlz3cwPNx/kIrhaWWbe/Oe9L0NZ9z 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: When page fault is tried holding the per VMA lock, bad_access_pkey() and bad_access() should not be called because it is assuming the mmap_lock is held. In the case a bad access is detected, fall back to the default path, grabbing the mmap_lock to handle the fault and report the error. Fixes: 169db3bb4609 ("powerc/mm: try VMA lock-based page fault handling first") Reported-by: Sachin Sant Link: https://lore.kernel.org/linux-mm/842502FB-F99C-417C-9648-A37D0ECDC9CE@linux.ibm.com Cc: Suren Baghdasaryan Signed-off-by: Laurent Dufour --- arch/powerpc/mm/fault.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index c7ae86b04b8a..e191b3ebd8d6 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -479,17 +479,13 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address, if (unlikely(access_pkey_error(is_write, is_exec, (error_code & DSISR_KEYFAULT), vma))) { - int rc = bad_access_pkey(regs, address, vma); - vma_end_read(vma); - return rc; + goto lock_mmap; } if (unlikely(access_error(is_write, is_exec, vma))) { - int rc = bad_access(regs, address); - vma_end_read(vma); - return rc; + goto lock_mmap; } fault = handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs);