Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1050055lqo; Fri, 17 May 2024 09:11:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmU0aI7TFrOau9MxZ7a3NdjiCG+nTAq+3gJCkQzlqtxyKRFbUNTOA3oRhlGRjbrL1nZueeM0QPGZiy2YydDFdVTmFNo2+YTL+IviP7HA== X-Google-Smtp-Source: AGHT+IHYyuX3ZDGbqbKXk+axyPGLQgk4OjdFCTY3ZRwdMOs5Ifb1QporlKAdksu5vGcOh9UBfLt2 X-Received: by 2002:a05:6359:4c09:b0:192:4634:b1db with SMTP id e5c5f4694b2df-193bb517d7dmr2398115555d.11.1715962270940; Fri, 17 May 2024 09:11:10 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43e3d8bbacesi31606891cf.329.2024.05.17.09.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 09:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182335-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=YDAWlxxx; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-182335-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 956A31C2189E for ; Fri, 17 May 2024 16:11:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F18D612FF6C; Fri, 17 May 2024 16:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="YDAWlxxx" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2107.outbound.protection.outlook.com [40.107.220.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B41E12FB2C for ; Fri, 17 May 2024 16:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.107 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715962251; cv=fail; b=GllNSMzM1mXQxvG9Us3yMX7kdU2UoQLC63VeSMilSwfoWnLFqtY0K8/8ik31Ll26ux2aRxPJTOQc5Dzas2Mq+sSu9vSscvo+7dwmXP1HE5lKVmn987qOUSR+MRSeBrFRCxQh/f1V89AzVgoEPPImIf0rAgIfkVxhffk7IOVGqyc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715962251; c=relaxed/simple; bh=HGNP7H+3GY9PZxJ80CVy35fx0g2YnFaE3OzLuhfY0cQ=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=X0slf6LhLSconIDd5lyn5D4yUU5PWfH6ra0IYAxZBOkvEengU6f93C7AJmPWS8fwNBAYbm8nq9GB7k8Lolzm2MJxnRs3fh5jsTrSkX/+Q6GVIs3ZFBABusGvah1U/JgecpDHL1BZOORrgkVN0x1fOI4oY/gXyeZYNAZZ1YvENtQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=YDAWlxxx; arc=fail smtp.client-ip=40.107.220.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+6KnGG5I7uxDTbJCD0JqEg/wwd9Hz7+fM+Ke2Qk593HPjqGwwatU+iM5lnK0ktm2i5zSW7mDV/SlMjrVNkHSOGjG+Stq3yrxRzjz/KVXAVldEgc4WrQ7AZvBAGBwFL7wX50LfFkVyjSKeuZVp32D7OjjYYCyx/IAaFRfhTqZ8GjEonaRuxlTVbD3OnMOd1bUZxwwVZRgSHViMJYW2F865T8JyyMwq4va81t/5ox2RPL7tiD2wzcCUUY+PInnlDtiOw2GOZnu5PEgwNxLdaovy/xhBkxXQRQFlXoiMudZUWwOmqYlqheyn8TioczPUkVJKTE3EfUEi1bqpiB/5q3Kw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RXVetSWuFWDLbGHJtJlxZSxCcPOGkZNnubLIdf9ckzc=; b=ZJQH9DtVo6Gm77V3oreiLzh5E3yow8qCJGoU2Zx/9olJRhR0Ctxj/StV7rBMsmfyOV1AdqeIuMzqTknLAjnSpEbF1DpOVXH/RgFS8FVDvYTUnfPleRjTPwrgtAZC+Tj9NiHvVLXkIhWbmfQAkBLOl2mNU92IHewzDZLn6PGw81reOqruuE+0bPkSgK9Rgj3q2gerSK3HrD+VdR6kc2zndt1ETu4MELmj84+4fltgggtT8ZsKkud/jtCD7WIChNE+YifOimdlNq6yZbnuq7tN2IouscuUraFee6Rx0mQmPokbrzEA+fVwZi4FHctpV1AxZRqXB2jFsVsPWZNwp6a5gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RXVetSWuFWDLbGHJtJlxZSxCcPOGkZNnubLIdf9ckzc=; b=YDAWlxxxh6WsywrCIeBMWv5TuxeerDNDbGAKVb+SpVN3fQctOz5CIiDPFUlIGqQOm4TlBqm7HA2iq5SspL3387ThYlWjzVL94aPLGCO7rdwIgPVWtXaJihs+uTte6SGw091nr+3K8FmHgf3h5jLeoFI2UfDhUgOkczihgKB1hNE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from BYAPR01MB5463.prod.exchangelabs.com (2603:10b6:a03:11b::20) by PH0PR01MB6683.prod.exchangelabs.com (2603:10b6:510:90::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.30; Fri, 17 May 2024 16:10:45 +0000 Received: from BYAPR01MB5463.prod.exchangelabs.com ([fe80::4984:7039:100:6955]) by BYAPR01MB5463.prod.exchangelabs.com ([fe80::4984:7039:100:6955%4]) with mapi id 15.20.7587.026; Fri, 17 May 2024 16:10:45 +0000 Message-ID: Date: Fri, 17 May 2024 09:10:40 -0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: mm: force write fault for atomic RMW instructions To: Catalin Marinas Cc: will@kernel.org, scott@os.amperecomputing.com, cl@gentwo.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240507223558.3039562-1-yang@os.amperecomputing.com> Content-Language: en-US From: Yang Shi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH5P223CA0010.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:1f3::11) To BYAPR01MB5463.prod.exchangelabs.com (2603:10b6:a03:11b::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR01MB5463:EE_|PH0PR01MB6683:EE_ X-MS-Office365-Filtering-Correlation-Id: b1657c02-d61a-4b8e-45af-08dc768be864 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?V2MrSXNLOG1rd0E3NTNnR24vRXVCSjNlR3RHWUFIL1phSGg0Nkl3enJ1TzBw?= =?utf-8?B?NXlNSWJqUFBJWUR6UnZidkhGQUhKbEtMQmZ2aUhEeHVMYm4vcXRXcnFqYnZi?= =?utf-8?B?bDh4UXoxTDhsUkcvdDFRUi82b2pWRjh0YmhIcG5xbnhwOEU0ZFAyMWt1NFZK?= =?utf-8?B?SDJiWGRSbG5LdDVkQXp3ckJNU01lT1AzZXltbXZCQ0cwMDFEZnFVTVJESW9V?= =?utf-8?B?RHI2emdWMDk3WEJpOFN5dm8vWEJMWStIWjJ5bG1pYUVZOC83MTVRRFN6QTha?= =?utf-8?B?VkZDbytTczlIVFUxYk5xMHhiR25waGhvQkNZYVR4cFJWRHl6QlJGRFJrcjJn?= =?utf-8?B?cnFQYnE1OXNaNUIwa2xTNUhNNFlNS2E4ZndvbFBPUnhWTFNLc1BPOHF5bDNw?= =?utf-8?B?STVJMWI4OG9icFF0MW1rNnNJSTYrZGsyUjZDUE0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U0RMaUFCdjBwTzdBOW1QWHI0cy92NmZOR3pM?= =?utf-8?B?NHZqQ050Um9UM25qZ3RXOGFIMTFCcFhraWZMb0haaVhyZ3F3UElBOFFhcHc2?= =?utf-8?B?ZW1lTDJVT01Jb044UmxnOHhYRmFRWnZjb1NKVmRHREJaTkdCOHZNMHZIK3BE?= =?utf-8?B?RXBvbndyTDd5OTBqYzNZZWNWYzZrc2xwQ3FTVGliQUg1U28zbUlnZnVYZ01m?= =?utf-8?B?SUI4L0pSdU5JYVovYjJ3ci9qU0g2N1k2UUFDNXNpUnFBRmpKbEl4aGYzSzhx?= =?utf-8?B?YWMvSTd1RjZMQ2h4RlIvdW9McFR5VGpjRS9JSjM2MEo4MGh0ZTR5NHFvYmVi?= =?utf-8?B?SG9ZMTZiS0oreEpsNVdValFYMHRpMVhaTDYwSmRhYnQzZUU3MjFWSU5RPT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR01MB5463.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vkh1THZkOEVhNG5UOWRHUjZIeng5NElDQTRobTd2UVRwZzM0amVVTFFZZmly?= =?utf-8?B?VDUvYzU2R0d4c2luYUZMQ2lxTDFlRytnTkFaY2hBU2hQeDFNTWNycllpSXhl?= =?utf-8?B?TVpiT0t1NWQvcW1XMEZxYS94c1FVTDVjaEt6MmRJSWlDbFBxbUYvVlNmZGhE?= =?utf-8?B?TDVFVUFicEtIRyszZ0tGdS9kSnZ0VW9UbDVHeVZmRysyNmJqc015TXVBRWta?= =?utf-8?B?SldQNkNtWG0wSlFFSk1JWVBxLy9aQU5tZURweDZwS0E0Ymlzck9xK1JxWG9v?= =?utf-8?B?bFlrRkhCcFAyMzVvTExaSHl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mZPNjJZaERH?= =?utf-8?B?bTBIUTA3dkIzWXJ0ZzRONmQyRnhTZHJnQ3ZDU3cyZ04zVUJsY0JRV3pVbEU0?= =?utf-8?Q?RyzgiisYONUjPwcQhp4HpXQ=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1657c02-d61a-4b8e-45af-08dc768be864 X-MS-Exchange-CrossTenant-AuthSource: BYAPR01MB5463.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 16:10:45.4286 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G8xH6v6YKoQ9JOSe1pbVekRcTJB0jtd0FAcCk4jvR3o7Yl+mW2Gj6E7ipjdqvN/xSUOwvjgjqPVh5AonkIUav1Fwa+8FZhTj0hvOzxIl1xI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB6683 On 5/14/24 3:53 AM, Catalin Marinas wrote: > On Mon, May 13, 2024 at 09:19:39PM -0600, Yang Shi wrote: >>> That said, I'm not keen on this kernel workaround. If openjdk decides to >>> improve some security and goes for PROT_EXEC-only mappings of its text >>> sections, the above trick will no longer work. >> I noticed futex does replace insns. IIUC, the below sequence should >> can do the trick for exec-only, right? >> >> disable privileged >> read insn with ldxr >> enable privileged > Do you mean not using the unprivileged LDTR as in get_user()? You don't > even need an LDXR, just plain LDR but with the extable entry etc. > > However, with PIE we got proper execute-only permission (not the kind of > fake one where we disabled the PTE_USER bit while keeping PTE_UXN as 0). > So the futex-style approach won't work unless we changed the PIE_E1 > entry for _PAGE_EXECONLY to be PIE_R by the kernel. I see. Thanks. Yes, I did see this works without PIE. As you said in the earlier email, exec-only is not that popular yet. I think we can just ignore it for now. >