Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2610897lqo; Tue, 14 May 2024 04:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVyE6gDdKyAMcH5Enag/MFN/kTcy5D/duQUCBpTN8pLUH8y0s4MmU60MCTXvEQd+sT9HgXGoQqeTMAXPwrlyR5Gt/6i8xM9LAN8GfUvg== X-Google-Smtp-Source: AGHT+IG3KLRgw6y5jCv9Ue94VrvxEC8noV8LYFEqplGnOOMwXjsNSr0TsRfKch52TCQuTgIBsUwT X-Received: by 2002:a17:902:dacb:b0:1f0:84e3:a620 with SMTP id d9443c01a7336-1f084e3a898mr18999985ad.13.1715685551125; Tue, 14 May 2024 04:19:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715685551; cv=pass; d=google.com; s=arc-20160816; b=sLTSYhcwMfaSdpvlWIyrft+1TApKMPNdwOyylH2OUYEM7yFAzIYXVQVCBkeFy8Y0iH Cm7qI0ia4dfG9Ud8IzwpND06I1r1VBbqPiNfW4NtgUuEc5cEqZM2tv0cwMd2vof4+S4A H0zJ0PQCgs4XszpRrMLuFrkm+YKyY9Z1t5BFBl0yjZnfsaMNTz/WTMwKRt3dwsplkqRt bLhul7v308TwSgNcrqYsJ3kLzYJqt9HFT3EHuwOSRpSTTtq3nVIclhPax8znLh4Jrfrj +q5j+ZTGuI4DcRdmmmouufpqUgtM0c6nnVSGpbRblKVsGkyRA36Glae5howU90iJwhng L7PQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=LyAQWfne8YAj1CfrTxkekMORDCwK0GEyXPdgX+ygeX4=; fh=7EYPrFYfZmpsdtLhC4O0F4aY7S+h0Cko/MWaWf/mJ8I=; b=MB0HS0f33OT5dHOFm85fn8Zmeu/Oaj7Gc5P0WoV+zv2VuwhwTK0a6ucIUwtbuapFgL hCRU9wAnaFudbNjFbvwd8zUvyrCafvHuIWd5xUM4qglWYi1BrJQ1B4nNonbRiRqxrWII F9cidj92IbxxOm94a8WWQcjte4FsfVt1r/U0qslwY8VE7cbaHLdWpF9Vtgz4486TAIZ6 +psV1WoubW+jiw7nTQfOfjo+yTUpHwyRZHPCMDSG1UnvPPBB6lyWr9uuwtOQV4zsZ/G4 jSEeBOao8beHAbi9GX9q3RLxNz0RtnltzRNzyYQ+TJ1wGXDv67X6doSDNzj0NpDm0Mfr QRBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-178582-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9cf256si117250075ad.91.2024.05.14.04.19.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 04:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178582-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-178582-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C3EDD282517 for ; Tue, 14 May 2024 11:19:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B62212F397; Tue, 14 May 2024 10:53:41 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9BC0C12F384 for ; Tue, 14 May 2024 10:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715684020; cv=none; b=iM8FyKVXs1XNTY7WJTq/8AA8CXCoPRoetf64PlT9SFr11o25PslAQviklCHOyVTWVgvcLdJL0Ral2023ixoDBNY+vNqqL+FV8oxFkt4P4qnFA9J8lU89HI2r2b8a+nwx6GPnWa4PyTGFpw9iCZyd1SmV4VYvhk5+mX+SOHmrWrQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715684020; c=relaxed/simple; bh=EdSoPuNL/ZHfLKbZlYhh8ep6nO2cbQb3toaneVwtv8w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K/WhKAseYyrMvpzxW+cze5q7sEj0Tj10yviKwd85PycMTOc7fBzUGjQ/jDsTMc1lZ/dRDvWKuUKvp7EL32jJUhBPXGnn/DL4IaHa+EgkIcF0X0WfXiNl1CyqHR5mJFeip0M8j1XL2V5sePUPQUmd+QpqHPIduDVIv2GHaq1EzyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40EF2C2BD10; Tue, 14 May 2024 10:53:39 +0000 (UTC) Date: Tue, 14 May 2024 11:53:37 +0100 From: Catalin Marinas To: Yang Shi Cc: will@kernel.org, scott@os.amperecomputing.com, cl@gentwo.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: mm: force write fault for atomic RMW instructions Message-ID: References: <20240507223558.3039562-1-yang@os.amperecomputing.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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. -- Catalin