linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected
@ 2024-05-07 19:55 Audra Mitchell
  2024-05-07 19:55 ` [PATCH 2/2] Update uffd-stress to handle EINVAL for unset config features Audra Mitchell
  2024-05-08  7:39 ` [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected David Hildenbrand
  0 siblings, 2 replies; 7+ messages in thread
From: Audra Mitchell @ 2024-05-07 19:55 UTC (permalink / raw)
  To: viro
  Cc: brauner, jack, linux-fsdevel, linux-kernel, akpm, shuah,
	linux-kselftest, linux-mm, raquini

Currently if we request a feature that is not set in the Kernel
config we fail silently and return the available features. However, the
documentation indicates we should return an EINVAL.

We need to fix this issue since we can end up with a Kernel warning
should a program request the feature UFFD_FEATURE_WP_UNPOPULATED on
a kernel with the config not set with this feature.

Signed-off-by: Audra Mitchell <audra@redhat.com>
---
 fs/userfaultfd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 60dcfafdc11a..17210558de79 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -2073,6 +2073,11 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
 	uffdio_api.features &= ~UFFD_FEATURE_WP_UNPOPULATED;
 	uffdio_api.features &= ~UFFD_FEATURE_WP_ASYNC;
 #endif
+
+	ret = -EINVAL;
+	if (features & ~uffdio_api.features)
+		goto err_out;
+
 	uffdio_api.ioctls = UFFD_API_IOCTLS;
 	ret = -EFAULT;
 	if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api)))
-- 
2.44.0


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

end of thread, other threads:[~2024-05-30 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07 19:55 [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected Audra Mitchell
2024-05-07 19:55 ` [PATCH 2/2] Update uffd-stress to handle EINVAL for unset config features Audra Mitchell
2024-05-08  7:39 ` [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected David Hildenbrand
2024-05-08 12:58   ` Audra Mitchell
2024-05-08 14:11     ` Peter Xu
2024-05-30 15:59       ` Audra Mitchell
2024-05-08 16:43     ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).