Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4626278ybp; Mon, 7 Oct 2019 11:14:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBWLySOsgEstLE4kbfWX3quW1P1dj7m3u1Gwt1jZXPHNvm80JWi1fRg61aXC3UAtX6yeJ2 X-Received: by 2002:a17:906:4c4c:: with SMTP id d12mr24098601ejw.174.1570472059449; Mon, 07 Oct 2019 11:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570472059; cv=none; d=google.com; s=arc-20160816; b=N9RrcAflg//p6ki2eoSbgDVTntmeTObzD00VTcJCELXBTKzDIrxS2jMTT7K3fOGxBU eDfDNfzadb2PWcCXPtlTgRlJ9HHmlpZ8XQvzIDNcQlmpb3O959KHM2bPy9boK6miLpNG MVr47uwvRgaMuSHGxX94p4D4SFw1AVx8sh9hC40BJGPRObcvV1JNndeNp984YGjdy98L lgXVfySscX2XpCfKHDbGEO0uFLn+tqjolmpfjdYahuVsSe+7Pk9qUNhBLfD0rN/3agRE UtWyIEA4y/iHDE2qcbKem16OZAnvnh0ZWTt+JqFVF8lk/Pr2FYswqe/tD4j/uqI6lmpT qc6g== 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=sSXG+xP1mD1UZGXg2TTq5r4dUsztpjrAAtm+apLCkB0=; b=ZcaQuDr2idU6YZD4XISDEYksIyUrm1AVmpnmB/mpHKq2QhMwCyoyWHRMPsf+v9UXiD 8z4Y5aod8Cjo5yb9p2pUsv+/u7Hf2lVZn7PUnZkr7QcmtbGm6tuJegmuTxvzvGpYOGsP VHWMq8BYI7gS0ubOYmkXBEJrQslZBKsHu802Bm4WUaE67zjcfzC747pvbcrUCkZioXTO yNoJs5laIdYOI19ojv+7CNrpP+tszj8kVxvrXkaLPrWXfPhMtOFvTUH/wZPEyaLuZj/H acO7JRUUvFAMRXaOrc7wH1mCGlJuM1rGQc2vXvpvee+lzFwVhfdzYC3n+HcZUbcBy+FY 2nig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=T9+n4Uy8; 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 i11si7539498eja.317.2019.10.07.11.13.55; Mon, 07 Oct 2019 11:14:19 -0700 (PDT) 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=T9+n4Uy8; 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 S1729275AbfJGSLb (ORCPT + 99 others); Mon, 7 Oct 2019 14:11:31 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39078 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728273AbfJGSLa (ORCPT ); Mon, 7 Oct 2019 14:11:30 -0400 Received: by mail-lj1-f194.google.com with SMTP id y3so14722414ljj.6 for ; Mon, 07 Oct 2019 11:11:27 -0700 (PDT) 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=sSXG+xP1mD1UZGXg2TTq5r4dUsztpjrAAtm+apLCkB0=; b=T9+n4Uy8+vBXnVgYXqxACSICel9I1qrO3WM1rG9o1zxB4y8+nglyP7so9RqnUS9cQ8 DPynUXscIFi1WYKoG9zr1emFzkpLyTp2BRuohwDJ1ouK6+mq/bC+2eV4h1P0P5G2vHiB f45dnjMv5AzSxoSBKOdXSpYYKUfiyQB6mH0fg= 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=sSXG+xP1mD1UZGXg2TTq5r4dUsztpjrAAtm+apLCkB0=; b=BbJ8saDVl2gqL3PkjDFyEa0pU8SB3In/flEXC/HdqZ7QEtRbm+jRi6G/gs2YIywG7x daGZw4cqWgANp8lshJQTBZutXK6vpPjcUbda3X1TWa+r8PrpzCl8ad8h40nA+ebvH8ds LAasM3X3w4X52bfan/IIYDeW/M7YjhrIp3jZdOyzr+OSyDlhKVKzvH1aHW14IZM5pFXI 4yQbe5SR/40NEeht4sLO2CUN7gcKc8tVFtOAo+qNcWtSiHnQxnXAFRLJTVYbqTiEmkMQ QeTUXBMzetH8pVqpvSTsvWdAVb7FQFU/UDIuau7IEfspTBaSu1RTNUN27rovkSf4ycTq 5SWw== X-Gm-Message-State: APjAAAWn15EmBT/MNjoKg3B3loxQ9fMw6OYXZdsO0p262/9iOyTdapWi EXLk8Vhh1FJv7N5XSorNSCily344IBg= X-Received: by 2002:a2e:3806:: with SMTP id f6mr19787879lja.143.1570471886405; Mon, 07 Oct 2019 11:11:26 -0700 (PDT) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id i21sm2802539lfl.44.2019.10.07.11.11.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2019 11:11:25 -0700 (PDT) Received: by mail-lj1-f171.google.com with SMTP id d1so14684795ljl.13 for ; Mon, 07 Oct 2019 11:11:25 -0700 (PDT) X-Received: by 2002:a2e:9556:: with SMTP id t22mr19099733ljh.97.1570471885049; Mon, 07 Oct 2019 11:11:25 -0700 (PDT) MIME-Version: 1.0 References: <20191006222046.GA18027@roeck-us.net> <5f06c138-d59a-d811-c886-9e73ce51924c@roeck-us.net> <20191007012437.GK26530@ZenIV.linux.org.uk> <20191007025046.GL26530@ZenIV.linux.org.uk> In-Reply-To: From: Linus Torvalds Date: Mon, 7 Oct 2019 11:11:09 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Convert filldir[64]() from __put_user() to unsafe_put_user() To: David Laight Cc: Al Viro , Guenter Roeck , Linux Kernel Mailing List , linux-fsdevel 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 Mon, Oct 7, 2019 at 8:40 AM David Laight wrote: > > You don't really want an extra access_ok() for every 'word' of a copy. Yes you do. > Some copies have to be done a word at a time. Completely immaterial. If you can't see the access_ok() close to the __get/put_user(), you have a bug. Plus the access_ok() is cheap. The real cost is the STAC/CLAC. So stop with the access_ok() "optimizations". They are broken garbage. Really. I've been very close to just removing __get_user/__put_user several times, exactly because people do completely the wrong thing with them - not speeding code up, but making it unsafe and buggy. The new "user_access_begin/end()" model is much better, but it also has actual STATIC checking that there are no function calls etc inside th4e region, so it forces you to do the loop properly and tightly, and not the incorrect "I checked the range somewhere else, now I'm doing an unsafe copy". And it actually speeds things up, unlike the access_ok() games. Linus