From patchwork Tue Mar 19 03:07:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10858767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B827C1575 for ; Tue, 19 Mar 2019 03:07:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3D8F294CB for ; Tue, 19 Mar 2019 03:07:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 971A1294D7; Tue, 19 Mar 2019 03:07:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E7A294CB for ; Tue, 19 Mar 2019 03:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbfCSDHh (ORCPT ); Mon, 18 Mar 2019 23:07:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36896 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726639AbfCSDHh (ORCPT ); Mon, 18 Mar 2019 23:07:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0353A308425C; Tue, 19 Mar 2019 03:07:36 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85F6A5D707; Tue, 19 Mar 2019 03:07:23 +0000 (UTC) From: Peter Xu To: linux-kernel@vger.kernel.org Cc: Paolo Bonzini , Hugh Dickins , Luis Chamberlain , Maxime Coquelin , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , peterx@redhat.com, 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, "Dr . David Alan Gilbert" , Andrew Morton Subject: [PATCH v2 0/1] userfaultfd: allow to forbid unprivileged users Date: Tue, 19 Mar 2019 11:07:21 +0800 Message-Id: <20190319030722.12441-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 19 Mar 2019 03:07:36 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, This is the second version of the work. V1 was here: https://lkml.org/lkml/2019/3/11/207 I removed CC to kvm list since not necessary any more, but added linux-api to the list as suggested by Kirill. This one greatly simplifies the previous version, dropped the kvm special entry and mimic the sysctl_unprivileged_bpf_disabled knob for userfaultfd as suggested by many. The major differences comparing to the BPF flag are: (1) use PTRACE instead of ADMIN capability, and (2) allow to switch the flag back and forth (BPF does not allow to switch back to "enabled" if "disabled" once). So the main idea of this simpler version is that we still keep the old way as is by default but we only provide a way for admins when they really want to turn userfaultfd off for unprivileged users. About procfs vs sysfs: I still used the procfs way because admins can still leverage sysctl.conf with that and also since no one yet explicitly asked for sysfs for a better reason yet (And I just noticed BPF just added another bpf_stats_enabled into sysctl a few weeks ago). Please have a look, thanks. Peter Xu (1): userfaultfd/sysctl: add vm.unprivileged_userfaultfd Documentation/sysctl/vm.txt | 12 ++++++++++++ fs/userfaultfd.c | 5 +++++ include/linux/userfaultfd_k.h | 2 ++ kernel/sysctl.c | 12 ++++++++++++ 4 files changed, 31 insertions(+)