Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1049976ybl; Thu, 23 Jan 2020 12:34:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxEnWXV6zoGD1YboLKGK75WSixsoXu11nqh8og9pw4sH5DKjx/GCGX2pVFfQLXZD7wuV0D1 X-Received: by 2002:aca:a997:: with SMTP id s145mr11916895oie.71.1579811662931; Thu, 23 Jan 2020 12:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579811662; cv=none; d=google.com; s=arc-20160816; b=vrlCjt4brVLz9OhLOHiaI5ii8Bx+y4BApxurOXXwU+Tuz9IIO2xPzMkZLG8eE2SkGz xmGvYRq3+yq5tojM93AOwhKUpi9MZeU6vXZbOyR83u4AoVgQ1WZ46HuyAUMQ3LIk3OiU c6nOXzcFJ6eTAueVU190gg4SVYpTVlb4SyLBNlGQcyxR8gGJiT1HF/SJutuzezEjoCKk CZXrOXVHXXImLXy8TTZMPQ+t7AXW4+si57W78uEDUwUfOP2RpW9HsMDIgfmiI5gAICIn exBx23777YdS2t2K0otla4IDTIaoljDTD9w7aX1XOkVPVl3HzkKNyhMxKCNqc6zR9zes exbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8DVtOQwrFkEAE5or+ctC9NfF/UngBhO5F9zvyg/cwIE=; b=D3GjJKx9YL74Q17QMLBB7qwA24G8AhcDjloq0mihpTG4vp9GDR6j3spK5X9h5+8g+0 IutPBTb5hsu2plskXKL2kX4/E30602fKoIe9E1eGp1pbGteIrvDD1Mz+QGnNIKvj/RLZ Pzo81jOJ+Q3zvbfEww6UL7YaD0Vck9bdffKEQt/dqIzJqUWNTmKbY+oWquUJmM/bkntE X3lCj0n4PxNn677Y7ygnPSnfF2VBouL+W9588UqIJn1FrwamLH6109oz/HmJ9rHsAArm 5f92RQenyWbcb4FO1x37zPePgYQ9JDuRNAcnw3GB2s8026BoviNxGF6koPtCppRuORYg v7KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=eQxTZQW0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20si1718771otq.190.2020.01.23.12.34.10; Thu, 23 Jan 2020 12:34:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=eQxTZQW0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgAWT6V (ORCPT + 99 others); Thu, 23 Jan 2020 14:58:21 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40151 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727816AbgAWT6U (ORCPT ); Thu, 23 Jan 2020 14:58:20 -0500 Received: by mail-lj1-f196.google.com with SMTP id n18so5038382ljo.7 for ; Thu, 23 Jan 2020 11:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8DVtOQwrFkEAE5or+ctC9NfF/UngBhO5F9zvyg/cwIE=; b=eQxTZQW0N74htNr8ZIoBTg2RQDPW3OjTEHCMc4sFe5oYhaOUGSJvrl6o1eL0CZRoF6 x82sJpEoaWzhBeyAQr4AJVLWbXFgY8LgUhy1SsB1ddXX6DI1lqW3atZTfWsWptXew+SX fwPcf1xNLR3ZLFeVh0I0M9xVVUDiWrMIvhW4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8DVtOQwrFkEAE5or+ctC9NfF/UngBhO5F9zvyg/cwIE=; b=nz60ZZydGjb6yRtGCh/+n8IPl9xmaHyyF2ZkZithJwb6VoA91wN1bBsM7LPYM7yxz5 n/Ui651k4rY14/BTWGFWqiZfOJl7MF8rAvWJpyxJGAfAe4+GNYg+unKyJu3/JFxsxP10 Z+NfSI7ttjV+Jd4j/o8kkBxT4YUzkKitlr7ANAeeci02crVTrt/NN8ey/I7Jo6x/kKYn aJvvvGxC6l76K3yoB18SdSOEPOKNrOu1WCuqUv2UVVtJ2N+VvlegeYiZhRh3Rs2kBxQM GRFoSUobYPMGPiqlUNbbPmTPNMFJwisrMCW0mHj2KRdr3kyvr0myNDHDZCwfPzJRfSx4 K5ZQ== X-Gm-Message-State: APjAAAUukeKGXZLA2kJSqCrUAgIrSi9BQhHI4lUQs5R5/8Rab7ikKK55 OufvGT5GxGXvg5PylOOhNq4xOqSjnDc= X-Received: by 2002:a2e:571d:: with SMTP id l29mr4254ljb.193.1579809498119; Thu, 23 Jan 2020 11:58:18 -0800 (PST) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com. [209.85.208.178]) by smtp.gmail.com with ESMTPSA id a12sm1828308ljk.48.2020.01.23.11.58.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jan 2020 11:58:14 -0800 (PST) Received: by mail-lj1-f178.google.com with SMTP id o11so5058258ljc.6 for ; Thu, 23 Jan 2020 11:58:14 -0800 (PST) X-Received: by 2002:a2e:88c5:: with SMTP id a5mr3682ljk.201.1579809493632; Thu, 23 Jan 2020 11:58:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Thu, 23 Jan 2020 11:57:57 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/7] uaccess: Tell user_access_begin() if it's for a write or not To: christophe leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Alexander Viro , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jani Nikula , Linux Kernel Mailing List , linuxppc-dev , linux-fsdevel , Linux-MM , dri-devel , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 23, 2020 at 11:47 AM christophe leroy wrote: > > I'm going to leave it aside, at least for the time being, and do it as a > second step later after evaluating the real performance impact. I'll > respin tomorrow in that way. Ok, good. From a "narrow the access window type" standpoint it does seem to be a good idea to specify what kind of user accesses will be done, so I don't hate the idea, it's more that I'm not convinced it matters enough. On x86, we have made the rule that user_access_begin/end() can contain _very_ few operations, and objtool really does enforce that. With objtool and KASAN, you really end up with very small ranges of user_access_begin/end(). And since we actually verify it statically on x86-64, I would say that the added benefit of narrowing by access type is fairly small. We're not going to have complicated code in that user access region, at least in generic code. > > Also, it shouldn't be a "is this a write". What if it's a read _and_ a > > write? Only a write? Only a read? > > Indeed that was more: does it includes a write. It's either RO or RW I would expect that most actual users would be RO or WO, so it's a bit odd to have those choices. Of course, often writing ends up requiring read permissions anyway if the architecture has problems with alignment handling or similar, but still... The real RW case does exist conceptually (we have "copy_in_user()", after all), but still feels like it shouldn't be seen as the only _interface_ choice. IOW, an architecture may decide to turn WO into RW because of architecture limitations (or, like x86 and arm, ignore the whole RO/RW/WO _entirely_ because there's just a single "allow user space accesses" flag), but on an interface layer if we add this flag, I really think it should be an explicit "read or write or both". So thus my "let's try to avoid doing it in the first place, but if we _do_ do this, then do it right" plea. Linus