Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp40305img; Tue, 19 Mar 2019 17:22:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDqaZ5moWU8wgbNTV0rglAu+Zm4cGjZVmXTVwyOhgJQvlE9AtPsRlM6Ku0507Z+lMF80yg X-Received: by 2002:a63:66c1:: with SMTP id a184mr4573770pgc.60.1553041339428; Tue, 19 Mar 2019 17:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553041339; cv=none; d=google.com; s=arc-20160816; b=SGMLghYF30piXBZ43vmnUDOQWgCx2AzTq9IoibX9n6isxvMQNMfACelWsCnqDm2ZZS b/tlOIfzXi93hzf0wmKvQs+q4Os2w30NGOsR6gF/BPbEtkBQ7UKgvAUIjF4aIare7SzP LJPbgSvsCN68Kcv2qQw+9N7orCG6xgFQEXCXmMwL5wEgsQndTpItdNytn50PT/1oEdty /fVWDabP8M/mxVU7BaZDFlQNtG4itG20kNMBtH8tHVieMa4U89kuXHTqZyeS5i9+R5gm tjB6cyM8WlAjC6tv65CSaJISVKLs5cKuqCc+EI1HZ4vYRrf9q1zBBJIubUaI7nE7QNfE wBKA== 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; bh=v2ZLQ79QNXgeJU3MuIahWibb9/y73LMvedva2zDojCU=; b=0pKN7bjFlrPMdrANi14y/4xeLHIhDzOk5W9Ipwc+4HrhsZfrrruUj5+U1RLmGtQ3q/ nm7vR7SniF/yukxFeQSQ4ugrft1kSzgAdwYW3Td3/JayIrH+PZfHDi6AIaQ4F2/UYgxv GCFZs9APLEwRK3x4iA8jnSMdz83uPu4QrZ49WZKHwfhUv+LVB8nIYjXPxWEYeqZaxwaK qgUxJhvoR4XcZIhhLwucr8fVVmOuAxzNZ3kYsIIWDBpLeAAai8/ZWGjROJWhgtx/Bx6j MztzL2CHlLTVbIMZSg4qCCSdYRTyJFWKdH58iYBdn7UyJd8JK90yusPxt4tlXpDLSs85 BJPA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10si236852pgo.404.2019.03.19.17.22.04; Tue, 19 Mar 2019 17:22: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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727536AbfCTAVF (ORCPT + 99 others); Tue, 19 Mar 2019 20:21:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60624 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfCTAVF (ORCPT ); Tue, 19 Mar 2019 20:21:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 337B8811A9; Wed, 20 Mar 2019 00:21:04 +0000 (UTC) Received: from xz-x1 (ovpn-12-94.pek2.redhat.com [10.72.12.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 054F74D9E6; Wed, 20 Mar 2019 00:20:52 +0000 (UTC) Date: Wed, 20 Mar 2019 08:20:43 +0800 From: Peter Xu To: "Dr. David Alan Gilbert" Cc: Andrew Morton , linux-kernel@vger.kernel.org, Paolo Bonzini , Hugh Dickins , Luis Chamberlain , Maxime Coquelin , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , Martin Cracauer , Denis Plotnikov , linux-mm@kvack.org, Marty McFadden , Mike Kravetz , Andrea Arcangeli , Mike Rapoport , Kees Cook , Mel Gorman , "Kirill A . Shutemov" , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 1/1] userfaultfd/sysctl: add vm.unprivileged_userfaultfd Message-ID: <20190320002042.GA8956@xz-x1> References: <20190319030722.12441-1-peterx@redhat.com> <20190319030722.12441-2-peterx@redhat.com> <20190319110236.b6169d6b469a587a852c7e09@linux-foundation.org> <20190319182822.GK2727@work-vm> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190319182822.GK2727@work-vm> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Mar 2019 00:21:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 19, 2019 at 06:28:23PM +0000, Dr. David Alan Gilbert wrote: > * Andrew Morton (akpm@linux-foundation.org) wrote: > > On Tue, 19 Mar 2019 11:07:22 +0800 Peter Xu wrote: > > > > > Add a global sysctl knob "vm.unprivileged_userfaultfd" to control > > > whether userfaultfd is allowed by unprivileged users. When this is > > > set to zero, only privileged users (root user, or users with the > > > CAP_SYS_PTRACE capability) will be able to use the userfaultfd > > > syscalls. > > > > Please send along a full description of why you believe Linux needs > > this feature, for me to add to the changelog. What is the benefit to > > our users? How will it be used? > > > > etcetera. As it was presented I'm seeing no justification for adding > > the patch! > > How about: > > --- > Userfaultfd can be misued to make it easier to exploit existing use-after-free > (and similar) bugs that might otherwise only make a short window > or race condition available. By using userfaultfd to stall a kernel > thread, a malicious program can keep some state, that it wrote, stable > for an extended period, which it can then access using an existing > exploit. While it doesn't cause the exploit itself, and while it's not > the only thing that can stall a kernel thread when accessing a memory location, > it's one of the few that never needs priviledge. > > Add a flag, allowing userfaultfd to be restricted, so that in general > it won't be useable by arbitrary user programs, but in environments that > require userfaultfd it can be turned back on. Thanks for the quick write up, Dave! I definitely should have some justification in the cover letter and carry it until the last version. Sorry to be unclear at the first glance. -- Peter Xu