Re: [PATCH v2 2/3] selftests/memfd_secret: add vmsplice() test

David Hildenbrand
2024-03-26T15:36:23Z

>> +static void test_vmsplice(int fd, const char *desc)
>> +{
>> + ssize_t transferred;
>> + struct iovec iov;
>> + int pipefd[2];
>> + char *mem;
>> +
>> + if (pipe(pipefd)) {
>> + fail("pipe failed: %s\n", strerror(errno));
>> + return;
>> + }
>> +
>> + mem = mmap(NULL, page_size, prot, mode, fd, 0);
>> + if (mem == MAP_FAILED) {
>> + fail("Unable to mmap secret memory\n");
>> + goto close_pipe;
>> + }
>> +
>> + /*
>> + * vmsplice() may use GUP-fast, which must also fail. Prefault the
>> + * page table, so GUP-fast could find it.
>> + */
>> + memset(mem, PATTERN, page_size);
>
> Shouldn't the non-prefault case be tested as well?

That's the "easy" case where GUP-fast is never involved, and it should
mostly be covered by the ptrace/process_vm_read() tests already.

--
Cheers,

David / dhildenb