From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF2AC4332F for ; Tue, 4 Oct 2022 17:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbiJDRi2 (ORCPT ); Tue, 4 Oct 2022 13:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiJDRiL (ORCPT ); Tue, 4 Oct 2022 13:38:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2190A2AC65; Tue, 4 Oct 2022 10:37:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7C234B81B72; Tue, 4 Oct 2022 17:37:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BF34C433D7; Tue, 4 Oct 2022 17:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664905023; bh=rtWTTcYorADYGq6pdo3E4C1gL/XjJH4Ahw8UABoFkfI=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=AW/d2RlZrEmql6lmdB9J08tUx36SJAmdy4a3rxLcT/uNcnmh1IZzILjyjXvheJItj HovThrG+m9WfHr0GyMrxSv4eKXCO9KqB49VswiinXwhtW5TATjvXDCtyLMHQJGe4M8 0xaAdaSHdamY5I4lJivabCHMtDyl2e1lb2EjTnoEJjPPVxUSwG8gqbaqZLorp4KJyY 6NmLPrghfY1Beu0p0qZAFpWLlfqzc1FlN2yi6TyKWJMTpwNN0pj62SZlt6caAnxegJ UWSRdbZ7wNNecl6k/lFilTlUo70i1F/1QbzEnYxWpgQ//JFGrpgryXh8xjg73ZL1Tv QDwve4rusdI9A== Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 8272F27C0054; Tue, 4 Oct 2022 13:37:00 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Tue, 04 Oct 2022 13:37:00 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeiuddguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvhfeuvddthfdufffhkeekffetgffhledtleegffetheeugeej ffduhefgteeihfenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id DECA631A0062; Tue, 4 Oct 2022 13:36:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1015-gaf7d526680-fm-20220929.001-gaf7d5266 Mime-Version: 1.0 Message-Id: In-Reply-To: <20221003222133.20948-6-aliraza@bu.edu> References: <20221003222133.20948-1-aliraza@bu.edu> <20221003222133.20948-6-aliraza@bu.edu> Date: Tue, 04 Oct 2022 10:36:38 -0700 From: "Andy Lutomirski" To: "Ali Raza" , "Linux Kernel Mailing List" Cc: "Jonathan Corbet" , masahiroy@kernel.org, michal.lkml@markovi.net, "Nick Desaulniers" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Eric W. Biederman" , "Kees Cook" , "Peter Zijlstra (Intel)" , "Al Viro" , "Arnd Bergmann" , juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, "Steven Rostedt" , "Ben Segall" , mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, "Paolo Bonzini" , jpoimboe@kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, "the arch/x86 maintainers" , rjones@redhat.com, munsoner@bu.edu, tommyu@bu.edu, drepper@redhat.com, lwoodman@redhat.com, mboydmcse@gmail.com, okrieg@bu.edu, rmancuso@bu.edu Subject: Re: [RFC UKL 05/10] x86/uaccess: Make access_ok UKL aware Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org On Mon, Oct 3, 2022, at 3:21 PM, Ali Raza wrote: > When configured for UKL, access_ok needs to account for the unified address > space that is used by the kernel and the process being run. To do this, > they need to check the task struct field added earlier to determine where > the execution that is making the check is running. For a zero value, the > normal boundary definitions apply, but non-zero value indicates a UKL > thread and a shared address space should be assumed. I think this is just wrong. Why should a UKL process be able to read() to kernel (high-half) memory? set_fs() is gone. Please keep it gone. > > Cc: Jonathan Corbet > Cc: Masahiro Yamada > Cc: Michal Marek > Cc: Nick Desaulniers > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: "H. Peter Anvin" > Cc: Andy Lutomirski > Cc: Eric Biederman > Cc: Kees Cook > Cc: Peter Zijlstra > Cc: Alexander Viro > Cc: Arnd Bergmann > Cc: Juri Lelli > Cc: Vincent Guittot > Cc: Dietmar Eggemann > Cc: Steven Rostedt > Cc: Ben Segall > Cc: Mel Gorman > Cc: Daniel Bristot de Oliveira > Cc: Valentin Schneider > Cc: Paolo Bonzini > Cc: Josh Poimboeuf > > Signed-off-by: Ali Raza > --- > arch/x86/include/asm/uaccess.h | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 913e593a3b45..adef521b2e59 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -37,11 +37,19 @@ static inline bool pagefault_disabled(void); > * Return: true (nonzero) if the memory block may be valid, false (zero) > * if it is definitely invalid. > */ > +#ifdef CONFIG_UNIKERNEL_LINUX > +#define access_ok(addr, size) \ > +({ \ > + WARN_ON_IN_IRQ(); \ > + (is_ukl_thread() ? 1 : likely(__access_ok(addr, size))); \ > +}) > +#else > #define access_ok(addr, size) \ > ({ \ > WARN_ON_IN_IRQ(); \ > likely(__access_ok(addr, size)); \ > }) > +#endif > > #include > > -- > 2.21.3