From nobody Sat Apr 18 01:21:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0405FC433EF for ; Tue, 19 Jul 2022 19:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239569AbiGST4o (ORCPT ); Tue, 19 Jul 2022 15:56:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239035AbiGST4h (ORCPT ); Tue, 19 Jul 2022 15:56:37 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFC95A176 for ; Tue, 19 Jul 2022 12:56:35 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-31c9a49a1a8so126140237b3.9 for ; Tue, 19 Jul 2022 12:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=2lmji2pJwQUUP3R6t1yXuXRPrPh1yDx0i1mGLg8CxXk=; b=rRPjfzCfRNd5lQiZ67VG1PsIVIYjPwFy08N1NgXwZEdmOj6JA+coqAzVWkDJIlNRY5 YYf3Y/bM+zhmKkRWAsQ2bjiJrwYdl3VnbCcCZGMRHF6ew7w4EywM1I3/QseVs1Mn1HXX tpRbi7PWHIGlDIpJweXOzNMEFyij2g2rnpJrMrBPd0i5ICMUSiInyP+w3GQ4/Jk2pCQB aC/ZpgWXZ+1KmqHJq0wUclsGmDY8ho2QpLzY95UOiGq0A0G8UHc0v+qIJPIQ9/n6efPf iewCSIjs66UnweZpc/EznMh9zB+4mPI7OoyNXC/osApBENIUmF4qtOi2XbW2DpSB5wMJ zUIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2lmji2pJwQUUP3R6t1yXuXRPrPh1yDx0i1mGLg8CxXk=; b=ma7mkg/1WRiRoiM02tkZzbyEMP8jlahFO5by4bvCg5XLpekJIQ9A6YXsUOcy8t0h4N Re8SdLvtMvjQHipW5Qtg0JX5diTqmDZgAt3ilRcBdUFq4eoSuM4dVcltL111Sun9+WB2 4UnyfX8JDVjLjLyFoDk+a9qcuLv9KLyN785PaigwgeKgu5L3zYB+J74HrZWiUwz4d2Sq 302COJp1FQLB9wiK4btVRa5Mpb2ZVNNtLNDLmPB11Ojo7Nwe/OlRcSsbHppMI4gmYMWc 4lFQOWjQfNh0act0k2Mhlx7K0NVqs6j+E66H15LwSNCtkjaoqOKKmGUPdenmcinrrvjh jTvw== X-Gm-Message-State: AJIora9G83csn5D0zlkhcEaaZ7FcG5wVKyip+5PyXeyAr7SqCsYVzvFP CZSW+jR1AYv7GlMSQpBBtPvMDFkWLzxIJG49aiN6 X-Google-Smtp-Source: AGRyM1uCcb2pDVTpDDsVUiZd0J0+WEjtbbgh4jqcG3bGfivbKRKkUwVy3Wnb/o8tyjKhhIKWZ30sg4m4oT0+s0fm0h3m X-Received: from ajr0.svl.corp.google.com ([2620:15c:2d4:203:a065:9221:e40d:4fbe]) (user=axelrasmussen job=sendgmr) by 2002:a25:7c41:0:b0:670:7de8:1d4b with SMTP id x62-20020a257c41000000b006707de81d4bmr5955132ybc.488.1658260595015; Tue, 19 Jul 2022 12:56:35 -0700 (PDT) Date: Tue, 19 Jul 2022 12:56:24 -0700 In-Reply-To: <20220719195628.3415852-1-axelrasmussen@google.com> Message-Id: <20220719195628.3415852-2-axelrasmussen@google.com> Mime-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 1/5] selftests: vm: add hugetlb_shared userfaultfd test to run_vmtests.sh From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi Cc: Axel Rasmussen , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Shuah Khan Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This not being included was just a simple oversight. There are certain features (like minor fault support) which are only enabled on shared mappings, so without including hugetlb_shared we actually lose a significant amount of test coverage. Reviewed-by: Shuah Khan Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/run_vmtests.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/self= tests/vm/run_vmtests.sh index 41fce8bea929..e70ae0f3aaf6 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -121,9 +121,11 @@ run_test ./gup_test -a run_test ./gup_test -ct -F 0x1 0 19 0x1000 =20 run_test ./userfaultfd anon 20 16 -# Test requires source and destination huge pages. Size of source -# (half_ufd_size_MB) is passed as argument to test. +# Hugetlb tests require source and destination huge pages. Pass in half the +# size ($half_ufd_size_MB), which is used for *each*. run_test ./userfaultfd hugetlb "$half_ufd_size_MB" 32 +run_test ./userfaultfd hugetlb_shared "$half_ufd_size_MB" 32 "$mnt"/uffd-t= est +rm -f "$mnt"/uffd-test run_test ./userfaultfd shmem 20 16 =20 #cleanup --=20 2.37.0.170.g444d1eabd0-goog From nobody Sat Apr 18 01:21:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67FF8CCA483 for ; Tue, 19 Jul 2022 19:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239814AbiGST45 (ORCPT ); Tue, 19 Jul 2022 15:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239325AbiGST4k (ORCPT ); Tue, 19 Jul 2022 15:56:40 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7322F5A47B for ; Tue, 19 Jul 2022 12:56:38 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id n192-20020a2540c9000000b0066fca45513eso11448269yba.0 for ; Tue, 19 Jul 2022 12:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qMVUvtohpl5u0YhYXflPGUyFWvhgp3J9BbhXpFzblMU=; b=lnfO9vGuCg2XCgU/FaH826cH1zjvOw9G/iNyzi1HOhL3DxRT5bJcHvrfvhI4t6URAW ZP8ma2CBwGO2AVLagAv1r0AO895+URwxT6XMHfplaCjyUO6lJkILUzedOiepPxy4Eahr EhH0JgOK+S8z069u+yUEl/l3mZrtwpKQA9Xw28TuBzAjavO2bWFh8TRuv1X2CVR90KpU qPBKThQYdZup0H8ibLQRBekD27EueLVSQBgOG0oQLbT0STjwrqunbK5D9oWZXtUEf2be s1WMV4AYiUbOkEVKGSa0BPiWU1Jl6E6ZbPremSWY888QlqwUWVrZ7Do8xcodXxNg2E9I fJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qMVUvtohpl5u0YhYXflPGUyFWvhgp3J9BbhXpFzblMU=; b=5IVZuDcFkj0L3um40asjs2jw4oTk8t53//p0i1IEe1nHv+Ic/REOpZJiAWlKtfuE9x 0yxQB+3kwb2FbIEIM+1m4Y1lRVd625QuI8I/DE3aR5g6sJG//qKgw8SvHxyXTza/9Ung IEGtvjcBcEeGfN6BeVdWx4s49Woo//XjhjPk8KYvnVU9NESgVmRF43E92K5KV5tvIz0L KayzVBH8VNlMuVA1xN330uUnVGNf/WHFMtN3Qzlra+NTHRlec4bZuHR6Fg8g7iFOSBBc xuWsrGtPV2nJBvtm7x9vyPA1NTL+bn31acx5FU5S7K/+YN4LIgYnp13bXKAcq/GOlfUN we1w== X-Gm-Message-State: AJIora+ZwAom0BINx4dDnTIGLomkNSyUBtrjqYP6IhcIpodHVCMS4zOH qq6jTY+5upoLO4BrCd0el3RU9ZYkxYJO+1anRSex X-Google-Smtp-Source: AGRyM1tJ/Uc5B/XJoSXLcnF76pAX+DiA/uqYaRjrJAYUu9yZiW0d+SAGBCOg8WS/GtxAUC/6LkRBA2YKMCzMouUel+Kd X-Received: from ajr0.svl.corp.google.com ([2620:15c:2d4:203:a065:9221:e40d:4fbe]) (user=axelrasmussen job=sendgmr) by 2002:a25:6ed5:0:b0:669:8b84:bb57 with SMTP id j204-20020a256ed5000000b006698b84bb57mr32393560ybc.227.1658260597485; Tue, 19 Jul 2022 12:56:37 -0700 (PDT) Date: Tue, 19 Jul 2022 12:56:25 -0700 In-Reply-To: <20220719195628.3415852-1-axelrasmussen@google.com> Message-Id: <20220719195628.3415852-3-axelrasmussen@google.com> Mime-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 2/5] userfaultfd: add /dev/userfaultfd for fine grained access control From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi Cc: Axel Rasmussen , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Historically, it has been shown that intercepting kernel faults with userfaultfd (thereby forcing the kernel to wait for an arbitrary amount of time) can be exploited, or at least can make some kinds of exploits easier. So, in 37cd0575b8 "userfaultfd: add UFFD_USER_MODE_ONLY" we changed things so, in order for kernel faults to be handled by userfaultfd, either the process needs CAP_SYS_PTRACE, or this sysctl must be configured so that any unprivileged user can do it. In a typical implementation of a hypervisor with live migration (take QEMU/KVM as one such example), we do indeed need to be able to handle kernel faults. But, both options above are less than ideal: - Toggling the sysctl increases attack surface by allowing any unprivileged user to do it. - Granting the live migration process CAP_SYS_PTRACE gives it this ability, but *also* the ability to "observe and control the execution of another process [...], and examine and change [its] memory and registers" (from ptrace(2)). This isn't something we need or want to be able to do, so granting this permission violates the "principle of least privilege". This is all a long winded way to say: we want a more fine-grained way to grant access to userfaultfd, without granting other additional permissions at the same time. To achieve this, add a /dev/userfaultfd misc device. This device provides an alternative to the userfaultfd(2) syscall for the creation of new userfaultfds. The idea is, any userfaultfds created this way will be able to handle kernel faults, without the caller having any special capabilities. Access to this mechanism is instead restricted using e.g. standard filesystem permissions. Signed-off-by: Axel Rasmussen Acked-by: Nadav Amit Acked-by: Peter Xu --- fs/userfaultfd.c | 69 +++++++++++++++++++++++++------- include/uapi/linux/userfaultfd.h | 4 ++ 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index e943370107d0..968f2517a281 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 int sysctl_unprivileged_userfaultfd __read_mostly; =20 @@ -413,13 +414,8 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsi= gned long reason) =20 if (ctx->features & UFFD_FEATURE_SIGBUS) goto out; - if ((vmf->flags & FAULT_FLAG_USER) =3D=3D 0 && - ctx->flags & UFFD_USER_MODE_ONLY) { - printk_once(KERN_WARNING "uffd: Set unprivileged_userfaultfd " - "sysctl knob to 1 if kernel faults must be handled " - "without obtaining CAP_SYS_PTRACE capability\n"); + if (!(vmf->flags & FAULT_FLAG_USER) && (ctx->flags & UFFD_USER_MODE_ONLY)) goto out; - } =20 /* * If it's already released don't get it. This avoids to loop @@ -2052,19 +2048,30 @@ static void init_once_userfaultfd_ctx(void *mem) seqcount_spinlock_init(&ctx->refile_seq, &ctx->fault_pending_wqh.lock); } =20 -SYSCALL_DEFINE1(userfaultfd, int, flags) +static inline bool userfaultfd_syscall_allowed(int flags) +{ + /* Userspace-only page faults are always allowed */ + if (flags & UFFD_USER_MODE_ONLY) + return true; + + /* + * The user is requesting a userfaultfd which can handle kernel faults. + * Privileged users are always allowed to do this. + */ + if (capable(CAP_SYS_PTRACE)) + return true; + + /* Otherwise, access to kernel fault handling is sysctl controlled. */ + return sysctl_unprivileged_userfaultfd; +} + +static int new_userfaultfd(bool is_syscall, int flags) { struct userfaultfd_ctx *ctx; int fd; =20 - if (!sysctl_unprivileged_userfaultfd && - (flags & UFFD_USER_MODE_ONLY) =3D=3D 0 && - !capable(CAP_SYS_PTRACE)) { - printk_once(KERN_WARNING "uffd: Set unprivileged_userfaultfd " - "sysctl knob to 1 if kernel faults must be handled " - "without obtaining CAP_SYS_PTRACE capability\n"); + if (is_syscall && !userfaultfd_syscall_allowed(flags)) return -EPERM; - } =20 BUG_ON(!current->mm); =20 @@ -2098,8 +2105,42 @@ SYSCALL_DEFINE1(userfaultfd, int, flags) return fd; } =20 +SYSCALL_DEFINE1(userfaultfd, int, flags) +{ + return new_userfaultfd(true, flags); +} + +static int userfaultfd_dev_open(struct inode *inode, struct file *file) +{ + return 0; +} + +static long userfaultfd_dev_ioctl(struct file *file, unsigned int cmd, uns= igned long flags) +{ + if (cmd !=3D USERFAULTFD_IOC_NEW) + return -EINVAL; + + return new_userfaultfd(false, flags); +} + +static const struct file_operations userfaultfd_dev_fops =3D { + .open =3D userfaultfd_dev_open, + .unlocked_ioctl =3D userfaultfd_dev_ioctl, + .compat_ioctl =3D userfaultfd_dev_ioctl, + .owner =3D THIS_MODULE, + .llseek =3D noop_llseek, +}; + +static struct miscdevice userfaultfd_misc =3D { + .minor =3D MISC_DYNAMIC_MINOR, + .name =3D "userfaultfd", + .fops =3D &userfaultfd_dev_fops +}; + static int __init userfaultfd_init(void) { + WARN_ON(misc_register(&userfaultfd_misc)); + userfaultfd_ctx_cachep =3D kmem_cache_create("userfaultfd_ctx_cache", sizeof(struct userfaultfd_ctx), 0, diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaul= tfd.h index 7d32b1e797fb..005e5e306266 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -12,6 +12,10 @@ =20 #include =20 +/* ioctls for /dev/userfaultfd */ +#define USERFAULTFD_IOC 0xAA +#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00) + /* * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In --=20 2.37.0.170.g444d1eabd0-goog From nobody Sat Apr 18 01:21:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C604C433EF for ; Tue, 19 Jul 2022 19:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239834AbiGST5C (ORCPT ); Tue, 19 Jul 2022 15:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239690AbiGST4o (ORCPT ); Tue, 19 Jul 2022 15:56:44 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A0B5B79A for ; Tue, 19 Jul 2022 12:56:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k64-20020a253d43000000b0067080eb57fdso2110647yba.5 for ; Tue, 19 Jul 2022 12:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kfHTJgvI1xhbc2HV5Dg5HLOm6jC5g70kHqbkIkuEdDY=; b=eATFJJjY0r2Ckp5HyJYF7nbsKpNr/n+bnVWTBX/qKJPuAEJFHTGGCBZXyp9cXnxBjg Ca1+y0xLR0qoBqtrlrNHYULBzMXCsc8caFlMWYdtEt52PUQhmCcZQT9ESXfI1teZEuWa IWUlbVDzn15ayl5FiIOdT8aMilcfI1uMjS5UpC1ymoVTyAuboD3MgfK8/r3RKHzKZmKP 8m5pTgYtqjZZkBSc+eWfj3+JIt1hCkNiSZnJ7k/w+No27VJ2bcyRAaOz1ogd6Mrde2Rr +tyNsenOxNV9jPukEvgPal2QfI5GQaafFY21IscEco8k3Vd5LNcprxRmuTztwvxV115+ 2EZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kfHTJgvI1xhbc2HV5Dg5HLOm6jC5g70kHqbkIkuEdDY=; b=bKd7isHdIIqLBJK4evzVrpfrV+tK7NXgE9iBqfCURnmXOy/xIxuvh+iC+04UCjL71s gQf2ct2c2o02GNycpNR65hq6iuR14EDthPoeEobSDiq2MbqaSjt8NdtwiXf9nPwYiz1w NssXs+b+yRaw46oklWSpKQgI9M9qwCpD3Vk00EUtPiwVUpyfja0Fsth/7cWOsIK+mJwO lav8L230gtf+u5BBfE2k1NoqrHlCNHmidIi+bBGSk8K7tU3E1cmIePD9rsmy4SndkbaW gB7rqzjjuwWy9UfgsdOkoomh1XPbtjJd9bqYlZaynxQXThvDA/Bn4D1hc+1esim+YxJJ WJnQ== X-Gm-Message-State: AJIora9LKjLjp1NXwJgYma/CxbaVMk4cJnz7O2VAwkog2Yd0/C6JNd1m 3Fh66fvEx/O0AcSci9VSAkki3vtfqhv1iQ0enrwJ X-Google-Smtp-Source: AGRyM1vh6EyxVuVXbs2vKNFncUeOGmAA4GIWCwxEtu04z5gOe8ex1hyo5UKRpWnlw9uhvTBE62Bd9M97+L2VvA7rWmqs X-Received: from ajr0.svl.corp.google.com ([2620:15c:2d4:203:a065:9221:e40d:4fbe]) (user=axelrasmussen job=sendgmr) by 2002:a25:3b11:0:b0:66e:ccf2:76dc with SMTP id i17-20020a253b11000000b0066eccf276dcmr33549674yba.247.1658260600090; Tue, 19 Jul 2022 12:56:40 -0700 (PDT) Date: Tue, 19 Jul 2022 12:56:26 -0700 In-Reply-To: <20220719195628.3415852-1-axelrasmussen@google.com> Message-Id: <20220719195628.3415852-4-axelrasmussen@google.com> Mime-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 3/5] userfaultfd: selftests: modify selftest to use /dev/userfaultfd From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi Cc: Axel Rasmussen , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We clearly want to ensure both userfaultfd(2) and /dev/userfaultfd keep working into the future, so just run the test twice, using each interface. Instead of always testing both userfaultfd(2) and /dev/userfaultfd, let the user choose which to test. As with other test features, change the behavior based on a new command line flag. Introduce the idea of "test mods", which are generic (not specific to a test type) modifications to the behavior of the test. This is sort of borrowed from this RFC patch series [1], but simplified a bit. The benefit is, in "typical" configurations this test is somewhat slow (say, 30sec or something). Testing both clearly doubles it, so it may not always be desirable, as users are likely to use one or the other, but never both, in the "real world". [1]: https://patchwork.kernel.org/project/linux-mm/patch/20201129004548.161= 9714-14-namit@vmware.com/ Signed-off-by: Axel Rasmussen Acked-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 69 ++++++++++++++++++++---- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selft= ests/vm/userfaultfd.c index 0bdfc1955229..0a126c620bc0 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -77,6 +77,11 @@ static int bounces; #define TEST_SHMEM 3 static int test_type; =20 +#define UFFD_FLAGS (O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY) + +/* test using /dev/userfaultfd, instead of userfaultfd(2) */ +static bool test_dev_userfaultfd; + /* exercise the test_uffdio_*_eexist every ALARM_INTERVAL_SECS */ #define ALARM_INTERVAL_SECS 10 static volatile bool test_uffdio_copy_eexist =3D true; @@ -125,6 +130,8 @@ struct uffd_stats { const char *examples =3D "# Run anonymous memory test on 100MiB region with 99999 bounces:\n" "./userfaultfd anon 100 99999\n\n" + "# Run the same anonymous memory test, but using /dev/userfaultfd:\n" + "./userfaultfd anon:dev 100 99999\n\n" "# Run share memory test on 1GiB region with 99 bounces:\n" "./userfaultfd shmem 1000 99\n\n" "# Run hugetlb memory test on 256MiB region with 50 bounces:\n" @@ -141,6 +148,14 @@ static void usage(void) "[hugetlbfs_file]\n\n"); fprintf(stderr, "Supported : anon, hugetlb, " "hugetlb_shared, shmem\n\n"); + fprintf(stderr, "'Test mods' can be joined to the test type string with a= ':'. " + "Supported mods:\n"); + fprintf(stderr, "\tsyscall - Use userfaultfd(2) (default)\n"); + fprintf(stderr, "\tdev - Use /dev/userfaultfd instead of userfaultfd(2)\n= "); + fprintf(stderr, "\nExample test mod usage:\n"); + fprintf(stderr, "# Run anonymous memory test with /dev/userfaultfd:\n"); + fprintf(stderr, "./userfaultfd anon:dev 100 99999\n\n"); + fprintf(stderr, "Examples:\n\n"); fprintf(stderr, "%s", examples); exit(1); @@ -154,12 +169,14 @@ static void usage(void) ret, __LINE__); \ } while (0) =20 -#define err(fmt, ...) \ +#define errexit(exitcode, fmt, ...) \ do { \ _err(fmt, ##__VA_ARGS__); \ - exit(1); \ + exit(exitcode); \ } while (0) =20 +#define err(fmt, ...) errexit(1, fmt, ##__VA_ARGS__) + static void uffd_stats_reset(struct uffd_stats *uffd_stats, unsigned long n_cpus) { @@ -383,13 +400,29 @@ static void assert_expected_ioctls_present(uint64_t m= ode, uint64_t ioctls) } } =20 +static int __userfaultfd_open_dev(void) +{ + int fd, _uffd =3D -1; + + fd =3D open("/dev/userfaultfd", O_RDWR | O_CLOEXEC); + if (fd < 0) + return -1; + + _uffd =3D ioctl(fd, USERFAULTFD_IOC_NEW, UFFD_FLAGS); + close(fd); + return _uffd; +} + static void userfaultfd_open(uint64_t *features) { struct uffdio_api uffdio_api; =20 - uffd =3D syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MOD= E_ONLY); + if (test_dev_userfaultfd) + uffd =3D __userfaultfd_open_dev(); + else + uffd =3D syscall(__NR_userfaultfd, UFFD_FLAGS); if (uffd < 0) - err("userfaultfd syscall not available in this kernel"); + errexit(KSFT_SKIP, "creating userfaultfd failed"); uffd_flags =3D fcntl(uffd, F_GETFD, NULL); =20 uffdio_api.api =3D UFFD_API; @@ -1584,8 +1617,6 @@ unsigned long default_huge_page_size(void) =20 static void set_test_type(const char *type) { - uint64_t features =3D UFFD_API_FEATURES; - if (!strcmp(type, "anon")) { test_type =3D TEST_ANON; uffd_test_ops =3D &anon_uffd_test_ops; @@ -1603,9 +1634,29 @@ static void set_test_type(const char *type) test_type =3D TEST_SHMEM; uffd_test_ops =3D &shmem_uffd_test_ops; test_uffdio_minor =3D true; - } else { - err("Unknown test type: %s", type); } +} + +static void parse_test_type_arg(const char *raw_type) +{ + char *buf =3D strdup(raw_type); + uint64_t features =3D UFFD_API_FEATURES; + + while (buf) { + const char *token =3D strsep(&buf, ":"); + + if (!test_type) + set_test_type(token); + else if (!strcmp(token, "dev")) + test_dev_userfaultfd =3D true; + else if (!strcmp(token, "syscall")) + test_dev_userfaultfd =3D false; + else + err("unrecognized test mod '%s'", token); + } + + if (!test_type) + err("failed to parse test type argument: '%s'", raw_type); =20 if (test_type =3D=3D TEST_HUGETLB) page_size =3D default_huge_page_size(); @@ -1653,7 +1704,7 @@ int main(int argc, char **argv) err("failed to arm SIGALRM"); alarm(ALARM_INTERVAL_SECS); =20 - set_test_type(argv[1]); + parse_test_type_arg(argv[1]); =20 nr_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); nr_pages_per_cpu =3D atol(argv[2]) * 1024*1024 / page_size / --=20 2.37.0.170.g444d1eabd0-goog From nobody Sat Apr 18 01:21:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F62C43334 for ; Tue, 19 Jul 2022 19:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239884AbiGST5M (ORCPT ); Tue, 19 Jul 2022 15:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239035AbiGST4u (ORCPT ); Tue, 19 Jul 2022 15:56:50 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC385D0FE for ; Tue, 19 Jul 2022 12:56:43 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id m5-20020a2598c5000000b0066faab590c5so11547720ybo.7 for ; Tue, 19 Jul 2022 12:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=D+axFZcXM2aiH957XKoLzm0NK888e8vhfRqJcL8tQlk=; b=Q6lTmACHbxPLYKcD6TEAkGdodCXui8T8KQJjaNpTrLvbWN5YYkAgyFnxcQZ0lRY7oa 9acQO03dUwhSLLvwZgG97CGmC+M40EFkdd14zNVuiZQDK4FpyM9U525S0X5c7VpbI6Xn marrPlcC1B8OnVdKcyWLEzuxmfyKhQY6KJ04vb6BCCY7/tXnVjU1sHyYUUStNY026lvx a1JgtjHgsUNop33vm+b+5kvkCAIjGuUeNHlBhU7D03TW84KjTflKGPaQP9ECMhxEIUtS /x21ATGjiJ/WPYC9JCPHfhv5dMPm6wUIZ9DJZ6WQtg1p5yFpjTb5vnOzyYzl9H6HwAsK MVbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=D+axFZcXM2aiH957XKoLzm0NK888e8vhfRqJcL8tQlk=; b=J5epIH7d5ROhAJREfJudNruZ3xiiJCAKk+MdJX4WApVHwJWumCuivd87rYz7RMZDOL ddNS4edPPgd6azSX91u0DtKe+waU0dV9cvCOd09ntiVg6w7k+tubsOkGA7sVnXmOMvmK JMCfCoE9DOX0bADqkEJCk/AXF80NViUrgymrasPTH/E/8KhtCQxjrc14M7I2Btdqnxxs cf6p2JGJS71CmWMCKWfhkwyoDHcYpjZpAFqrqxfy4QpbgY9H9Szo3jYEybkaKIJ9n0KJ axtiSflkeep50ui1eyQjBXak8hdWSg3zLn5ZfoZVVsp6dp6D9vjHpSKgW6knbUvzYAZY uzvQ== X-Gm-Message-State: AJIora9Aj42nI6qT82N87VFJkOw926QPELv0pdcxSSnLuGri3f+bROrX L9CP+MW2u675WnH1geHPYUvPK/X8mVo5TncnihS2 X-Google-Smtp-Source: AGRyM1sQ1a9x2GIZzx4aY+TQYaC9bhDEJVn0xFYWIaHkF0vSABxhMbIcNlU/zTDwvgT/LJednu8AwjLGuGiRA1DWNMMo X-Received: from ajr0.svl.corp.google.com ([2620:15c:2d4:203:a065:9221:e40d:4fbe]) (user=axelrasmussen job=sendgmr) by 2002:a5b:202:0:b0:66f:aab4:9c95 with SMTP id z2-20020a5b0202000000b0066faab49c95mr32614656ybl.81.1658260602570; Tue, 19 Jul 2022 12:56:42 -0700 (PDT) Date: Tue, 19 Jul 2022 12:56:27 -0700 In-Reply-To: <20220719195628.3415852-1-axelrasmussen@google.com> Message-Id: <20220719195628.3415852-5-axelrasmussen@google.com> Mime-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 4/5] userfaultfd: update documentation to describe /dev/userfaultfd From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi Cc: Axel Rasmussen , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Explain the different ways to create a new userfaultfd, and how access control works for each way. Signed-off-by: Axel Rasmussen Acked-by: Peter Xu --- Documentation/admin-guide/mm/userfaultfd.rst | 41 ++++++++++++++++++-- Documentation/admin-guide/sysctl/vm.rst | 3 ++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/a= dmin-guide/mm/userfaultfd.rst index 6528036093e1..a76c9dc1865b 100644 --- a/Documentation/admin-guide/mm/userfaultfd.rst +++ b/Documentation/admin-guide/mm/userfaultfd.rst @@ -17,7 +17,10 @@ of the ``PROT_NONE+SIGSEGV`` trick. Design =3D=3D=3D=3D=3D=3D =20 -Userfaults are delivered and resolved through the ``userfaultfd`` syscall. +Userspace creates a new userfaultfd, initializes it, and registers one or = more +regions of virtual memory with it. Then, any page faults which occur withi= n the +region(s) result in a message being delivered to the userfaultfd, notifying +userspace of the fault. =20 The ``userfaultfd`` (aside from registering and unregistering virtual memory ranges) provides two primary functionalities: @@ -34,12 +37,11 @@ The real advantage of userfaults if compared to regular= virtual memory management of mremap/mprotect is that the userfaults in all their operations never involve heavyweight structures like vmas (in fact the ``userfaultfd`` runtime load never takes the mmap_lock for writing). - Vmas are not suitable for page- (or hugepage) granular fault tracking when dealing with virtual address spaces that could span Terabytes. Too many vmas would be needed for that. =20 -The ``userfaultfd`` once opened by invoking the syscall, can also be +The ``userfaultfd``, once created, can also be passed using unix domain sockets to a manager process, so the same manager process could handle the userfaults of a multitude of different processes without them being aware about what is going on @@ -50,6 +52,39 @@ is a corner case that would currently return ``-EBUSY``). API =3D=3D=3D =20 +Creating a userfaultfd +---------------------- + +There are two ways to create a new userfaultfd, each of which provide ways= to +restrict access to this functionality (since historically userfaultfds whi= ch +handle kernel page faults have been a useful tool for exploiting the kerne= l). + +The first way, supported since userfaultfd was introduced, is the +userfaultfd(2) syscall. Access to this is controlled in several ways: + +- Any user can always create a userfaultfd which traps userspace page faul= ts + only. Such a userfaultfd can be created using the userfaultfd(2) syscall + with the flag UFFD_USER_MODE_ONLY. + +- In order to also trap kernel page faults for the address space, then eit= her + the process needs the CAP_SYS_PTRACE capability, or the system must have + vm.unprivileged_userfaultfd set to 1. By default, vm.unprivileged_userfa= ultfd + is set to 0. + +The second way, added to the kernel more recently, is by opening and issui= ng a +USERFAULTFD_IOC_NEW ioctl to /dev/userfaultfd. This method yields equivale= nt +userfaultfds to the userfaultfd(2) syscall. + +Unlike userfaultfd(2), access to /dev/userfaultfd is controlled via normal +filesystem permissions (user/group/mode), which gives fine grained access = to +userfaultfd specifically, without also granting other unrelated privileges= at +the same time (as e.g. granting CAP_SYS_PTRACE would do). Users who have a= ccess +to /dev/userfaultfd can always create userfaultfds that trap kernel page f= aults; +vm.unprivileged_userfaultfd is not considered. + +Initializing a userfaultfd +-------------------------- + When first opened the ``userfaultfd`` must be enabled invoking the ``UFFDIO_API`` ioctl specifying a ``uffdio_api.api`` value set to ``UFFD_A= PI`` (or a later API version) which will specify the ``read/POLLIN`` protocol diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-= guide/sysctl/vm.rst index 5c9aa171a0d3..36cf21f3b7ab 100644 --- a/Documentation/admin-guide/sysctl/vm.rst +++ b/Documentation/admin-guide/sysctl/vm.rst @@ -928,6 +928,9 @@ calls without any restrictions. =20 The default value is 0. =20 +Another way to control permissions for userfaultfd is to use +/dev/userfaultfd instead of userfaultfd(2). See +Documentation/admin-guide/mm/userfaultfd.rst. =20 user_reserve_kbytes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.37.0.170.g444d1eabd0-goog From nobody Sat Apr 18 01:21:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 023AFC43334 for ; Tue, 19 Jul 2022 19:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239788AbiGST51 (ORCPT ); Tue, 19 Jul 2022 15:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239732AbiGST4v (ORCPT ); Tue, 19 Jul 2022 15:56:51 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0A75D5B3 for ; Tue, 19 Jul 2022 12:56:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31ce88f9ab8so127541037b3.16 for ; Tue, 19 Jul 2022 12:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=hOhehCg3VD/THunYJJ5B4YThbuYZbL9+a5Qwaql9g98=; b=bNEJzZtKoIwRRVCbEhhzPBFWZtV6mxX5h0TNf42DduzDwcxSAljzJzxILukQgkAqZJ Fr4hgnnXxmToxkm5HMEiBThZjYFkjtQNe1w0gNK8HVvBtsDUcNgn+QTuCIz9wKiHWsOa rQ+x3lFIMfgeny/J1BHAsDcYfSwoYWcXCMgbYh/VWoIVx1qsJxbRI/zFLssciOfAf1OO 4v+uBp9+wTcaNYpEFGhApHT+SfhxwXOIqt2T2pAjvhX1U9EHcdMMY5T/0cmp5MO2+olo EL/TuCXI7fV8EMi8yISn4WQ3LWCqnWkhxLy3WcnraSF8Qfb11rn+rA/jNwzFARxSTaeR vsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hOhehCg3VD/THunYJJ5B4YThbuYZbL9+a5Qwaql9g98=; b=FS+KK1sfgRLYAH3IjCVCsDjnO717sdX7MfQnl9KiD7DL8QQhX2jhzHSCX3y1CRSQBJ jXca6PFOEElm3UnYxmUpJxSpKrsDUyZCF13cwwGtMqpz1JnjTztliel1gwXDHtgnJTMO ZDl0V/mfCfpVSqRTP1Nk8uvA855wBFfE0JAUZ2dZCEctehf5jdT8bVI+z9m7+yYD/q1Z bbRYszEEewyENM51gJFhNk1hwC+Q9eNNzO3VG8uWFi266mqAdcDq1Xk2lPsix1bGFiFT M51i8FHKkiA0GBBlh9RMTTrlglVc9nDZ8fiur/V5e6//NuvCBmTbLIoiMIBYyetHk6H3 1VpQ== X-Gm-Message-State: AJIora/AIRrmkIPToBFqBcf3w5HS+zo5OUeOPq3LhCB2ZlZf2K7cJd5H umz9/1eAV3117+gh5QprxIlgY8gfzbptdEgfAZ/4 X-Google-Smtp-Source: AGRyM1sJa7Fbwmi70rsvyDqxe2kH1B8xy8UoSr0mRkjdLSB4LR9SWeGIONuOcxkrQy2m8DeHjejHuwm+ncnhHIgcyBt6 X-Received: from ajr0.svl.corp.google.com ([2620:15c:2d4:203:a065:9221:e40d:4fbe]) (user=axelrasmussen job=sendgmr) by 2002:a25:2e50:0:b0:669:9a76:beb with SMTP id b16-20020a252e50000000b006699a760bebmr34308174ybn.597.1658260604865; Tue, 19 Jul 2022 12:56:44 -0700 (PDT) Date: Tue, 19 Jul 2022 12:56:28 -0700 In-Reply-To: <20220719195628.3415852-1-axelrasmussen@google.com> Message-Id: <20220719195628.3415852-6-axelrasmussen@google.com> Mime-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 5/5] selftests: vm: add /dev/userfaultfd test cases to run_vmtests.sh From: Axel Rasmussen To: Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Peter Xu , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi Cc: Axel Rasmussen , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Shuah Khan Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This new mode was recently added to the userfaultfd selftest. We want to exercise both userfaultfd(2) as well as /dev/userfaultfd, so add both test cases to the script. Reviewed-by: Shuah Khan Acked-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/run_vmtests.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/self= tests/vm/run_vmtests.sh index e70ae0f3aaf6..156f864030fc 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -121,12 +121,17 @@ run_test ./gup_test -a run_test ./gup_test -ct -F 0x1 0 19 0x1000 =20 run_test ./userfaultfd anon 20 16 +run_test ./userfaultfd anon:dev 20 16 # Hugetlb tests require source and destination huge pages. Pass in half the # size ($half_ufd_size_MB), which is used for *each*. run_test ./userfaultfd hugetlb "$half_ufd_size_MB" 32 +run_test ./userfaultfd hugetlb:dev "$half_ufd_size_MB" 32 run_test ./userfaultfd hugetlb_shared "$half_ufd_size_MB" 32 "$mnt"/uffd-t= est rm -f "$mnt"/uffd-test +run_test ./userfaultfd hugetlb_shared:dev "$half_ufd_size_MB" 32 "$mnt"/uf= fd-test +rm -f "$mnt"/uffd-test run_test ./userfaultfd shmem 20 16 +run_test ./userfaultfd shmem:dev 20 16 =20 #cleanup umount "$mnt" --=20 2.37.0.170.g444d1eabd0-goog