[LTP] [PATCH] userfaultfd: Add test using UFFDIO_POISON

Ricardo Branco rbranco@suse.de
Fri Feb 6 16:47:19 CET 2026



On 2/6/26 3:47 PM, Cyril Hrubis wrote:
> Hi!
>> +static void run(void)
>> +{
>> +	pthread_t thr;
>> +	struct uffdio_api uffdio_api = {};
>> +	struct uffdio_register uffdio_register;
>> +	struct sigaction sa = {};
>> +	volatile char dummy;
>> +
>> +	sa.sa_handler = sigbus_handler;
>> +	sigemptyset(&sa.sa_mask);
>> +	SAFE_SIGACTION(SIGBUS, &sa, NULL);
>> +
>> +	set_pages();
>> +
>> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
>> +
>> +	uffdio_api.api = UFFD_API;
>> +	uffdio_api.features = UFFD_FEATURE_POISON;
>> +
>> +	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
>> +
>> +	uffdio_register.range.start = (unsigned long) page;
>> +	uffdio_register.range.len = page_size;
>> +	uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;
>> +
>> +	SAFE_IOCTL(uffd, UFFDIO_REGISTER, &uffdio_register);
>> +
>> +	SAFE_PTHREAD_BARRIER_INIT(&barrier, NULL, 2);
> Why does this test need barriers and the rest of the tests that looks
> nearly the same does not?

This one is more complex because of the signal handling & siglongjmp.

In the other tests we can just wait for the handler thread. In this test we
must also coordinate with the signal handler,

The alternative would be fork + waitpid with WIFSIGNALED,

Best,
Ricardo.


More information about the ltp mailing list