linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Axel Rasmussen <axelrasmussen@google.com>
To: Peter Xu <peterx@redhat.com>
Cc: Jiaqi Yan <jiaqiyan@google.com>,
	David Hildenbrand <david@redhat.com>,
	 James Houghton <jthoughton@google.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Christian Brauner <brauner@kernel.org>,
	 Hongchen Zhang <zhanghongchen@loongson.cn>,
	Huang Ying <ying.huang@intel.com>,
	 "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	 "Mike Rapoport (IBM)" <rppt@kernel.org>,
	Nadav Amit <namit@vmware.com>,
	 Naoya Horiguchi <naoya.horiguchi@nec.com>,
	Shuah Khan <shuah@kernel.org>,
	 ZhangPeng <zhangpeng362@huawei.com>,
	linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-mm@kvack.org,  linux-kselftest@vger.kernel.org,
	Anish Moorthy <amoorthy@google.com>
Subject: Re: [PATCH 1/3] mm: userfaultfd: add new UFFDIO_SIGBUS ioctl
Date: Fri, 19 May 2023 10:32:13 -0700	[thread overview]
Message-ID: <CAJHvVcgVcGigruVdCyOZ2gyrOMboHjuMBwyx9+9LFiv_xH2Q5A@mail.gmail.com> (raw)
In-Reply-To: <ZGehyTCtAtTneiE8@x1n>

On Fri, May 19, 2023 at 9:20 AM Peter Xu <peterx@redhat.com> wrote:
>
> Hi, Jiaqi,
>
> On Fri, May 19, 2023 at 08:04:09AM -0700, Jiaqi Yan wrote:
> > I don't think CAP_ADMIN is something we can work around: a VMM must be
> > a good citizen to avoid introducing any vulnerability to the host or
> > guest.
> >
> > On the other hand, "Userfaults allow the implementation of on-demand
> > paging from userland and more generally they allow userland to take
> > control of various memory page faults, something otherwise only the
> > kernel code could do." [3]. I am not familiar with the UFFD internals,
> > but our use case seems to match what UFFD wants to provide: without
> > affecting the whole world, give a specific userspace (without
> > CAP_ADMIN) the ability to handle page faults (indirectly emulate a
> > HWPOISON page (in my mind I treat it as SetHWPOISON(page) +
> > TestHWPOISON(page) operation in kernel's PF code)). So is it fair to
> > say what Axel provided here is "provide !ADMIN somehow"?
> >
> > [3]https://docs.kernel.org/admin-guide/mm/userfaultfd.html
>
> Userfault keywords on "user", IMHO.  We don't strictly need userfault to
> resolve anything regarding CAP_ADMIN problems.  MADV_DONTNEED also dosn't
> need CAP_ADMIN, same to any new madvise() if we want to make it useful for
> injecting poisoned ptes with !ADMIN and limit it within current->mm.
>
> But I think you're right that userfaultfd always tried to avoid having
> ADMIN and keep everything within its own scope of permissions.
>
> So again, totally no objection on make it uffd specific for now if you guys
> are all happy with it, but just to be clear that it's (to me) mostly for
> avoiding another WAKE, and afaics that's not really for solving the ADMIN
> issue here.

How about this plan:

Since the concrete use case we have (postcopy live migration) is
UFFD-specific, let's leave it as a UFFDIO_* operation for now.

If in the future we come up with a non-UFFD use case, we can add a new
MADV_* which does this operation at that point. From my perspective
they could even share most of the same implementation code.

I don't think it's a big problem keeping the UFFDIO_* version too at
that point, because it still provides some (perhaps small) value:

- Combines the operation + waking into one syscall
- It allows us to support additional UFFD flags which modify / extend
the operation in UFFD-specific ways, if we want to add those in the
future

Seem reasonable?

If so, I'll send a v2 with documentation updates.

>
> Thanks,
>
> --
> Peter Xu
>


  reply	other threads:[~2023-05-19 17:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 18:24 Axel Rasmussen
2023-05-11 18:24 ` [PATCH 2/3] selftests/mm: refactor uffd_poll_thread to allow custom fault handlers Axel Rasmussen
2023-05-11 18:24 ` [PATCH 3/3] selftests/mm: add uffd unit test for UFFDIO_SIGBUS Axel Rasmussen
2023-05-11 20:22 ` [PATCH 1/3] mm: userfaultfd: add new UFFDIO_SIGBUS ioctl Mike Kravetz
2023-05-11 20:40   ` Axel Rasmussen
2023-05-11 21:05     ` Axel Rasmussen
2023-05-11 22:00 ` James Houghton
2023-05-17 22:12   ` Peter Xu
2023-05-17 22:20     ` Peter Xu
2023-05-17 22:28       ` Axel Rasmussen
2023-05-18  0:20         ` Peter Xu
2023-05-18  0:43         ` Jiaqi Yan
2023-05-18 16:05           ` Peter Xu
2023-05-18 20:38             ` Axel Rasmussen
2023-05-18 21:38               ` Peter Xu
2023-05-18 21:50                 ` Peter Xu
2023-05-19  8:38               ` David Hildenbrand
2023-05-19 15:04                 ` Jiaqi Yan
2023-05-19 16:20                   ` Peter Xu
2023-05-19 17:32                     ` Axel Rasmussen [this message]
2023-05-23 17:27                       ` Peter Xu
2023-05-23 17:26 ` Peter Xu
2023-05-23 17:59   ` Axel Rasmussen
2023-05-24 15:05     ` Peter Xu

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=CAJHvVcgVcGigruVdCyOZ2gyrOMboHjuMBwyx9+9LFiv_xH2Q5A@mail.gmail.com \
    --to=axelrasmussen@google.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=amoorthy@google.com \
    --cc=brauner@kernel.org \
    --cc=david@redhat.com \
    --cc=jiaqiyan@google.com \
    --cc=jthoughton@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=namit@vmware.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=ying.huang@intel.com \
    --cc=zhanghongchen@loongson.cn \
    --cc=zhangpeng362@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox