From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BAE2C433E9 for ; Tue, 26 Jan 2021 18:15:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31AA82311F for ; Tue, 26 Jan 2021 18:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394355AbhAZSPd (ORCPT ); Tue, 26 Jan 2021 13:15:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391407AbhAZRvC (ORCPT ); Tue, 26 Jan 2021 12:51:02 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CDDCC061574 for ; Tue, 26 Jan 2021 09:50:21 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id d22so20843425edy.1 for ; Tue, 26 Jan 2021 09:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YDZ9xoM4vkjgG3VDn83cus2ZyU7tS/ImHr1EbR40OHE=; b=iC68VBpaq64YNVQ0gyie62K2q0gqKG2wunAeMFJligWQ54mFY6PLhbrOxMmB1Snsrn 0iShrefSXyHlxlN+8Q01JLqZUHgUdC4dPm083RP/P3G/HjqXJvx5QaNoLA+/CSe5uglG oCWZXKNRQA8x+9nVwamn+mDCLqUFyKlzOV+3EpXHa8AaC5IVSJx910YSC18RZPWc81FJ ltKjl4opEIguMtRBiMwBDki887zMS5XWqqiJz+57O7hld88oTYnoGPI1DqSPOACvYHV6 26MiLHaOJpXDLenM4lVZhCqcgeWByzzXB8oi3MdeA4rODu556+k1D2I+NKeM2iME7D/w wH+g== 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=YDZ9xoM4vkjgG3VDn83cus2ZyU7tS/ImHr1EbR40OHE=; b=oY82VX5J/F/Cnz/2Az/i9CFolrfWUthKDNbNPtrSbPdXcOENyCN5/bBu1/zgD8YP/g vKluh68cA+SRuYgOvRbxsYShbTMv3qgBq7ZeW/2uxYtWLYyV0G8fHZ3RW7j8alXu6jgX iaeBCqfvE+mrXYTf0Sq4fMq5ytblqu19JDcJRcLUWEvGa3/6mm3C7KaeNps7WUoo+QO9 6T62gHN5WpqezvSJz0MuxiJeae8j5d+PB2w+FkDtA2PEGLza+Rb/ulu2JveXcLXFrAif NXp27jefi71CbmrrH8WW2enB9iPY1UNVOehLs5t2j3rP3pw+jNiauQXwX+IJjX8D/zDo GJBA== X-Gm-Message-State: AOAM530zD2YNMrNbGQ/DKQbKFgql6J5IBX7pvrXUXGabWDhLz42B1cIb IDO5roBvURViMoWlpBox8q/O/2/u9g81hnm85FUYmQ== X-Google-Smtp-Source: ABdhPJx3Yv1kBkYCpT7b1VeYY0tK4Gs4XrFwiszGuqBHo9jL/4XtOW+Fht+NXcjZCRLEkjSwZDjZJ0Ui6hVhT9ALTl8= X-Received: by 2002:aa7:d4c8:: with SMTP id t8mr5784370edr.199.1611683419835; Tue, 26 Jan 2021 09:50:19 -0800 (PST) MIME-Version: 1.0 References: <20210126014450.1901335-1-lokeshgidra@google.com> In-Reply-To: <20210126014450.1901335-1-lokeshgidra@google.com> From: Lokesh Gidra Date: Tue, 26 Jan 2021 09:50:08 -0800 Message-ID: Subject: Re: [PATCH v1] userfaultfd.2: Add UFFD_USER_MODE_ONLY flag To: linux-man@vger.kernel.org Cc: Daniel Colascione , linux-kernel , Kalesh Singh , Calin Juravle , Suren Baghdasaryan , Jeffrey Vander Stoep , "Cc: Android Kernel" , Peter Xu , Andrea Arcangeli , Andrew Morton , "open list:MEMORY MANAGEMENT" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 5:44 PM Lokesh Gidra wrote: > > Add description of UFFD_USER_MODE_ONLY flag to userfaultfd(2) manual > page, which is required after [1]. Also updated the description of > unprivileged_userfaultfd file in proc(5) as per [2]. > > [1] https://lore.kernel.org/linux-mm/20201215031349.NXimL388W%25akpm@linux-foundation.org/ > [2] https://lore.kernel.org/linux-mm/20201215031354.gUsHJUpKo%25akpm@linux-foundation.org/ > > Signed-off-by: Lokesh Gidra > --- > man2/userfaultfd.2 | 5 +++++ > man5/proc.5 | 12 ++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 > index e7dc9f813..792a49d52 100644 > --- a/man2/userfaultfd.2 > +++ b/man2/userfaultfd.2 > @@ -72,6 +72,11 @@ See the description of the > .BR O_NONBLOCK > flag in > .BR open (2). > +.TP > +.BR UFFD_USER_MODE_ONLY " (Since Linux 5.11)" > +Allow handling of user-mode page-faults only. See the description of the > +unprivileged_userfaultfd file in > +.BR proc (5). > .PP > When the last file descriptor referring to a userfaultfd object is closed, > all memory ranges that were registered with the object are unregistered > diff --git a/man5/proc.5 b/man5/proc.5 > index f16a29d6e..cb2350c0c 100644 > --- a/man5/proc.5 > +++ b/man5/proc.5 > @@ -5905,6 +5905,18 @@ If this file has the value 0, then only processes that have the > capability may employ > .BR userfaultfd (2). > The default value in this file is 1. > +.IP > +Starting with Linux 5.11, > +.BR userfaultfd (2) > +can be used by all processes, however, if this file has the value 0, then > +.BR UFFD_USER_MODE_ONLY > +flag must be passed to it, which restricts page-fault handling to only > +user-mode faults. This restriction is not applicable for processes with > +.B CAP_SYS_PTRACE > +capability, or if this file has the value 1. Furthermore, the default > +value in this file is changed to 0. For further details see the > +Linux kernel source file > +.I Documentation/admin\-guide/sysctl/vm.rst. > .TP > .IR /proc/sysrq\-trigger " (since Linux 2.4.21)" > Writing a character to this file triggers the same SysRq function as > -- Adding the right linux-mm mailing list. Mistakenly used linux-mm@kvack.kernel.org earlier. > 2.30.0.280.ga3ce27912f-goog > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B1EDC433DB for ; Tue, 26 Jan 2021 17:50:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ED67F22472 for ; Tue, 26 Jan 2021 17:50:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED67F22472 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5444C8D00FB; Tue, 26 Jan 2021 12:50:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 518898D00F8; Tue, 26 Jan 2021 12:50:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4077D8D00FB; Tue, 26 Jan 2021 12:50:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 2B1F18D00F8 for ; Tue, 26 Jan 2021 12:50:22 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DA17E180AD82F for ; Tue, 26 Jan 2021 17:50:21 +0000 (UTC) X-FDA: 77748665442.14.van23_49149e427590 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id BB7011822987A for ; Tue, 26 Jan 2021 17:50:21 +0000 (UTC) X-HE-Tag: van23_49149e427590 X-Filterd-Recvd-Size: 5345 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Jan 2021 17:50:21 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id a14so9505465edu.7 for ; Tue, 26 Jan 2021 09:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YDZ9xoM4vkjgG3VDn83cus2ZyU7tS/ImHr1EbR40OHE=; b=iC68VBpaq64YNVQ0gyie62K2q0gqKG2wunAeMFJligWQ54mFY6PLhbrOxMmB1Snsrn 0iShrefSXyHlxlN+8Q01JLqZUHgUdC4dPm083RP/P3G/HjqXJvx5QaNoLA+/CSe5uglG oCWZXKNRQA8x+9nVwamn+mDCLqUFyKlzOV+3EpXHa8AaC5IVSJx910YSC18RZPWc81FJ ltKjl4opEIguMtRBiMwBDki887zMS5XWqqiJz+57O7hld88oTYnoGPI1DqSPOACvYHV6 26MiLHaOJpXDLenM4lVZhCqcgeWByzzXB8oi3MdeA4rODu556+k1D2I+NKeM2iME7D/w wH+g== 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=YDZ9xoM4vkjgG3VDn83cus2ZyU7tS/ImHr1EbR40OHE=; b=pnrcfk2UMq0Q8IOViBtpdGmzw8LJWDoehzcjRscTqBSo+CWeO2pD3Ra7utZ/1bSGxp 4y0iv29QRMELuNZGOqAfCTsvoGTBPDnAXieWRc0w7s+rdaV/VoDIVhDsEM+29AUeogF5 NvrXNck+xHazU5CpBgD5xA/VejkUxAsLDe2WwvXq+SfxR/lbttovgPd5wWkhISESTTKa 2qARQd62XOJROKA7IZ0BkjuZWtthrMNhU68rDcCadBO8+Zf95osBe5BauGIzo6BRfKes kpnW9ELI0FRwVnrjJsSTAFq5OjuqUDxK5PIwsGokBgBl836itDwgI6MTtFUAX2enwGdc HK5g== X-Gm-Message-State: AOAM532hyWd0bJq+VC9ZRR/BojFTnOF5RJGutMqzFAXwUjwHz/OZ8MHi s6Zv8mAa02+1phWk+zEhgQiNLdTuG8xI0qTq+g106g== X-Google-Smtp-Source: ABdhPJx3Yv1kBkYCpT7b1VeYY0tK4Gs4XrFwiszGuqBHo9jL/4XtOW+Fht+NXcjZCRLEkjSwZDjZJ0Ui6hVhT9ALTl8= X-Received: by 2002:aa7:d4c8:: with SMTP id t8mr5784370edr.199.1611683419835; Tue, 26 Jan 2021 09:50:19 -0800 (PST) MIME-Version: 1.0 References: <20210126014450.1901335-1-lokeshgidra@google.com> In-Reply-To: <20210126014450.1901335-1-lokeshgidra@google.com> From: Lokesh Gidra Date: Tue, 26 Jan 2021 09:50:08 -0800 Message-ID: Subject: Re: [PATCH v1] userfaultfd.2: Add UFFD_USER_MODE_ONLY flag To: linux-man@vger.kernel.org Cc: Daniel Colascione , linux-kernel , Kalesh Singh , Calin Juravle , Suren Baghdasaryan , Jeffrey Vander Stoep , "Cc: Android Kernel" , Peter Xu , Andrea Arcangeli , Andrew Morton , "open list:MEMORY MANAGEMENT" Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jan 25, 2021 at 5:44 PM Lokesh Gidra wrote: > > Add description of UFFD_USER_MODE_ONLY flag to userfaultfd(2) manual > page, which is required after [1]. Also updated the description of > unprivileged_userfaultfd file in proc(5) as per [2]. > > [1] https://lore.kernel.org/linux-mm/20201215031349.NXimL388W%25akpm@linux-foundation.org/ > [2] https://lore.kernel.org/linux-mm/20201215031354.gUsHJUpKo%25akpm@linux-foundation.org/ > > Signed-off-by: Lokesh Gidra > --- > man2/userfaultfd.2 | 5 +++++ > man5/proc.5 | 12 ++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 > index e7dc9f813..792a49d52 100644 > --- a/man2/userfaultfd.2 > +++ b/man2/userfaultfd.2 > @@ -72,6 +72,11 @@ See the description of the > .BR O_NONBLOCK > flag in > .BR open (2). > +.TP > +.BR UFFD_USER_MODE_ONLY " (Since Linux 5.11)" > +Allow handling of user-mode page-faults only. See the description of the > +unprivileged_userfaultfd file in > +.BR proc (5). > .PP > When the last file descriptor referring to a userfaultfd object is closed, > all memory ranges that were registered with the object are unregistered > diff --git a/man5/proc.5 b/man5/proc.5 > index f16a29d6e..cb2350c0c 100644 > --- a/man5/proc.5 > +++ b/man5/proc.5 > @@ -5905,6 +5905,18 @@ If this file has the value 0, then only processes that have the > capability may employ > .BR userfaultfd (2). > The default value in this file is 1. > +.IP > +Starting with Linux 5.11, > +.BR userfaultfd (2) > +can be used by all processes, however, if this file has the value 0, then > +.BR UFFD_USER_MODE_ONLY > +flag must be passed to it, which restricts page-fault handling to only > +user-mode faults. This restriction is not applicable for processes with > +.B CAP_SYS_PTRACE > +capability, or if this file has the value 1. Furthermore, the default > +value in this file is changed to 0. For further details see the > +Linux kernel source file > +.I Documentation/admin\-guide/sysctl/vm.rst. > .TP > .IR /proc/sysrq\-trigger " (since Linux 2.4.21)" > Writing a character to this file triggers the same SysRq function as > -- Adding the right linux-mm mailing list. Mistakenly used linux-mm@kvack.kernel.org earlier. > 2.30.0.280.ga3ce27912f-goog >