From: Rodrigo Campos <rodrigo@kinvolk.io>
To: Sargun Dhillon <sargun@sargun.me>
Cc: Kees Cook <keescook@chromium.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux Containers <containers@lists.linux-foundation.org>,
Christian Brauner <christian.brauner@ubuntu.com>,
Giuseppe Scrivano <gscrivan@redhat.com>,
Will Drewry <wad@chromium.org>,
Andy Lutomirski <luto@amacapital.net>,
Alban Crequy <alban@kinvolk.io>
Subject: Re: [PATCH v3 1/2] seccomp: Add wait_killable semantic to seccomp user notifier
Date: Fri, 29 Apr 2022 11:42:15 +0200 [thread overview]
Message-ID: <CACaBj2bW8XkENHoLNXEprQ_d8=_aLT_XQdjCZtSOiPJis8G_pQ@mail.gmail.com> (raw)
In-Reply-To: <20220429023113.74993-2-sargun@sargun.me>
On Fri, Apr 29, 2022 at 4:32 AM Sargun Dhillon <sargun@sargun.me> wrote:
> the concept is searchable. If the notifying process is signaled prior
> to the notification being received by the userspace agent, it will
> be handled as normal.
Why is that? Why not always handle in the same way (if wait killable
is set, wait like that)
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index db10e73d06e0..9291b0843cb2 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -1081,6 +1088,12 @@ static void seccomp_handle_addfd(struct seccomp_kaddfd *addfd, struct seccomp_kn
> complete(&addfd->completion);
> }
>
> +static bool should_sleep_killable(struct seccomp_filter *match,
> + struct seccomp_knotif *n)
> +{
> + return match->wait_killable_recv && n->state == SECCOMP_NOTIFY_SENT;
Here for some reason we check the notification state to be SENT.
> +}
> +
> static int seccomp_do_user_notification(int this_syscall,
> struct seccomp_filter *match,
> const struct seccomp_data *sd)
> @@ -1111,11 +1124,25 @@ static int seccomp_do_user_notification(int this_syscall,
> * This is where we wait for a reply from userspace.
> */
> do {
> + bool wait_killable = should_sleep_killable(match, &n);
> +
So here, the first time this runs this will be false even if the
wait_killable flag was used in the filter (because that function
checks the notification state to be sent, that is not true the first
time)
Why not just do wait_for_completion_killable if match->wait_killable
and wait_for_completion_interruptible otherwise? Am I missing
something?
Best,
Rodrigo
next prev parent reply other threads:[~2022-04-29 9:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 2:31 [PATCH v3 0/2] Handle seccomp notification preemption Sargun Dhillon
2022-04-29 2:31 ` [PATCH v3 1/2] seccomp: Add wait_killable semantic to seccomp user notifier Sargun Dhillon
2022-04-29 9:42 ` Rodrigo Campos [this message]
2022-04-29 17:14 ` Sargun Dhillon
2022-04-29 18:20 ` Kees Cook
2022-05-02 12:48 ` Rodrigo Campos
2022-04-29 18:22 ` Kees Cook
2022-05-02 14:15 ` Rodrigo Campos
2022-05-02 16:04 ` Sargun Dhillon
2022-05-03 14:27 ` Rodrigo Campos
2022-04-29 2:31 ` [PATCH v3 2/2] selftests/seccomp: Add test for wait killable notifier Sargun Dhillon
2022-04-29 18:19 ` Kees Cook
2022-04-29 22:35 ` Sargun Dhillon
2022-04-29 22:43 ` Kees Cook
2022-04-29 9:24 ` [PATCH v3 0/2] Handle seccomp notification preemption Rodrigo Campos
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='CACaBj2bW8XkENHoLNXEprQ_d8=_aLT_XQdjCZtSOiPJis8G_pQ@mail.gmail.com' \
--to=rodrigo@kinvolk.io \
--cc=alban@kinvolk.io \
--cc=christian.brauner@ubuntu.com \
--cc=containers@lists.linux-foundation.org \
--cc=gscrivan@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=sargun@sargun.me \
--cc=wad@chromium.org \
/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 NNTP newsgroup(s).