public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho@tycho.pizza>
To: Sargun Dhillon <sargun@sargun.me>
Cc: Kees Cook <keescook@chromium.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/seccomp: Ensure that notifications come in FIFO order
Date: Thu, 28 Apr 2022 07:15:51 -0600	[thread overview]
Message-ID: <YmqTh68UkjVsTnUX@cisco> (raw)
In-Reply-To: <20220428015447.13661-2-sargun@sargun.me>

On Wed, Apr 27, 2022 at 06:54:47PM -0700, Sargun Dhillon wrote:
> +	/* Start children, and them generate notifications */
                           ^^ - they maybe?

> +	for (i = 0; i < ARRAY_SIZE(pids); i++) {
> +		pid = fork();
> +		if (pid == 0) {
> +			ret = syscall(__NR_getppid);
> +			exit(ret != USER_NOTIF_MAGIC);
> +		}
> +		pids[i] = pid;
> +	}
> +
> +	/* This spins until all of the children are sleeping */
> +restart_wait:
> +	for (i = 0; i < ARRAY_SIZE(pids); i++) {
> +		if (get_proc_stat(pids[i]) != 'S') {
> +			nanosleep(&delay, NULL);
> +			goto restart_wait;
> +		}
> +	}

I wonder if we should/can combine this loop with the previous one, and
wait for the child to sleep in getppid() before we fork the next one.
Otherwise isn't racy in the case that your loop continues to the next
iteration before the child processes are scheduled, so things might be
out of order? Maybe I'm missing something.

In any case, this change seems reasonable to me.

Tycho

  reply	other threads:[~2022-04-28 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  1:54 [PATCH 1/2] seccomp: Use FIFO semantics to order notifications Sargun Dhillon
2022-04-28  1:54 ` [PATCH 2/2] selftests/seccomp: Ensure that notifications come in FIFO order Sargun Dhillon
2022-04-28 13:15   ` Tycho Andersen [this message]
2022-04-28 16:38     ` Sargun Dhillon
2022-04-28 19:34       ` Tycho Andersen
2022-04-28  8:04 ` [PATCH 1/2] seccomp: Use FIFO semantics to order notifications Christian Brauner
2022-04-29 18:50 ` Kees Cook

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=YmqTh68UkjVsTnUX@cisco \
    --to=tycho@tycho.pizza \
    --cc=christian.brauner@ubuntu.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=sargun@sargun.me \
    /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