Re: [PATCH 2/2] selftests/seccomp: Ensure that notifications come in FIFO order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux