Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2314891imd; Fri, 2 Nov 2018 09:17:11 -0700 (PDT) X-Google-Smtp-Source: AJdET5cuTPrLsDpN2VbiuZkO7bnNC0Yxtl8B5ThwtJtsFv3lqylkl5mBwjU2n0sobHrj2QFcI1Wy X-Received: by 2002:a17:902:6801:: with SMTP id h1-v6mr12200719plk.177.1541175431262; Fri, 02 Nov 2018 09:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541175431; cv=none; d=google.com; s=arc-20160816; b=IoyUHxVesvump5ggPpcQouR9KFFvDY4pyyzCzla5vpvjh8R7VvvSgFSHm8OiuuDBfU E+e6+w/Vs+cwggiURGaKSlFT24iOHX0agmOD1YlsrGJeLoHAgSO6De6Jdmgs7atvy17p 6MCAHk2s1bc1SGqcYdnZ5Tw4YFGEZt3MULYCU6vyfTPNyJ4zb9BQC4HczA2L+m6EtBlq BEfhRDOxWqEDZ11rOfXTlJS7XS/lL3wtoGP2Bq6fbhvjHsqmsGSKYONYjh6x9cdIE6pN DYlYlr2t6hkyOhqzxhd25kfw6kedBmj4i7RZ6v+8xOWnAfe0f6avIJKpzb+wopCFzMtL is9Q== 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=T1ZLS/k8UCAenrnOpeIYJTMeU7f68faZYEvIFC7BSwo=; b=J5vgGA1ZzoRoa7ps/K4h7wQFbeRLhyPEH2QqHqrpKbuB4cnvtLL9nU+xzDoz4c3vDZ VVL3NleAzyUj6j5BGAuHr/CbkjFtstwGoRXQFWEOpeyjNXroCUyoPiGvUybbivl+H6J5 6uW2XcIMlajTBgPg5+5+EszkBtpJ4j22D8sbo3mOqZh7ljf6KTDVO6HadYm61uqS47hU GhoRN8/XHlS/5CxlyZ5oAoolRQDZ9b06AG+VnzIltWWJIV/KigvvCSEO/V/ICCFZZhev EtcX+8LfODDbIbmMxJNx5FpB6d8FaYAsQReJG/vuzYGQYoKlar4/Ix+s+djqWCCQiurw JvPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RqKqgkFr; 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 l12-v6si7554407pff.126.2018.11.02.09.16.56; Fri, 02 Nov 2018 09:17:11 -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=RqKqgkFr; 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 S1728030AbeKCBWt (ORCPT + 99 others); Fri, 2 Nov 2018 21:22:49 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42021 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbeKCBWt (ORCPT ); Fri, 2 Nov 2018 21:22:49 -0400 Received: by mail-lf1-f65.google.com with SMTP id q6-v6so1698259lfh.9 for ; Fri, 02 Nov 2018 09:15:10 -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=T1ZLS/k8UCAenrnOpeIYJTMeU7f68faZYEvIFC7BSwo=; b=RqKqgkFrR/SMxTNgjp+V8lFISbp1vMagYZELURKydXYnkMFjr8gBNJ+J710DMCYIpV qTYFPTYrO04WFZJf7tfx7gy7P2xxp6aVqQw2zqC5R/2tOF0RmUu5QO1AjfeCJIWAArbm BUkhkJq4RwhODpybfQm6oC81+QN798t/HOdI0= 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=T1ZLS/k8UCAenrnOpeIYJTMeU7f68faZYEvIFC7BSwo=; b=cmF4fmjnGhtwvf6uocxYMuTolSbt2vut/HgGcTeNJfzHFwaVT6Ccu6oeJtJLfk801a EiIOnWbPkpHs6niWy1aEk2cm86+df9wngOCfoCr72FL6MLEw/1ptg5VJtvEvaIDjR03Z 9AgT9N7fZD5Bl/JAPC8834OOvIAixN7UA48BabVICGIbepaw6+E8hpT+E95ifDUC5a6+ 1eSVB/BO2wFwevhkMO9/xnbs0VWBf+QrH2t0uJrIXNZt7XAH75cUmovj3eccmsJapbNE IlIe29TR9BbghBu8/Td+SXY0Vz9jK41TpJLhp3npG2vsGcfDhwzD5TGgsHDi8vhthQ1Q wgRQ== X-Gm-Message-State: AGRZ1gI/ebqWfsrxCMykcW5us3z4Pg2QmSIskKlNi7QYM5n+F5XMcEJm A8+1aYhjYD7rLU8yk9ev+tn7lPnBKEGVZw== X-Received: by 2002:a19:2a4b:: with SMTP id f72mr6798663lfl.139.1541175309350; Fri, 02 Nov 2018 09:15:09 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id c5-v6sm2048439lja.62.2018.11.02.09.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 09:15:08 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id c16so1694733lfj.8 for ; Fri, 02 Nov 2018 09:15:08 -0700 (PDT) X-Received: by 2002:a19:982:: with SMTP id 124mr1660875lfj.138.1541175307489; Fri, 02 Nov 2018 09:15:07 -0700 (PDT) MIME-Version: 1.0 References: <20181101171938-mutt-send-email-mst@kernel.org> <20181102114635.hi3q53kzmz4qljsf@lakrids.cambridge.arm.com> <20181102083018-mutt-send-email-mst@kernel.org> In-Reply-To: <20181102083018-mutt-send-email-mst@kernel.org> From: Linus Torvalds Date: Fri, 2 Nov 2018 09:14:51 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PULL] vhost: cleanups and fixes To: mst@redhat.com Cc: mark.rutland@arm.com, Kees Cook , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Linux Kernel Mailing List , Andrew Morton , bijan.mottahedeh@oracle.com, gedwards@ddn.com, joe@perches.com, lenaic@lhuard.fr, liang.z.li@intel.com, mhocko@kernel.org, mhocko@suse.com, stefanha@redhat.com, wei.w.wang@intel.com 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 Fri, Nov 2, 2018 at 6:04 AM Michael S. Tsirkin wrote: > > I've tried making access_ok mask the parameter it gets. PLEASE don't do this. Just use "copy_to/from_user()". We have had lots of bugs because code bitrots. And no, the access_ok() checks aren't expensive, not even in a loop. They *used* to be somewhat expensive compared to the access, but that simply isn't true any more. The real expense in copy_to_user and friends are in the user access bit setting (STAC and CLAC on x86), which easily an order of magnitude more expensive than access_ok(). So just get rid of the double-underscore version. It's basically always a mis-optimization due to entirely historical reasons. I can pretty much guarantee that it's not visible in profiles. Linus