Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5004190imm; Mon, 14 May 2018 17:42:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLC4ZZDJ0gq6wurEMMegJUemOY30J22JtKTiDRYTzfdqWL19Jl6hsMt3FpHgqYZN03W8bY X-Received: by 2002:a17:902:3103:: with SMTP id w3-v6mr11290400plb.37.1526344939235; Mon, 14 May 2018 17:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526344939; cv=none; d=google.com; s=arc-20160816; b=vINrRnGlvRz8IYPhzl2qY8p8CFoJZo9Ugg9jGQBxIU85/6IOAu8fpFF7v/tvWBALGz ca2v9mqMeEYy4wNdIwl2WFG+zgHrXRxtL7odLVcmg1lZjzE1tuSIo/qpZWNyVlzOuXBA N4GTsxu0euD/cJZfM4uQ9A+lIaGMMg5SfswXXtPU04YLuX73heKahNi8/N9Oz7mnP6KI OLtLjDN524QZJofp92Sek5m7E+NjSDFyZl41QOBy5suWNjcLJtb0Rvu14BYiEuwnmnkO 5rZoAjHrO/DX+vDyjxfkVLm9HfkJ9tMx6Qc0t/Qi64Y2Y5UBZDlWVuywIQVRgRZvLAVo PQaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=vTWTa7BPC9078VhRLWgM/sL+XqPsk5BPsAz6R7HnfwE=; b=MbKq88TlwVz3V2F8pDgI1czbB1GTcYZ9MzNpj/p48sIvH+pogGD9APLRqwW9G5grk7 PEK70t6XfdMTVDTSPfdxG84hfWVWDyC7LyWMq1iJSINSFYY2W45oQLhSO6HQqWyEWUmG RqMDM/Mn4HXmkW+nxTq4uMj5AwqG/H82q/Ab7IHORR7kCmYU5yqBRniZfa3D6EdJvLjn uymTNB7WEpoLtbBO3cIXZygJ0TZwq9v9qA6Ek1sF+ymH2N9AL9ca+VZqQ4uWhJAW7/Zo /uUTnbpRpJSEwXuMrKw4V9YqZsQfO5lge29diWlaQJ8ifaWrx/q+8IGYJkX1zYhfYal8 Jd3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VbuXGt7l; 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 z80-v6si10847886pfi.7.2018.05.14.17.42.03; Mon, 14 May 2018 17:42: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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VbuXGt7l; 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 S1752482AbeEOAlo (ORCPT + 99 others); Mon, 14 May 2018 20:41:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45436 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752372AbeEOAll (ORCPT ); Mon, 14 May 2018 20:41:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vTWTa7BPC9078VhRLWgM/sL+XqPsk5BPsAz6R7HnfwE=; b=VbuXGt7lcAO/EEtFMtCrmNGwn MMxrdZJykCaFr8+w6t5usWlBW9pfM28RDLMM0aVwZhg7yXhvd8gkjpWi81VM/NA+MpMR5EqDi7a5O KeVBJ2w19jVSlnJgTstkiymC8fG3fCqEDAVPYGJtoAPUESHkht6m5CPC8gfbEF0Me/fYgyFGKA3zx iK2t4yBNcNUi76i/hJuD2PvSbsSl30ZZ21KFe3s72jDb1CV2vq24GJ+pbidH9YQ2XhPrnmhUOl+YD 8+aiSk+QK9pEaJ120cAzFTo/nslyyMJgNguU+3AfynzrphWQhycv2kxZ9M/XtMr1AQDHP+L+OCVdU shIQSfppg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIO26-0003jA-1p; Tue, 15 May 2018 00:41:38 +0000 Date: Mon, 14 May 2018 17:41:37 -0700 From: Matthew Wilcox To: Boaz Harrosh Cc: Jeff Moyer , Andrew Morton , "Kirill A. Shutemov" , linux-kernel , linux-fsdevel , "linux-mm@kvack.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Dave Hansen , Rik van Riel , Jan Kara , Matthew Wilcox , Amit Golander Subject: Re: [PATCH] mm: Add new vma flag VM_LOCAL_CPU Message-ID: <20180515004137.GA5168@bombadil.infradead.org> References: <0efb5547-9250-6b6c-fe8e-cf4f44aaa5eb@netapp.com> <20180514191551.GA27939@bombadil.infradead.org> <7ec6fa37-8529-183d-d467-df3642bcbfd2@netapp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ec6fa37-8529-183d-d467-df3642bcbfd2@netapp.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 10:37:38PM +0300, Boaz Harrosh wrote: > On 14/05/18 22:15, Matthew Wilcox wrote: > > On Mon, May 14, 2018 at 08:28:01PM +0300, Boaz Harrosh wrote: > >> On a call to mmap an mmap provider (like an FS) can put > >> this flag on vma->vm_flags. > >> > >> The VM_LOCAL_CPU flag tells the Kernel that the vma will be used > >> from a single-core only, and therefore invalidation (flush_tlb) of > >> PTE(s) need not be a wide CPU scheduling. > > > > I still don't get this. You're opening the kernel up to being exploited > > by any application which can persuade it to set this flag on a VMA. > > > > No No this is not an application accessible flag this can only be set > by the mmap implementor at ->mmap() time (Say same as VM_VM_MIXEDMAP). > > Please see the zuf patches for usage (Again apologise for pushing before > a user) > > The mmap provider has all the facilities to know that this can not be > abused, not even by a trusted Server. I don't think page tables work the way you think they work. + err = vm_insert_pfn_prot(zt->vma, zt_addr, pfn, prot); That doesn't just insert it into the local CPU's page table. Any CPU which directly accesses or even prefetches that address will also get the translation into its cache.