Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3383726lqp; Tue, 26 Mar 2024 07:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbxcdFTPW5EwD/KYPDZDJWNRAvoqrEAzceFKD6WeqpQXxxf2YV149/6t70s6FxCHpuObX4908FhZEQLRXr6X/YFyAtU5XuDUq51J9N/g== X-Google-Smtp-Source: AGHT+IFSbH9Ge1uMTpV+FC6265uiZ9s+bmv7ELoMXzy9DrP21wT8/ik2Xx1dAXg/bf0M5XNkPqKo X-Received: by 2002:a17:90b:1bc3:b0:2a0:390e:f032 with SMTP id oa3-20020a17090b1bc300b002a0390ef032mr11885pjb.32.1711464657674; Tue, 26 Mar 2024 07:50:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711464657; cv=pass; d=google.com; s=arc-20160816; b=Z1APztHEvd7CIPLuyU9VJdSYVfTHHiBoGSiYR74ob97BX72pPPWSN1m89RyMgJeP9f KVo1MRSNMxJV8ak8omAc7AeH7bV5wc9B9LNwP9dHAUfMf/oVgmpjTu6EtrLFat06slty fVL5TfTKedf0OyKFnTyyairRQyW++R5f31V25gkujPKjljP/ToNq7799xm8a75ox1Xwx KauuUHF0PuAjVQZEeuDk1+wWsp3xuB06DhVrIX9n85FR2qVM31BUjH/owe6J6t+gLK9N IBMUXRfL1ML+2u1tNl4BJSL9fGPA8fWmYZzTrqUzUhlvm5qgOCG2I4HtEzAw+ex440NM facQ== 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=DAJ/JhQqyI3HCNKdlfe0abeACZojSWtUG0yZq7UPSYc=; fh=Sa4ZGfEzEbkjB37LM4mgujt83hoc06PVIbGClDvZWGQ=; b=ekROXCd/4hb1ngMdB/s60x/4SSFg5W2RUXVMbo6q8ItiwrTztAJ5CcAFe70u3XfK9I wCJx47Ts1CXm1cGCrpbpfsWeC6tCyfOwsZb42GroBanDE/QgtmVHgMkqtUsP9YepwNy2 sNK/2TlDvDwiwneJYkftUShNjWuhb+bAh+b18cWxsUPq/7kQYc2Jz//VONoGXvncl4o7 4KEIXDOzTRbmQUGZ2JkYrWQqkZ6EUbgtvZs1E5Qng0SZzNlqp2BKEpthsXsXrothkPzU zD5vXuntZWm65M9L2yqTsdziH2jTdA8Dc43vh0M3hlD35z3qs8JFB0fnIhVMvmGTnVxF s5rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119216-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119216-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 ob12-20020a17090b390c00b002a08b4768cdsi1331116pjb.165.2024.03.26.07.50.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 07:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119216-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 spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119216-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119216-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 2B13B301DBB for ; Tue, 26 Mar 2024 14:50:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8669413C692; Tue, 26 Mar 2024 14:50:05 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 959C213C674 for ; Tue, 26 Mar 2024 14:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711464605; cv=none; b=XYMOxzyI492c0Vt12/cLA9O+fSsbvxEuy9hE7qNihweNMtWC5XCZtJ1GzrKIL6ID/owtNO+6AIkfhavuJ8sbCy4tgKniWhUF+f+eP1DTN/K3NaBjo/zWa3CAhn2ymx55dbqCdv9MSj/ZYsjGvEngdFPLug/LZ6/WWwIAVhlXNT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711464605; c=relaxed/simple; bh=K283dq0rMCMbXlbjFmsIYUEw3mlmXF2plQnChcVoYxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a41CK21z4Efd0Y++uNoE7x1L3Nf+tQBzxZJ02y82jisHHOI885WwgTG5TsUlvyYRZH2LHDR9EVz8PKsaQAISzNfp8IJHDup4z6JUTSSwd9nCweTHCITX1HDiW+wGuMursOgoiqYa2u190delaX9S/31j2bAiO+o+ORw/OUH6VWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BBA1339; Tue, 26 Mar 2024 07:50:36 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.35.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C25E3F694; Tue, 26 Mar 2024 07:50:00 -0700 (PDT) Date: Tue, 26 Mar 2024 14:49:57 +0000 From: Mark Rutland To: David Laight Cc: 'Arnd Bergmann' , Alexandre Ghiti , Samuel Holland , Alexandre Ghiti , Palmer Dabbelt , "linux-riscv@lists.infradead.org" , Albert Ou , Andrew Morton , Charlie Jenkins , guoren , Jisheng Zhang , Kemeng Shi , Matthew Wilcox , Mike Rapoport , Paul Walmsley , Xiao W Wang , Yangyu Chen , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] riscv: Define TASK_SIZE_MAX for __access_ok() Message-ID: References: <88de4a1a-047e-4be9-b5b0-3e53434dc022@sifive.com> <95eb125d-dd54-42f1-b080-938faca6a8a1@app.fastmail.com> <882fc86da89f4adb81570cde3a653e6f@AcuMS.aculab.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: <882fc86da89f4adb81570cde3a653e6f@AcuMS.aculab.com> On Tue, Mar 26, 2024 at 10:19:28AM +0000, David Laight wrote: > From: Arnd Bergmann > > Sent: 25 March 2024 20:38 > > > > On Mon, Mar 25, 2024, at 19:30, Mark Rutland wrote: > > > On Mon, Mar 25, 2024 at 07:02:13PM +0100, Arnd Bergmann wrote: > > >> On Mon, Mar 25, 2024, at 17:39, Mark Rutland wrote: > > > > > >> If an architecture ignores all the top bits of a virtual address, > > >> the largest TASK_SIZE would be higher than the smallest (positive, > > >> unsigned) PAGE_OFFSET, so you need TASK_SIZE_MAX to be dynamic. > > > > > > Agreed, but do we even support such architectures within Linux? > > > > Apparently not. > > > > On 32-bit architectures, you often have TASK_SIZE==PAGE_OFFSET, > > but not on 64-bit -- either the top few bits in PAGE_OFFSET are > > always ones, or the user and kernel page tables are completely > > separate. > > ISTR that arm64 uses (something like) bit 56 to select kernel > with the annoying 'feature' that the high bits can be ignored > just to complicate things. Yes, bit 55. We choose our TASK_SIZE_MAX to be below 2^55, so no kernel address will pass access_ok(), and we pre-mangle the TBI bits for userspace so they can't affect the check and fail unexpectedly. So it doesn't actually matter -- leave that aspect to arch code. Mark.