public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* userfaultfd: two-step UFFDIO_API always gives -EINVAL
@ 2024-11-23 15:13 stsp
  2024-11-25  9:05 ` stsp
  2024-11-25 15:59 ` Peter Xu
  0 siblings, 2 replies; 19+ messages in thread
From: stsp @ 2024-11-23 15:13 UTC (permalink / raw)
  To: Linux kernel; +Cc: Muhammad Usama Anjum, Peter Xu

Hello.

I tried to use userfaultfd and got
that strange result: when I first do
UFFDIO_API ioctl with features = 0,
it succeeds. I check the needed
features, and they are all in place.
But on the second step, where I
request the needed features,
UFFDIO_API gives -EINVAL no matter
what features I requested (or even
set features to 0 again).

A quick look into the kernel code
suggests that the problem is that
uffd_ctx_features() doesn't check
user_features for being 0, and just
sets UFFD_FEATURE_INITIALIZED
with no features at all. After that,
userfaultfd_api() should always
fail with -EINVAL when doing this:

ctx_features = uffd_ctx_features(features);
ret = -EINVAL;
if (cmpxchg(&ctx->features, 0, ctx_features) != 0)
         goto err_out;

But I haven't checked my finding
by rebuilding the kernel.
So is this broken or am I missing
something?


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-11-26 17:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23 15:13 userfaultfd: two-step UFFDIO_API always gives -EINVAL stsp
2024-11-25  9:05 ` stsp
2024-11-25 15:59 ` Peter Xu
2024-11-25 16:15   ` stsp
2024-11-25 16:58     ` Peter Xu
2024-11-25 17:07       ` stsp
2024-11-25 17:13         ` Peter Xu
2024-11-25 17:32           ` stsp
2024-11-25 17:44             ` Peter Xu
2024-11-25 18:01               ` stsp
2024-11-25 18:44                 ` Muhammad Usama Anjum
2024-11-26  7:32                   ` stsp
2024-11-26 15:56                     ` Peter Xu
2024-11-26 16:16                       ` stsp
2024-11-26 17:41                         ` Peter Xu
2024-11-26  9:41                   ` stsp
2024-11-25 22:42           ` Axel Rasmussen
2024-11-26  7:39             ` stsp
2024-11-26 15:50               ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox