Re: [PATCH v4 0/5] userfaultfd: add /dev/userfaultfd for fine grained access control

From: Nadav Amit
Date: Mon Aug 01 2022 - 19:19:58 EST


On Aug 1, 2022, at 3:50 PM, Axel Rasmussen <axelrasmussen@xxxxxxxxxx> wrote:

> ⚠ External Email
>
> On Mon, Aug 1, 2022 at 12:53 PM Nadav Amit <namit@xxxxxxxxxx> wrote:
>> On Aug 1, 2022, at 10:13 AM, Axel Rasmussen <axelrasmussen@xxxxxxxxxx> wrote:
>
> Ah, that I think is more or less what my series already proposes, if I
> understand you correctly.
>
> The usage is:
>
> fd = open(/dev/userfaultfd) /* This FD is only useful for creating new
> userfaultfds */
> uffd = ioctl(fd, USERFAULTFD_IOC_NEW) /* Now you get a real uffd */
> close(fd); /* No longer needed now that we have a real uffd */
>
> /* Use uffd to register, COPY, CONTINUE, whatever */
>
> One thing we could do now or in the future is extend
> USERFAULTFD_IOC_NEW to take a pid as an argument, to support creating
> uffds for remote processes.
>
>
>
> And then we get the benefit of permissions for /dev nodes working very
> naturally - they default to root, but can be configured by the
> sysadmin via chown/chmod, or udev rules, or whatever.

Oh. Stupid me. Then yes, using the /dev/userfaultfd is in line with other
usage models, such as KVM. And reading from each file descriptor is indeed
providing different output.