Message ID | cover.1680306489.git.ackerleytng@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp914010vqo; Fri, 31 Mar 2023 16:53:27 -0700 (PDT) X-Google-Smtp-Source: AKy350a5na9FIxuPQdWJHKntLuBScI+fZU8Z9CFAITzIitrVKpogDaKcWdn0WpiyZI6m0CX+9UAW X-Received: by 2002:a17:906:951:b0:933:3cc7:4420 with SMTP id j17-20020a170906095100b009333cc74420mr28866403ejd.45.1680306807558; Fri, 31 Mar 2023 16:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680306807; cv=none; d=google.com; s=arc-20160816; b=kWLoW3iSK3VLxcb33a+8zozToAJ3MeKpIvqFq0aIe68QqvfW7BhOnURRHB2B7o7yO+ geyoBXpQNimkhvSIQvjpy3OclejsIdDwXOCLXV7jqLqhk5RuM2L4O+ewQNxo9dG/hE0O rvpY6PXno8lP8JqwT11ysCptsKZ2bsNY+nQJ3737bIA14lZYieHQICzbT24lr66XKPev y7kaKQBCexl5gAOWs9wmxbYN623elbJBxtaqk8xGv60lZ1FwQF2b3XfuyxLhCAAOXNpT 0HD6416YjRikA1Rk7qkune/5q9pz2xFmkRHE1Zpf1TYqoZStzDMOUXaa7L9T8ajIqqCg Ljnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:mime-version:date:dkim-signature; bh=MX7MCqmj1YYihUkBpAVlEeGMviJT2cJPKDZIN4OR+eI=; b=vPR52MwavtCamTGGFFHUx+hLyKWx9KMMHedMdRaNKmCJLixtfhP1pEC0dPMPCq9EyU beH/sBKgtdSDa7N92OSNNCV793WSoj6PUtRDvmd80xPb9QwaeEBB1ntoQWAY4aRAnC9S TubvxwFE1Cid0igJqySnvqzhT/DYECfQ9Ziz6HGD2uKQVr7s0X6I2TUMM4IuwYUAzvam C50CUqgQGFa4d4UEsCcKsg5atCEGERdEY0aKKTEyQx8ODAn1bp20zJ/k8/gU8jRd7SGL mj7O7inrtdc0IPoedZbaHNmpoijqsma1YlnlWCRnIx71TS/2iEQ9SGxY30ZnuM8gP/e9 BDdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rs2Oji08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my14-20020a1709065a4e00b0093472dbf64asi569505ejc.557.2023.03.31.16.52.59; Fri, 31 Mar 2023 16:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rs2Oji08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233273AbjCaXuw (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Fri, 31 Mar 2023 19:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233129AbjCaXus (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 31 Mar 2023 19:50:48 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4CF11C1DB for <linux-kernel@vger.kernel.org>; Fri, 31 Mar 2023 16:50:45 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id p9-20020a170902e74900b001a1c7b2e7afso13607689plf.0 for <linux-kernel@vger.kernel.org>; Fri, 31 Mar 2023 16:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680306645; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=MX7MCqmj1YYihUkBpAVlEeGMviJT2cJPKDZIN4OR+eI=; b=rs2Oji081/y9n1X5EoKWy+YAnL83qBuCdumcenLPrxwfD9FhAIw4hlVj4XP7/Y5Csq lU5b9UIB/trmNN3L2g1BONn/YlWj6kHwCJvT6fd05AaijB3WMTF8/D+hd3HfgCkafQDu NbHJ0a1bnlAMC3KxpgtTUZNOqAMxuDxYtesuddpHrX/ENLS89CzH5G+JzzOmQK4jvnd5 5mTrfkQj806FnvEE68QrxmzAe0mZ26vs2memR3hQ+yGRR4Hz54qvdF34OtXX2se9Qkq6 yuJZ+avzEi827lI5ZZjCExL+izen0tkcmYbNDaEC2FQNPb5gMHAwJLc2JI7bg+7pOI5w M4qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680306645; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MX7MCqmj1YYihUkBpAVlEeGMviJT2cJPKDZIN4OR+eI=; b=C+s0a7z+/GLBAY4KRTUrUgYPIHswW1aN0v7KoQ8gT0G0spvNL7bPfmxhXhKtU4LKuO 3i/xVImU81g8IYQdzpc0nVZU88TnIrmRiblCJx65gZujxPoyT1VO4JmqdIU9zTmiZLGP cs02BFLboVcr9H5OXihFPUM1RVk8O4JwSUdFQ8xvnVqCO5k8IlBBIG2xJTH6UWhHbjYR EXy88G0nkHHo1v3fJyUvvadX30vCGrMEMa88Y+3rL/RsCPgDAi2kQ+hwKN+AJWXIYfeR nBrJzD9lSnMX/iOJI11WtAq+o6VmVRrSHiuuaGjs/wsAm3aNVQoWpbW2D0UUB94jOkzk O6Ew== X-Gm-Message-State: AAQBX9cH7RgGvn9YFqrN0u9kE7GedXEIt1r7X9qTtC+ZduxjOQqCbdaG GB6BfzTwFH53vlWz4NlAyUryqbEfJilvu+c6GA== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a05:6a00:a12:b0:62d:9bea:2a0c with SMTP id p18-20020a056a000a1200b0062d9bea2a0cmr8375791pfh.4.1680306645245; Fri, 31 Mar 2023 16:50:45 -0700 (PDT) Date: Fri, 31 Mar 2023 23:50:38 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <cover.1680306489.git.ackerleytng@google.com> Subject: [RFC PATCH v3 0/2] Providing mount in memfd_restricted() syscall From: Ackerley Tng <ackerleytng@google.com> To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, Ackerley Tng <ackerleytng@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761929391122561003?= X-GMAIL-MSGID: =?utf-8?q?1761929391122561003?= |
Series |
Providing mount in memfd_restricted() syscall
|
|
Message
Ackerley Tng
March 31, 2023, 11:50 p.m. UTC
Hello, This patchset builds upon the memfd_restricted() system call that was discussed in the ‘KVM: mm: fd-based approach for supporting KVM’ patch series, at https://lore.kernel.org/lkml/20221202061347.1070246-1-chao.p.peng@linux.intel.com/T/ The tree can be found at: https://github.com/googleprodkernel/linux-cc/tree/restrictedmem-provide-mount-fd-rfc-v3 In this patchset, a modification to the memfd_restricted() syscall is proposed, which allows userspace to provide a mount, on which the restrictedmem file will be created and returned from the memfd_restricted(). Allowing userspace to provide a mount allows userspace to control various memory binding policies via tmpfs mount options, such as Transparent HugePage memory allocation policy through ‘huge=always/never’ and NUMA memory allocation policy through ‘mpol=local/bind:*’. Changes since RFCv2: + Tightened semantics to accept only fds of the root of a tmpfs mount, as Christian suggested + Added permissions check on the inode represented by the fd to guard against creation of restrictedmem files on read-only tmpfs filesystems or mounts + Renamed RMFD_TMPFILE to RMFD_USERMNT to better represent providing a userspace mount to create a restrictedmem file on + Updated selftests for tighter semantics and added selftests to check for permissions Changes since RFCv1: + Use fd to represent mount instead of path string, as Kirill suggested. I believe using fds makes this syscall interface more aligned with the other syscalls like fsopen(), fsconfig(), and fsmount() in terms of using and passing around fds + Remove unused variable char *orig_shmem_enabled from selftests Dependencies: + Sean’s iteration of the ‘KVM: mm: fd-based approach for supporting KVM’ patch series at https://github.com/sean-jc/linux/tree/x86/upm_base_support + Proposed fixes for these issues mentioned on the mailing list: + https://lore.kernel.org/lkml/diqzzga0fv96.fsf@ackerleytng-cloudtop-sg.c.googlers.com/ Links to earlier patch series: + RFC v2: https://lore.kernel.org/lkml/cover.1679428901.git.ackerleytng@google.com/T/ + RFC v1: https://lore.kernel.org/lkml/cover.1676507663.git.ackerleytng@google.com/T/ --- Ackerley Tng (2): mm: restrictedmem: Allow userspace to specify mount for memfd_restricted selftests: restrictedmem: Check hugepage-ness of shmem file backing restrictedmem fd include/linux/syscalls.h | 2 +- include/uapi/linux/restrictedmem.h | 8 + mm/restrictedmem.c | 74 ++- tools/testing/selftests/Makefile | 1 + .../selftests/restrictedmem/.gitignore | 3 + .../testing/selftests/restrictedmem/Makefile | 15 + .../testing/selftests/restrictedmem/common.c | 9 + .../testing/selftests/restrictedmem/common.h | 8 + .../restrictedmem_hugepage_test.c | 486 ++++++++++++++++++ 9 files changed, 599 insertions(+), 7 deletions(-) create mode 100644 include/uapi/linux/restrictedmem.h create mode 100644 tools/testing/selftests/restrictedmem/.gitignore create mode 100644 tools/testing/selftests/restrictedmem/Makefile create mode 100644 tools/testing/selftests/restrictedmem/common.c create mode 100644 tools/testing/selftests/restrictedmem/common.h create mode 100644 tools/testing/selftests/restrictedmem/restrictedmem_hugepage_test.c -- 2.40.0.348.gf938b09366-goog