Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1614193img; Tue, 19 Mar 2019 11:29:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwb7+rsz8vE/TM3bEMFfOCbJhHfTp8s3GAjJjcMocEWXvn0a56GvJrD5HP5mFVHep8rdOLQ X-Received: by 2002:a63:124c:: with SMTP id 12mr3050904pgs.86.1553020179481; Tue, 19 Mar 2019 11:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553020179; cv=none; d=google.com; s=arc-20160816; b=IwaYtzWLgsldtMw6lo16dSCQWW3fdYwphMCxWuA5siph3g2tWjlYgw/z/u0s1er/KR 0pl7ybfwf0WYm1UQkfMixQF+K4jKj7H9s7ThhO51Ytrc/KUkOemlJNb1Y0/LFtPvku+I z1jlCy/I6BAxb1tpWgbSA7VIzDYD+RCjrm9VluceNltJH72wTNoUky36jsKt8AXSdtjl RhfMrDSujkwJXE3xswUnoKQpxVfKALJh4Gf8eEfpy2b9NjSjecozzRJCXMrZHMcrRg6F IyWwyxHgYa5/UV/8omoN67I7wbj0pDZf/uLZ/+T6BVewOWt3tjQb9KJrmPtPkROvcQhZ EcXg== 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=30apmnEQmfNZjkyK96GSJdVik20/1QA65Tr6Etwrt5A=; b=vbEQ601Ci+zG7ZDwiTPDicuuoS4OBnLnIynUEOK8KF+hQUjHjg0ZLkXxqb4VRTnie2 O5L2yqzdOkHZMEzZPuQyMxeZUxmU0cW0yhKC3VGIvfupqzTzu70edlPPNXtPt1Txndzl amgaBKcmJnYO3YdIRAlnzxgUykEd4NUyCw4ll9eU/cNwHqj1MNxDvRA/NGqHGL9JPfSj YY0gT7e87WsgiAZnBWNjYvpE4zhO5JUYW3/yIre/VSPwxZQxrl9Zj+TcixnSUIxwGetK ZrelyH/kB3t+C7oU7+6+gvJo9zl6AzzD1z8X6T3PR3PFQrZoSA/OUg4xLLrbJf4C0NHE TxSw== 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 z1si12413318pln.21.2019.03.19.11.29.23; Tue, 19 Mar 2019 11:29:39 -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 S1727267AbfCSS2o (ORCPT + 99 others); Tue, 19 Mar 2019 14:28:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50498 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbfCSS2o (ORCPT ); Tue, 19 Mar 2019 14:28:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11AFA81F31; Tue, 19 Mar 2019 18:28:43 +0000 (UTC) Received: from work-vm (ovpn-117-168.ams2.redhat.com [10.36.117.168]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1867F611CD; Tue, 19 Mar 2019 18:28:25 +0000 (UTC) Date: Tue, 19 Mar 2019 18:28:23 +0000 From: "Dr. David Alan Gilbert" To: Andrew Morton Cc: Peter Xu , 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: <20190319182822.GK2727@work-vm> References: <20190319030722.12441-1-peterx@redhat.com> <20190319030722.12441-2-peterx@redhat.com> <20190319110236.b6169d6b469a587a852c7e09@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190319110236.b6169d6b469a587a852c7e09@linux-foundation.org> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Mar 2019 18:28:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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. --- Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK