From patchwork Tue Apr 20 16:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12214761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7040C433B4 for ; Tue, 20 Apr 2021 16:55:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 909CA613AB for ; Tue, 20 Apr 2021 16:55:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 909CA613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=wlOiTRF1JzqQcwEs3iZteASsDtkY/yQY+tuGdZ1zw5w=; b=d/WDQLTuk9Rsd4B1h3d5a/l+Cp s91vz8Bwc70Oz3XHly8cme2bFwvfoDhI3LGoHjdq8hIqCEVbeCAvwfwBNFupv6mtAvn9nfzvPBBX0 SElrv3vMXXXOSQiHpWHwoNFkuWgK7/kIsgDmavbbQlvZE/BXOBhlA8AiQoZwO313sqqyvRy4AgVM/ 0z//eyWEdHKTQQYs81iD17uoNnE7DDfhpgRNUx9ccy1lIRPaCTUqvdP3RTcMuZ4FuWj4hyCK+9v6f u6+b9UpN64kmoPzkTSNDdpArP6dwFkD7czaShz9e737x5nOUSGeqhOnchWoEjrylDpRUcjzc9L/Y1 lkD+qlwg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYtcd-00CceZ-7I; Tue, 20 Apr 2021 16:53:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYtaH-00Cbkp-V4 for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 16:50:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version: Content-Transfer-Encoding:Content-Type:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=dzcqGSkZyw/D6a1e/bPszDOHvl2ObGE0tmn5ByRCFR0=; b=neQQNiLCFW3Id6xYVtgohj+7Vg f1Ukut3TnGUuQ1goN95W7c3tDZAFu3Q+9NtM6u1/LgLIVM6xfTXy/ch0cFsKbEprbFuTUMoJSgRls 8kndDf1MUmazI1lnXdxUmqP0WoqfhvuLY5Gw4NRQRRgE6hQt3YpCh1e9xAoygFluW1Ihxf9TxIgTi 96yX/eNYPwKy6GuRieBf4IgmKBxBogJIivPKJd+7xyO+EOkTed7AW6+Sxo2S5pm5kNLJB8IlqZFyy YAibpm/FaShJWgaAHXxAxVosg31nvnFWnK3LWlkQ5XjmUvfKw7iaIRgRMXQCatCi4DN6Wn9pHGLAf cCs3JiuQ==; Received: from userp2120.oracle.com ([156.151.31.85]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYta9-00CHrf-7Q for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 16:50:44 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGaobr173668; Tue, 20 Apr 2021 16:50:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=dzcqGSkZyw/D6a1e/bPszDOHvl2ObGE0tmn5ByRCFR0=; b=znHSlSPDmDRO0AjA+5IPFrMG4kvaA6/i9dubPJzRxkeZ8lGpOg+wme2IvoqMXyKZeadw 6pDD/G3uys2pvl3B0yL3pf728qlbHRrMb1g5NtVKrCx874OVXUb6KQJzrptPwLSHAYR+ f16o6ObbgETD8wQvOU4YBunUk5HJK3z99xBu7eo6O4A5hi2H/Lz7tLtWucWEnO9XkH4+ 8N6w8bmU+qSzcjQugYlEOZTDbN9YmEb4EeYbPd50C3qZNU4yakCucPeTDbAI+qun5Xgu HX9Fg3jTwqUtGgFtODtBUUgtbbm3v7kqS2QAJDihHsr2qSNb/1lrfjtkaHafZ1hv/tc5 Lg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 38022xy8qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:16 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGZtsO102703; Tue, 20 Apr 2021 16:50:15 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by userp3020.oracle.com with ESMTP id 3809esxw95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FbC7rsIXwEZxiWhgjdTlfNrOrYarqKvL8Oy6UkCKeO5T45ETZge0Cy+13cobVrUWR2cCm9TKUg7GCqzz8AH0Jxby2L56FrO9/a75J//elDRcobd8bIPpqFjXQeMbGKwIU8gLISaxfwfFwFAFsWTNTcrO6pkKzVYwClZIUwtd7Uwoz7zWw7vcQhVVJV7ELsIkbI/TXMPO/B/gWoSh3blUqsUnmD3KgEp3hbSGayT97arNnLwvo9Mt9t8vOPF0qKjXCSkEnL7un6Bi0DAzjlRfOZSZ4P3d9siQOuFcmapqu9ta+BW/GIpycoy3yjJcFZsP1BcBSUKq0HgWx0VWpmwmrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dzcqGSkZyw/D6a1e/bPszDOHvl2ObGE0tmn5ByRCFR0=; b=DHhzsGNQkRgZSAYFMZ3RVB/QbtzAmnneANCTvjzcdcSOZYhC+dvdCLvd1Y3Fc1Lh7EAnhBMCU5ttkqrpi+F6zDlP7gP1vdq76UuwmRotHwyJEMHPtb8iJsCbwarZoAblChKxFilsnwstiiYawuOEib74AcmS/UkLkCifOsBovwxkosmNZoh9D3w1jEOjl5gVGY17ctFK5Zt42W9dVFkc576T2EbzEz522eufJHN8HvlakzlPMa4qRTg6Pr3CavmGPWbI/f+5XCkg6QX/UrYmHzvlGZRQif5wH2TKM8OohST7+jtyDcjAKl6a3qxLUQmd0r9tNHoJiINVdi4NmCCLwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dzcqGSkZyw/D6a1e/bPszDOHvl2ObGE0tmn5ByRCFR0=; b=qBc1+owSFuEopiS0zuUXItO1bCCp5AvSHlk9P6eDF5z3rXjpA+iFR29YSfkIRdCfnlmVhxC18ts0Cxal0yhoa51rjJ6tVKkoWscbK69yas3DNQf1BKOJK9QwwmtXXZdyvJ5VWYpq5NXFlVziUOQqTZdUpW4OyXP+D7Oai9RSAmI= Received: from MWHPR10MB1582.namprd10.prod.outlook.com (2603:10b6:300:22::8) by CO1PR10MB4772.namprd10.prod.outlook.com (2603:10b6:303:94::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Tue, 20 Apr 2021 16:50:13 +0000 Received: from MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811]) by MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811%8]) with mapi id 15.20.4042.024; Tue, 20 Apr 2021 16:50:13 +0000 From: Liam Howlett To: Catalin Marinas , Will Deacon , Julien Grall CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Liam Howlett , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" Subject: [PATCH 1/3] arm64: armv8_deprecated: Fix swp_handler() signal generation Thread-Topic: [PATCH 1/3] arm64: armv8_deprecated: Fix swp_handler() signal generation Thread-Index: AQHXNgU7pAWIynV4NUyh79ZCugEeMA== Date: Tue, 20 Apr 2021 16:50:12 +0000 Message-ID: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oracle.com; x-originating-ip: [23.233.25.87] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 667a504d-3ed2-4e5f-7c57-08d9041c5ddf x-ms-traffictypediagnostic: CO1PR10MB4772: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qfAoNk2aQchsMUGi/RhIfy9VOoAt853OrOrKK6PCeMskcU1/tW7kgEhpO5HcJyIz25Yh8cUYp0MuqfCTtpLrSrSTbdnD9A+PncQ441A33UNcNuv2x9CTKauBqmPumf2mhTamN9SbN589HgVJLjL3bETu/u+tYQr88i4XSKFG0ghmkpuUmR0gnxIhOfzN6fMkAY7dMIPrpYEviIPIJ9nZ+KkMvBXv80IQGhqjjaZCEENNaOGQKka/h4DfU/maePu+3xbSMk7un9TQ5waPZOwsoNwylPevbvQcqy/rzTBLaU+0Yl14htZ8y3G8i09y04p0GISQlaubpeb+0e9e1dWWvg5tsoYKiyTKVy5KHjvzNGLGSGEj5U8+09B/sSvhTjEiuIjPwJzSLx8oRXRsrsSt6u9SYR0xuO0Cdjnwx3xIu67tfaQOi/J7Meoo2q8p6+adGVOJQHsDRVCEqZc+0leorOUKIKUJMfh+jFQfcZHn94/TlfDJJ3w8Vkhzr+I8li4GCACmfsAgjBNUUR4uPtPUS1ltHK2oG94ErKFKQqYNaIyf/T5sXtpCcqSl2uxPzpQvK2oGqA35po3SwzKVIcOwG0Du6zca17kKIbDfUj/Tuvs= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR10MB1582.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(366004)(136003)(39860400002)(396003)(376002)(6506007)(83380400001)(6486002)(64756008)(110136005)(5660300002)(8936002)(8676002)(54906003)(7416002)(316002)(66556008)(91956017)(1076003)(186003)(66476007)(2906002)(4326008)(71200400001)(36756003)(26005)(122000001)(2616005)(6512007)(66946007)(478600001)(38100700002)(44832011)(86362001)(76116006)(66446008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?NPBlHEnUgG85WhkzAy6ZEt++k?= =?iso-8859-1?q?138tubHOZrVSm3nVetXXrmkY6wm/rcVhlyAzko/W25WALMzRW+BCT1WfRtTp?= =?iso-8859-1?q?or6QaQuuD3rm37rskuVBlEbiOhWH8jVfbeVnJg3zlkxMVmLb6KvwZ9G7VHW0?= =?iso-8859-1?q?zKNBwnqnAroKHp4gLs7Hj6EIhsFurGs9mwdrsx3nfca72m8kf+/RXl5EFCeN?= =?iso-8859-1?q?AQUxgYJX5Mw0iW2meVXOqmT9kzadJXL2ZMMKxZZa1Q6jTZ3unRNpfF5ZXheO?= =?iso-8859-1?q?Rq7eRBFk5wjHDkGuZbgC38I5ME595JsPvEOz0FSL12FrOwe1bJb5YAeRk1WH?= =?iso-8859-1?q?xpZccTb78pX0OEDQVJoyLnFy5+KlvYNBYuNtZfmKDuclvS9E5tnWjs12IgrF?= =?iso-8859-1?q?vHrb5vLKhQpOK5TL72N2bwPuhJ+3796155ICnyaIkjWFxhyb+gA3kOFLW/vm?= =?iso-8859-1?q?f4Pp9yUwtl+OkjTXSwhIBX8oB1V/rr5xduMkrXkgyD5Vp8iB0dWK4yx7FgIt?= =?iso-8859-1?q?tgrlXl1juMZIyzSxUaK7xvYQOj3x1a9xt0zPYdeYKBY8LN3XTbp7+3Oo01TV?= =?iso-8859-1?q?vR8o+4oRfAQRQ5wQoa03rNPV3kutX7yd3YXG8gcBigopDmQiYracdSghV++e?= =?iso-8859-1?q?orRYY+WWjAE7pzhOpnHaMoVDac2/A7v4K27MkAgnTxFeFEK7yXiHWuzh0mZd?= =?iso-8859-1?q?+0kSKBxx2Uf1AzMui62c4MnI/V5r76plwLZR14dTzF+bedwlnSn3fN4Ccm3A?= =?iso-8859-1?q?mMQxDoHpjVnHk6CF/kbgUj1PCs9opB/MTmzNtFsFXaAKvxT6v0MRUReOEXvY?= =?iso-8859-1?q?b5oj7BvRrwNfx9IgFp/duQhSu6rzPcrhqpZp4LBGrF2Wn5V4F+5RYSKlZDab?= =?iso-8859-1?q?C9rbrCHgoJCPrXNkmvbNXgsN/mYilVgOuFU7EzgXcdawdc5yIqn0KRglvVEh?= =?iso-8859-1?q?c4XXFpFU8QFO7HniXAbDRJEmUm8HI2DDOYETXG38ItpQom2ef+xDYOeqIFpl?= =?iso-8859-1?q?Ua/apxHt53XP/dTWIpV0SWM1e16eVoCPO5r3/kEevaCEFqPYmOYBvMQmAsRx?= =?iso-8859-1?q?ydyFrEofgGoMXqWvFQkPFP2SpAmUOzyzqxI6mMX0oKpo1fSm05qACqeQpucS?= =?iso-8859-1?q?8u7gy5JAi60Gc8O61vg3DdX93A9A4vx5rdO2PGCVa8J8XeI3JWYd688K6Pij?= =?iso-8859-1?q?ErVMBg1Jq+8RnRpW4GVI+JvsagrcIkTCgK9SOo+9k3nBcWwRM/n7oAfPoI8K?= =?iso-8859-1?q?7oQjGKAXdF+0jzHJDuHBW5Mp8LOMUoVSlDvz6mT81VuOxo7pvfnsDR+EPmSE?= =?iso-8859-1?q?BMQL5mC6eUOpB1tXGQ51kNpkejXZE+qbBtGdul40zwdkwFl8g+vXISlRS+2?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR10MB1582.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 667a504d-3ed2-4e5f-7c57-08d9041c5ddf X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2021 16:50:12.8429 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: D9qXCdvovrjf9VinGe/UJqT/H3WoMinDhk6rZjZm+12kCme2UXbkva0deohqSy2thifru51k5ObMHXwc2j+Eig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4772 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-Proofpoint-ORIG-GUID: tuDDPyW461aWiHkKAXJlI4tzj2P2zeAj X-Proofpoint-GUID: tuDDPyW461aWiHkKAXJlI4tzj2P2zeAj X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1011 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_095037_425710_D4099A53 X-CRM114-Status: GOOD ( 23.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org arm64_notify_segfault() was written to decide on the si_code from the assembly emulation of the swp_handler(), but was also used for the signal generation from failed access_ok() and unaligned instructions. When access_ok() fails, there is no need to search for the offending address in the VMA space. Instead, simply set the error to SIGSEGV with si_code SEGV_ACCERR. Change the return code from emulate_swpX() when there is an unaligned pointer so the caller can differentiate from the EFAULT. It is unnecessary to search the VMAs in the case of an unaligned pointer. This change uses SIGSEGV and SEGV_ACCERR instead of SIGBUS to keep with what was returned before. Fixes: bd35a4adc413 (arm64: Port SWP/SWPB emulation support from arm) Signed-off-by: Liam R. Howlett --- arch/arm64/kernel/armv8_deprecated.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 0e86e8b9cedd..f424082b3455 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -324,7 +324,7 @@ static int emulate_swpX(unsigned int address, unsigned int *data, if ((type != TYPE_SWPB) && (address & 0x3)) { /* SWP to unaligned address not permitted */ pr_debug("SWP instruction on unaligned pointer!\n"); - return -EFAULT; + return -ENXIO; } while (1) { @@ -406,15 +406,17 @@ static int swp_handler(struct pt_regs *regs, u32 instr) user_ptr = (const void __user *)(unsigned long)(address & ~3); if (!access_ok(user_ptr, 4)) { pr_debug("SWP{B} emulation: access to 0x%08x not allowed!\n", - address); - goto fault; + address); + goto e_access; } res = emulate_swpX(address, &data, type); - if (res == -EFAULT) - goto fault; - else if (res == 0) + if (!res) regs->user_regs.regs[destreg] = data; + else if (res == -EFAULT) + goto e_fault; + else if (res = -ENXIO) /* Unaligned pointer */ + goto e_align; ret: if (type == TYPE_SWPB) @@ -428,10 +430,14 @@ static int swp_handler(struct pt_regs *regs, u32 instr) arm64_skip_faulting_instruction(regs, 4); return 0; -fault: +e_fault: pr_debug("SWP{B} emulation: access caused memory abort!\n"); arm64_notify_segfault(address); + return 0; +e_align: +e_access: + force_signal_inject(SIGSEGV, SEGV_ACCERR, address, 0); return 0; } From patchwork Tue Apr 20 16:50:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12214757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DFB0C433B4 for ; Tue, 20 Apr 2021 16:55:06 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C60616100B for ; Tue, 20 Apr 2021 16:55:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C60616100B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0l2/k46E4retgDrwTfYa44E1pUMtoSYyH/zysJe/8oc=; b=CrLkOSNhQa+G7hEejCJ75eMop QJfBqjJ122QRmXlLsk2iiV5tnnJXfSWW5VrwrSPkoK1HF72nT666TQVw6PIxykJKOYhwCucoXm75i KaHkog0f0FrhBt7v+BVGK76f3HJboDObT7mbYUrt1OBIKYnrK15OUhCfHBFamSYBguIvzaXpGVFhm M2rLSKonDswEfeN1/nFJ8rhLFVD711YhKh8b07Ut7VPOVda3tEyXKOuu+b1KC0EB9McvFjiZEGTQZ IeVPvLNuhvwRBeq4AtfVugeJ3S8B3SgUqU2nn2SLqDrZs9tHW/5fL6VumhQIUPpnRUra7HZ4kfVXn 2SgeDP4RA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYtc7-00CcOh-F4; Tue, 20 Apr 2021 16:52:39 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYtaE-00CbkD-IW for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 16:50:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version: Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=vizutN4qjOVBZgUbVWBMCtJcAIxkye7j89XvrdngMNI=; b=5EYnpbdjnkkw7Kp9VQDrP4Qa0H oWOYVDdh9v1xJAjZA3MHsiSIK7huH3ji+wzaXpA31GqkbaEkWtCLWiHaqeyjeeu3dkyeOZaA/3YSv JKHdEualboCrw5qQ3fnDdWmPMzclqJFwDceU3TmgBBQX5f4yj6P6rSu+g/W+b08FYHK/BpXXztSuj aGIEGPZtY/z0AaBjdDw/EZ3WnlxhZXLEhJXAO6CQAIUs782aEgmugI9Ep74dXCAutULKF1057SW4/ nH/eqtn/q+3Z+RASW4JLtPoH1VT58qfgKlZQdcz9Qak0WpEj5qKh34bvWNuLe1hS76kyfCO4URjvM wTR0obiA==; Received: from aserp2120.oracle.com ([141.146.126.78]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYta9-00CHre-45 for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 16:50:41 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGYwGa110556; Tue, 20 Apr 2021 16:50:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=vizutN4qjOVBZgUbVWBMCtJcAIxkye7j89XvrdngMNI=; b=AGDUR5zimmUPVaeHznGvNZ7KYCOP08SsQgxckeXpEdRFedPD0/hqj3js2i3nj605vu1R 0AQZNV1bi03WvFbyOMSjsNkgmcuwcOTz/eoZJGF5KmP8bZpgP6vdp9yaRO4BRCUN7+5H kIGwYxR/tyty+X7PRhyC8TnTPkiH6Pbnwsta6Y+nF7vSFj1mvNO5+jgkWosdnT1O2jiz tmOXB2qyoigl7pOosAuwt3mE11ivOz26h3wlL7SW3nEMbHosVFxBKdZc0sOnx8myRU9W nWuV/8kzG4GpC6hgSmZEk8bZ+wbe9dW1AOe80tIjYjwU9Txhz36Uc0Az7P2lizAT6ik9 Xg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37yqmnfuw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:16 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGa7gL084073; Tue, 20 Apr 2021 16:50:16 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2043.outbound.protection.outlook.com [104.47.73.43]) by aserp3020.oracle.com with ESMTP id 3809k0n3gx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bfpqMCYUmxgKDfDk8ZiEYmC7h1S/5YkL7MGlTr86vW1fwBchqcQi7SecJYiHTP0+GTtvoBpbgC0UoL/E/lhpZVaoGKTCIxOO3vyWaR2BHJeXs5kzWnJPZvbg+n8QlTO62M6Z5+xEO0JwT5Gud/VGVCu7xV554goex7BLZfNfQl739V4nH/Xd616fWhcVt9xtpMMg92g/lzzvA2j2kC7DFasJ8qOz2eWePwHPckjfMYqOqP4Jy4bHtKQGgmF9UJWFGBunQY50xo/orpAmZsnnZ8V/Sf0i9QHrwJvNS6nM62ZWalRPCNBiHcka55ND1Sg13tMIL+NkSGnRNTXj/nUjHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vizutN4qjOVBZgUbVWBMCtJcAIxkye7j89XvrdngMNI=; b=d+zO0Pp/AlMQwaXFBrvKZuftS6sYuoVt6pgMf/2+amMkY7D3WWvg6dMJt0JOx9/UMoh2YzuMGPYQ2iNogtejKDACJsXO3Ei8YnNSvMVFWtpWE8nveTsz5F6WWLtcQLuDQpYDhTzaZyepsXU1oOb08cVPARLTbFLAND1R13pqPra+dv3nTUUWmcVT7tKLcjdG0qgO22Jh6vqc1rM/IkcmZL8/QW1meDHqWmDNaqpHndHi9hun0yyjbDQos98pSTR3jZvKtKaFdfe7O9qq8OMQWZlQy3fW4uQ3tZ2YDasH7xhWZIQFqxVspDSHNbp5mG6ce+Ufy9xlS5WsP9Wg2CrmyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vizutN4qjOVBZgUbVWBMCtJcAIxkye7j89XvrdngMNI=; b=OAWi4CfS9FEYc9yYcJWQesdmQ2ku0v2ra4gpI/fyQ8OWb+HpBRg7CUtDkXGOU5T/FX5dfr6Glxh1sMAer1c86+WVyzLewyRAQFVcGElq4XjEdPsWy8ovLtRspg5EX0Zud3iE5TnOZb0UwSmD0lVcs5LGTQy30quDh0CXaUOB/H0= Received: from MWHPR10MB1582.namprd10.prod.outlook.com (2603:10b6:300:22::8) by MWHPR10MB1536.namprd10.prod.outlook.com (2603:10b6:300:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Tue, 20 Apr 2021 16:50:13 +0000 Received: from MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811]) by MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811%8]) with mapi id 15.20.4042.024; Tue, 20 Apr 2021 16:50:13 +0000 From: Liam Howlett To: Catalin Marinas , Will Deacon , Julien Grall CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Liam Howlett , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" Subject: [PATCH 2/3] arm64: signal: sigreturn() and rt_sigreturn() sometime returns the wrong signals Thread-Topic: [PATCH 2/3] arm64: signal: sigreturn() and rt_sigreturn() sometime returns the wrong signals Thread-Index: AQHXNgU7cqnWwo9uSUqkb8fv6D7LrA== Date: Tue, 20 Apr 2021 16:50:13 +0000 Message-ID: <20210420165001.3790670-2-Liam.Howlett@Oracle.com> References: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> In-Reply-To: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oracle.com; x-originating-ip: [23.233.25.87] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e0744ab1-4791-486f-fa11-08d9041c5e57 x-ms-traffictypediagnostic: MWHPR10MB1536: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +KaajMNyKAuGoiBXyqgLhZfqqvxfUx0WZrWCN9zsXnaqQjYKXs1nlvsDjfLzRogQG9DeX7jEXv/FRzbWBG/xzJ2q+mpI//BM0Y0d+zudrmHBqIvqdWR6XN2cpRE8c7H/+wRXVbFcGqEx8YiNasYoRNRblpJPd3XRHzdUZMKCrYRPlO2kNMUGw6VSf/bPLi5Wwerwyp3IikhXdhzMns9bMpaYBB3pkCQ/H0XhtFbfjRGgGzDctG1QHQcP0XpYUYB2CAMUbu3NRpiJeD3ZGKmBWqZ4GR5rhW33+XgWgqPi7gIod5fxgSNYHjmmVqYhqxCWSmUCi4mzgL8lGDKpyBKOpIne+tYM+7C0DZBidQnKj+MrMoFv9MKt9SFF06dIDl+pMljrh8ZOWnEVuyzQfM9LN9hB3eunbwOHmQ/l8IBrf4kNR+18fmeO/mug3k+ND+VahD9auMipOVAsPE4/SD32rlHyM2cQmDFPYS6yuC8eertWkqUVIrvelFobKRLqiZfsJ6Y9//qxmAxY7zKDmpMki6/sEIuefJ+ZqxPsu9J2psPRbuNprKibXLWeJLl5c4w0gf9YkGVI5ganmjd+p6dIleM5w86mG6bhbZAKCTnMEi0= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR10MB1582.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(366004)(396003)(136003)(376002)(83380400001)(64756008)(2906002)(5660300002)(44832011)(6506007)(186003)(71200400001)(66476007)(66946007)(316002)(7416002)(66556008)(91956017)(54906003)(8936002)(1076003)(26005)(76116006)(8676002)(110136005)(36756003)(2616005)(122000001)(86362001)(6512007)(66446008)(478600001)(6486002)(4326008)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?JWO11iNKoXGZT2kEEOnHJiHju?= =?iso-8859-1?q?aa5ep220k8G7xTwO+GHkYeBnmnCGoR3D/0NGOnKfKqmr5PFBw/M6+yqkwx4O?= =?iso-8859-1?q?x72l6Pt42+4Jct5p2paqxr0QHht/ax3r5QDL0g3j6cdG0Hf0InlGlkLxdfD+?= =?iso-8859-1?q?HruvGEqrQKwKp4ogRRjLzBNGKkdxVzj01dKmSRpdgrevfXVxerE9ryhhKBiU?= =?iso-8859-1?q?whOt2bMY9uiIh0mnU2dxXoWOI2AzOulCr5iieLz54cN7EFwckq5W/QcyIGXH?= =?iso-8859-1?q?3h1bKZRS9E9R8aR2KDDGVdjxp0uqI9T4S7qJXE8KlaYeZXQDEnrr8e3SJEn2?= =?iso-8859-1?q?etUMs4CHIVvUiFGMktN8aI+lKRIHR2KYjmi+Hi7QXlUZfrfRz5zkZidgIPVf?= =?iso-8859-1?q?JapP5pGbAirFNgPpgfXagEFjEoPGXWFGj2Y78JZgQemCSCepRNzvfFFimTmt?= =?iso-8859-1?q?aRsPMqXtoa5j20HShiGEx6z3dA3LIDN6myHgypb2DtBdGEB8DoUQlhmqQ4R1?= =?iso-8859-1?q?7CnU5A2eK3j2cNpNRSqaEwD9b+m5sOiLCvr6Y0P+x/BrQhU0Di5ALvXTTJTe?= =?iso-8859-1?q?kWzSuFhOMzVH7ETFfL0LoXZBCkldIw5IFN3z46xfvL2ypeMNWzUYKbb0b/gh?= =?iso-8859-1?q?8W7i3rbXdrSprRWErahtsM2lfon6Cz8q/N3oAPOeCgDiS/1bEHu+4Sgcv/aG?= =?iso-8859-1?q?KfercXvLyQfyfMv18KlAtbJ6o3tIsJXY8VQtI5P1XHTqrs9HlZFY1OEy5Jpj?= =?iso-8859-1?q?6kXdTioL20rFw3g4F5aQMcsG+TrBUgoasMRmH2O5ctPZuBpDIqfWa1wXI3ZV?= =?iso-8859-1?q?e3ZndvqSaXDZC1hmNqFEpSB11PvCjMfzJ+126Ztx6svjByNavxQhxlG0KoKi?= =?iso-8859-1?q?BQPhTHbTUqZ5xlya/ds/glUmn1vUBGA+79N+Zd2oY/xFB5bPWomSaI3DxQCL?= =?iso-8859-1?q?z8WniFOvk1iy3XWbjsbrCSRPGkfgzjpOV7wqvn+LteSZhwJwSsXTtaddUUla?= =?iso-8859-1?q?gPNmhMwOihU7qm3f/lBVTUdLFmfl5EFJO+Ms7EYGawnC4y7V1VVjbgAU2K6D?= =?iso-8859-1?q?mcWxJLi48vN4adDu8wGiwb/EsMW0XiAN53txuVPuX7mBbUExFopHXZaGV246?= =?iso-8859-1?q?havGKsAxW9QHR++EW8Md6FMC7E/77aMj7RsIr4rIclCkn4jhaxmumf77/cV+?= =?iso-8859-1?q?vQY6MtnGf/2RPQ6pR9XsTv0LMwbb2n9wy5wmpH0y1cqWwPLcp0pE5Ec9hwPP?= =?iso-8859-1?q?/POn9L29782+KZgS3Pq8mklSDPH6i4IlMfNBlmHaDt3ixqFwoalwyNa13wgz?= =?iso-8859-1?q?fFF1ZgI7E298qAN6GaN7cOOI07eAmoiE/8xXQQWnjQNDDmCPa8YqMkOSCcI?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR10MB1582.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0744ab1-4791-486f-fa11-08d9041c5e57 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2021 16:50:13.3897 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: laZ5VI74wb9uhFf2ZShI/3EYvuwIlpwp46iwZGb8YmG5AzcAF2u4s0t7e3wtW8C6iSnVcTlTYqv1JIlcPlnJvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1536 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-Proofpoint-ORIG-GUID: YcnjrERkwVhP-xy0laVrSODAkpWcIFea X-Proofpoint-GUID: YcnjrERkwVhP-xy0laVrSODAkpWcIFea X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_095037_346085_2C43538D X-CRM114-Status: GOOD ( 18.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org arm64_notify_segfault() was used to force a SIGSEGV in all error cases in sigreturn() and rt_sigreturn() to avoid writing a new sig handler. There is now a better sig handler to use which does not search the VMA address space and return a slightly incorrect error code. Restore the older and correct si_code of SI_KERNEL by using arm64_notify_die(). In the case of !access_ok(), simply return SIGSEGV with si_code SEGV_ACCERR. This change requires exporting arm64_notfiy_die() to the arm64 traps.h Fixes: f71016a8a8c5 (arm64: signal: Call arm64_notify_segfault when failing to deliver signal) Signed-off-by: Liam R. Howlett --- arch/arm64/include/asm/traps.h | 2 ++ arch/arm64/kernel/signal.c | 8 ++++++-- arch/arm64/kernel/signal32.c | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h index 54f32a0675df..9b76144fcba6 100644 --- a/arch/arm64/include/asm/traps.h +++ b/arch/arm64/include/asm/traps.h @@ -29,6 +29,8 @@ void arm64_notify_segfault(unsigned long addr); void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str); void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str); void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str); +void arm64_notify_die(const char *str, struct pt_regs *regs, int signo, + int sicode, unsigned long far, int err); /* * Move regs->pc to next instruction and do necessary setup before it diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 6237486ff6bb..9fde6dc760c3 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -544,7 +544,7 @@ SYSCALL_DEFINE0(rt_sigreturn) frame = (struct rt_sigframe __user *)regs->sp; if (!access_ok(frame, sizeof (*frame))) - goto badframe; + goto e_access; if (restore_sigframe(regs, frame)) goto badframe; @@ -555,7 +555,11 @@ SYSCALL_DEFINE0(rt_sigreturn) return regs->regs[0]; badframe: - arm64_notify_segfault(regs->sp); + arm64_notify_die("Bad frame", regs, SIGSEGV, SI_KERNEL, regs->sp, 0); + return 0; + +e_access: + force_signal_inject(SIGSEGV, SEGV_ACCERR, regs->sp, 0); return 0; } diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 2f507f565c48..af8b6c0eb8aa 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -248,7 +248,7 @@ COMPAT_SYSCALL_DEFINE0(sigreturn) frame = (struct compat_sigframe __user *)regs->compat_sp; if (!access_ok(frame, sizeof (*frame))) - goto badframe; + goto e_access; if (compat_restore_sigframe(regs, frame)) goto badframe; @@ -256,7 +256,12 @@ COMPAT_SYSCALL_DEFINE0(sigreturn) return regs->regs[0]; badframe: - arm64_notify_segfault(regs->compat_sp); + arm64_notify_die("Bad frame", regs, SIGSEGV, SI_KERNEL, + regs->compat_sp, 0); + return 0; + +e_access: + force_signal_inject(SIGSEGV, SEGV_ACCERR, regs->compat_sp, 0); return 0; } @@ -279,7 +284,7 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn) frame = (struct compat_rt_sigframe __user *)regs->compat_sp; if (!access_ok(frame, sizeof (*frame))) - goto badframe; + goto e_access; if (compat_restore_sigframe(regs, &frame->sig)) goto badframe; @@ -290,7 +295,12 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn) return regs->regs[0]; badframe: - arm64_notify_segfault(regs->compat_sp); + arm64_notify_die("Bad frame", regs, SIGSEGV, SI_KERNEL, + regs->compat_sp, 0); + return 0; + +e_access: + force_signal_inject(SIGSEGV, SEGV_ACCERR, regs->compat_sp, 0); return 0; } From patchwork Tue Apr 20 16:50:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12214753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55E92C433ED for ; Tue, 20 Apr 2021 16:54:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A171960FE5 for ; Tue, 20 Apr 2021 16:54:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A171960FE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vfe0oHuNPqWARKwD8EEF0hXofn9sULPdDKjJRM3GYus=; b=QIQS0uHcuX2X9VLQYItN86Y04 PJ8iFNfgckzSiRRffNgYEnanxV8mTb/9LNAzjIhkzEMr3wiPGtfXLBnuafXN2oolani/bG+ovpbjU L0v8cMREjGZKWRiE+DWd2kXYVRx+DW9Vn8SV0U4r0UHpmC2VyP0Izn/3XXdAhzZUHdqxnY1BNzta3 k+7OYALFnLrFk1UwCt5ZYA0AeTRolROJfHUrx2T7ojF24bdeBP6+LxWX3ZEonO2CB46mZehA2EQXM go8e3EJeV8qXyzKJwDqObS93W5WmKTm4BaoKDUVzdanbRe0gq0RIriuMPcdZduoPg57oqHwAgOJ4V U0wDhOfBA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYtbi-00CcEE-C0; Tue, 20 Apr 2021 16:52:16 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYtaE-00CbkC-IT for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 16:50:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version: Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=oDHmLqAsgLS7mPsMg0BXUPLJw+J0W7W2uM1tHebWINQ=; b=kr+Y+hxGJWfIjkcOjDwzMEgfp1 9Clpl61JXvnaHvZkzqHSjMtY/clpTDKIK3uS9zaFAOVIg5h+qbNOfW9Yw2bXZFkm1zQdneFJHaCSP 1Mcr+eT81HJkAaTzN0mCqLgfgDyCvVUC2N2cyUOM6zhuxQnZZ9/jEYVlFIj+msJpH04Zxij1aDtWI 6tsq22/Kw0H5rNZzPAzAREMkH4vo5aHhNB9hgNGiFtsXCQOQkIFKQHP13QYhsFDSxFgZXPkQkHdLs ikqO8Rz38a/CVSGuSph2YMhLec9GcPpFKlxpHOZYMHz9SZShNax//LA1irY8Hp9R78a9DA4Iweu3n ri5L8IIw==; Received: from aserp2120.oracle.com ([141.146.126.78]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYta9-00CHrd-46 for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 16:50:41 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGYwqT110562; Tue, 20 Apr 2021 16:50:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=oDHmLqAsgLS7mPsMg0BXUPLJw+J0W7W2uM1tHebWINQ=; b=OWx65MZVJICIfSodKnIOK8CX0Lq2KK8HwZQ8+hwvleQa48M7Iz/S3X9O0UUS4ozJsnFn Tv5Dwk0aLC2flAjZB5dlkFRENokgBul9nSZHo1XWtSQlRhazj781FP3VUuZveOY6Pgps 4u9SeMGwjspECxV4RMJNxxmSRKUlOKhM14FXl+AAUqX+0aC1xKHoL138VnFlutZaS8h9 QeTGYSq8Pi+tlIPv7XWK4RSORkJB74UNJB7qkzo4TxHekEVlK/YrXV8HmFrtNrpSUXkq rR7UzjqVz/RQ/S+NcVfQv5HO6bDo91JW43kh+bY9aUq9EZBd5Sjoeu/pzz+KhgGDhuSo qQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37yqmnfuw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:17 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13KGa7gM084073; Tue, 20 Apr 2021 16:50:17 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2043.outbound.protection.outlook.com [104.47.73.43]) by aserp3020.oracle.com with ESMTP id 3809k0n3gx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Apr 2021 16:50:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BKaBacitNyl+gvqZa9QVaR07iNOa8oqSJOXBie5r33lv5ztlxtX41/15xEwhw1C2FZ6S4zcqmjFbw1HQfPZ+8Nvy4eGzScojKS5fcgxtUqwm+diZH2wRPvcEGSK4dlX7MxlaoxSs/PJg7LjYYGtF6ubXvOm/K8mWtv3yUAZEsChLwqkjI6a8sb2GBs5Zi9U4Q3+ikuV+pMzbDYPfAWhYGIo/erWcxYnnAb5IMKW8Z0E1MDBl4vpkXnwqFYwDNH7l313mXWkE6b66HEh1vfOrhfkPfeuKLiKYDID4C+rHFgA5hBHWwQqKNVgcLqzlGaJPfoUhp7oUB9zsjfCkST6P+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oDHmLqAsgLS7mPsMg0BXUPLJw+J0W7W2uM1tHebWINQ=; b=dR/QX5EcpC7BEO0fy5u+mc/5s5jQXdb2Bspk8NJn9Sbs6xY/fsyi08C+OWSX44bCDu+/aa4BWIJ3rTzRg869l2WmgP2dJJjrl3dSreK22WWuaQbjITvCjmA1qb7Q2I2qCKFd8+oPYnlbvL7DwSffdV8SW/6E7WjER2y3jyfH/zSAjAf4hCpLjIyFvbZbA5qgyKMy4ad3/oyKf4FBKjxeVNOmf809Jix7/yHk29OcuPTDSvquk1aZPozy3xAVPg71wylgvZ2f4MvdRNiilaHvdQO1ZV9mtFJBl7HpwkDcNIvF7JBOCzbNxIbKOf/7/QzFjMQS7L3bFONJhiAsYmi1Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oDHmLqAsgLS7mPsMg0BXUPLJw+J0W7W2uM1tHebWINQ=; b=iXVcQRyfhEV8rBhfbndYrVclGMTbtn/4Mb3JGpMa6kvGeQl91CLVGeZpLa872sPWUkE3ranR1EfNmDJXdz4gZRWRkDo/BJddYB5ayApyPMTMbd99x4k6fL7lLhWL+xtxRNt5tr3XBZPWpzJo5Vb4Ipjp0IzFIiw2Hzsj68Nk4qE= Received: from MWHPR10MB1582.namprd10.prod.outlook.com (2603:10b6:300:22::8) by MWHPR10MB1536.namprd10.prod.outlook.com (2603:10b6:300:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Tue, 20 Apr 2021 16:50:14 +0000 Received: from MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811]) by MWHPR10MB1582.namprd10.prod.outlook.com ([fe80::353a:1802:6e91:1811%8]) with mapi id 15.20.4042.024; Tue, 20 Apr 2021 16:50:14 +0000 From: Liam Howlett To: Catalin Marinas , Will Deacon , Julien Grall CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Liam Howlett , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" Subject: [PATCH 3/3] arch/arm64/kernel/traps: Use find_vma_intersection() in traps for setting si_code Thread-Topic: [PATCH 3/3] arch/arm64/kernel/traps: Use find_vma_intersection() in traps for setting si_code Thread-Index: AQHXNgU7TopVgzWGUEaUH9orR8DEdw== Date: Tue, 20 Apr 2021 16:50:13 +0000 Message-ID: <20210420165001.3790670-3-Liam.Howlett@Oracle.com> References: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> In-Reply-To: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oracle.com; x-originating-ip: [23.233.25.87] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0d829fda-db64-4971-fc26-08d9041c5e94 x-ms-traffictypediagnostic: MWHPR10MB1536: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aP6pqR/WIteaIsHeiV1f2v0xyugwQXhOjRqKqK7UIFRQB82k3tYaNwrkMD3ppauNs35h7pa0TXhL43Y4V6pBmhfCrou7o7VejVhO1/rzD1nfVbMjrFEQL/l1L5rEBTesn7tqIb9nWv1UAVVz4uVMq6Nh+7T0oD0W/sndF/GlUaJG3bQX+wsWormbhoayTABod9nu8+pyKiNm5S2HJwE5CVtgGR6T0r1PG95bZHJ6WycqljbcZqknJf05PYLXwWvsy+sOsRp03OOXoEM6zw55v9T1W9bSgxu9lMEp/jgBcarg4JxZFF9h/aADK03h8cWaGHOObEolZHoMcmJ79xovw7fY1JNdSiBmbGv7QVuW9cYGASzImu53Q2YVOLc9XTHrWkWlh2n2JOOlptYuvl0IZSR1CO4YqI8EKnZYUEppMxSuHKuqkGu/gyzsb0K6r5wVDi+5qsEI62YQZCanq/1FxIfBImEqwHRzL3PvFlvFAOIkU1HD1vumtRGRgKGEsfHZBgBpDJgNaoXWfmlA04I3FcY0HKrt3kWd80F9FsPk43wklOo2LGjlEmLu6QmzfPwkwSdSu88vhipDeenS0oxYWDeulBQT8z9OTVbSDXCkqYM= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR10MB1582.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(366004)(396003)(136003)(376002)(83380400001)(64756008)(2906002)(5660300002)(44832011)(6506007)(186003)(71200400001)(66476007)(66946007)(316002)(7416002)(66556008)(91956017)(54906003)(8936002)(1076003)(26005)(76116006)(8676002)(110136005)(36756003)(2616005)(122000001)(86362001)(6512007)(66446008)(478600001)(6486002)(4326008)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?eAe8HF9r75jQP7W8UWVaznpVT?= =?iso-8859-1?q?Mmd+vC2PenTlfXFf+0Bz99jfZg/mfItAl6aXxzG9ynGfrHfLV0F696OHKinX?= =?iso-8859-1?q?PZFX4CLcmHCql/Skd7cF3d3fhjYlrKCfMxF1iIskF93sc4ZH968Vfchk8quJ?= =?iso-8859-1?q?R277BIV0nRDy4iIBJYt/XxQKiM3toJvgAlYWnXcFCeuC8kKSGAQtu8B80sXV?= =?iso-8859-1?q?HVOnrQge1W6bb5WFYI0BXpxhuWK80ISWk8ACgSUPgBQfPSHsFpJPuO5usQik?= =?iso-8859-1?q?f2cEumRKJDIkxIDmvAI8kS3XUGpkyYXa/TVrVjQY7soDsE78UVO17ZtfJLQ1?= =?iso-8859-1?q?Rdd+bxd7XSAACxHn0F05JKM6cp3u5MS4O9lQHIrY6dyvUGJpI7lbusrcC9RP?= =?iso-8859-1?q?7L70eRnc1YhmRXBCJbdHpQ1+sBQRQdnrJ76dWUaNehzZwUeW2udAX1QVKf6r?= =?iso-8859-1?q?iDuouGfPQgN3S1vU7i2N7Hi0iujl5j1qrDryw3A+onFdHOXezSdCFxow4XM3?= =?iso-8859-1?q?DUKNODvU8QcIlvkifUPftRj5PTqpQnu43TsQOhenwEQDQ5u5bS6Nzis3FwYy?= =?iso-8859-1?q?4d4m3xdfk29cZQ2E47gB809/yyVYXe8nlyZUXLH++Yad8oqjZqVI29MELV8E?= =?iso-8859-1?q?SigKMfi9cKvNGsWaYBKol8vPOvxdkNEwp+Fe42cJLZ20V9ZYUZKQfmvBo8wy?= =?iso-8859-1?q?73WPisnr+i7b6qs3NRH3OvvFdwiTGbUOcq8wrjr/1EhHiwq/HaCOWidD3kI+?= =?iso-8859-1?q?wCkbFKVbnUqEZFMWSFwZnO/2HfSFtYUH1f21CctVMeN9Z9oxicmDe3ndGtgG?= =?iso-8859-1?q?AA4gRzppz7ZR3C86Q9B8wDPLYvIFgzrLUMldFFbY+JAXGIAKLlc/i1kOG/W0?= =?iso-8859-1?q?7WhuDwzm5rFjnQRIgWRUwlLnERHRTcqrubRThOvuw9pR15AEtMD/wnStKJEj?= =?iso-8859-1?q?ca+cC7HU1sCGlT6fZ+A3bN37HDfRUB2K7b38HynRvGOIkYIPbwCXa3zaYWEl?= =?iso-8859-1?q?qar7qCVV8bqRbKIGjLR4aPMKyb7AWi4IvgF30ZrlMyBiU6Uhh5w97gzUCxM8?= =?iso-8859-1?q?dS5uonVtxCZMkqB7yMewnQHZVTkm4cFc9yHk3WKJk2euAILbuiBaUzEnUwWp?= =?iso-8859-1?q?+OcHCZ9B/BmcfXMruJ3Rytsm8QbpuvtId+053ab+AVGHcOW9bwhlbB0ZTROd?= =?iso-8859-1?q?75M2HTlupd6YcYYrIHbkMufbH0TTBRVt7GpB7/4u7WVAiHBf7A/LOdL65i50?= =?iso-8859-1?q?M0XwXBWJyIZy9dKH7BaMZpW6oTuJazv9sN6SaUbcj3vstf3nxmWKtk3WwwZF?= =?iso-8859-1?q?rask/b+HND9XfBozQN59mhrE2VRmHcqrlAPnlViRAKc2/cAdeOizXF5wY8f?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR10MB1582.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d829fda-db64-4971-fc26-08d9041c5e94 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2021 16:50:13.8425 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: UHAnPyoKhs4auSck29MgX2MYyi9+gjr7bv21FIfbedFBxIOo+TRlU2Wdb8scM8HfztUFvHyqKOcaqz3H111xBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1536 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-Proofpoint-ORIG-GUID: DlUi-Rm3_w_lNpuqS41IgthNEHYqyDNw X-Proofpoint-GUID: DlUi-Rm3_w_lNpuqS41IgthNEHYqyDNw X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9960 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104200117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_095037_345653_2DCB8039 X-CRM114-Status: GOOD ( 20.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org find_vma() will continue to search upwards until the end of the virtual memory space. This means the si_code would almost never be set to SEGV_MAPERR even when the address falls outside of any VMA. The result is that the si_code is not reliable as it may or may not be set to the correct result, depending on where the address falls in the address space. Using find_vma_intersection() allows for what is intended by only returning a VMA if it falls within the range provided, in this case a window of 1. Fixes: bd35a4adc413 (arm64: Port SWP/SWPB emulation support from arm) Signed-off-by: Liam R. Howlett --- arch/arm64/kernel/traps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index a05d34f0e82a..a44007904a64 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -383,9 +383,10 @@ void force_signal_inject(int signal, int code, unsigned long address, unsigned i void arm64_notify_segfault(unsigned long addr) { int code; + unsigned long ut_addr = untagged_addr(addr); mmap_read_lock(current->mm); - if (find_vma(current->mm, untagged_addr(addr)) == NULL) + if (find_vma_intersection(current->mm, ut_addr, ut_addr + 1) == NULL) code = SEGV_MAPERR; else code = SEGV_ACCERR;