Linux-Fsdevel Archive on
 help / color / Atom feed
From: Andrea Arcangeli <>
To: Lokesh Gidra <>
Cc: Kees Cook <>,
	Jonathan Corbet <>, Peter Xu <>,
	Sebastian Andrzej Siewior <>,
	Andrew Morton <>,
	Alexander Viro <>,
	Stephen Smalley <>,
	Eric Biggers <>,
	Daniel Colascione <>,
	"Joel Fernandes (Google)" <>,,,,,,,,,,
	Mike Rapoport <>, Shaohua Li <>,
	Jerome Glisse <>,
	Mauro Carvalho Chehab <>,
	Johannes Weiner <>,
	Mel Gorman <>,
	Nitin Gupta <>,
	Vlastimil Babka <>,
	Iurii Zaikin <>,
	Luis Chamberlain <>
Subject: Re: [PATCH v5 2/2] Add user-mode only option to unprivileged_userfaultfd sysctl knob
Date: Fri, 23 Oct 2020 22:48:35 -0400
Message-ID: <> (raw)
In-Reply-To: <>

Hello everyone,

On Sat, Oct 10, 2020 at 11:24:56PM -0700, Lokesh Gidra wrote:
> With this change, when the knob is set to 0, it allows unprivileged
> users to call userfaultfd, like when it is set to 1, but with the
> restriction that page faults from only user-mode can be handled.
> In this mode, an unprivileged user (without SYS_CAP_PTRACE capability)
> must pass UFFD_USER_MODE_ONLY to userfaultd or the API will fail with
> This enables administrators to reduce the likelihood that
> an attacker with access to userfaultfd can delay faulting kernel
> code to widen timing windows for other exploits.
> The default value of this knob is changed to 0. This is required for
> correct functioning of pipe mutex. However, this will fail postcopy
> live migration, which will be unnoticeable to the VM guests. To avoid
> this, set 'vm.userfault = 1' in /sys/sysctl.conf. For more details,
> refer to Andrea's reply [1].
> [1]
> Signed-off-by: Lokesh Gidra <>

Nobody commented so it seems everyone is on board with this change to
synchronize the kernel default with the post-boot Android default.

The email in the link above was pretty long, so the below would be a
summary that could be added to the commit header:


The main reason this change is desirable as in the short term is that
the Android userland will behave as with the sysctl set to zero. So
without this commit, any Linux binary using userfaultfd to manage its
memory would behave differently if run within the Android userland.


Reviewed-by: Andrea Arcangeli <>

BTW, this is still a minor nitpick, but a printk_once of the 1/2 could
be added before the return -EPERM too, that's actually what I meant
when I suggested to add a printk_once :), however the printk_once you
added can turn out to be useful too for devs converting code to use
bounce buffers, so it's fine too, just it could go under DEBUG_VM and
to be ratelimited (similarly to the "FAULT_FLAG_ALLOW_RETRY missing
%x\n" printk).


  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11  6:24 [PATCH v5 0/2] Control over userfaultfd kernel-fault handling Lokesh Gidra
2020-10-11  6:24 ` [PATCH v5 1/2] Add UFFD_USER_MODE_ONLY Lokesh Gidra
2020-10-24  2:08   ` Andrea Arcangeli
2020-10-11  6:24 ` [PATCH v5 2/2] Add user-mode only option to unprivileged_userfaultfd sysctl knob Lokesh Gidra
2020-10-24  2:48   ` Andrea Arcangeli [this message]
2020-10-24  4:08     ` Lokesh Gidra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Fsdevel Archive on

Archives are clonable:
	git clone --mirror linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ \
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone