From: David Hildenbrand <david@redhat.com>
To: Audra Mitchell <audra@redhat.com>, viro@zeniv.linux.org.uk
Cc: brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
shuah@kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, raquini@redhat.com,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected
Date: Wed, 8 May 2024 09:39:10 +0200 [thread overview]
Message-ID: <939a16f2-7b66-45a6-a043-4821bd3c71dc@redhat.com> (raw)
In-Reply-To: <20240507195510.283744-1-audra@redhat.com>
On 07.05.24 21:55, Audra Mitchell wrote:
> 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.
I assume you are referencing
"EINVAL The API version requested in the api field is not supported by
this kernel, or the features field passed to the kernel includes
feature bits that are not supported by the current kernel version."
and
"To enable userfaultfd features the application should set a bit
corresponding to each feature it wants to enable in the features field.
If the kernel supports all the requested features it will enable them.
Otherwise it will zero out the returned uffdio_api structure and return
EINVAL.
"
in which case I agree.
>
> 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.
Can you mention which exact one? Is it a WARN* or a pr_warn() ?
Likely we want "Fixes:" here.
>
> 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)))
CCing Peter.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-05-08 7:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` David Hildenbrand [this message]
2024-05-08 12:58 ` [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected Audra Mitchell
2024-05-08 14:11 ` Peter Xu
2024-05-08 16:43 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=939a16f2-7b66-45a6-a043-4821bd3c71dc@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=audra@redhat.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=raquini@redhat.com \
--cc=shuah@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).