lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a4899657-7d7b-4786-8903-8f51e438535d@t-8ch.de>
Date:   Mon, 31 Jul 2023 08:10:50 +0200
From:   Thomas Weißschuh <thomas@...ch.de>
To:     Yuan Tan <tanyuan@...ylab.org>
Cc:     w@....eu, falcon@...ylab.org, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v2 2/2] selftests/nolibc: add testcase for pipe

On 2023-07-31 13:51:00+0800, Yuan Tan wrote:
> Add a testcase of pipe that child process sends message to parent
> process.

Thinking about it some more:

What's the advantage of going via a child process?
The pipe should work the same within the same process.

> Here we use memcmp() to avoid the output buffer issue.

This sentence is meaningless without the background from v1.
You can drop it.

> Suggested-by: Thomas Weißschuh <thomas@...ch.de>
> Suggested-by: Willy Tarreau <w@....eu>
> Link: https://lore.kernel.org/all/c5de2d13-3752-4e1b-90d9-f58cca99c702@t-8ch.de/
> Signed-off-by: Yuan Tan <tanyuan@...ylab.org>
> ---
>  tools/testing/selftests/nolibc/nolibc-test.c | 35 ++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 03b1d30f5507..2653ab8d5124 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -767,6 +767,41 @@ int test_mmap_munmap(void)
>  	return ret;
>  }
>  
> +int test_pipe(void)

Should be static and actually get called :-)

> +{
> +	const char *const msg = "hello, nolibc";
> +	int pipefd[2];
> +	char buf[32];
> +	pid_t pid;
> +	ssize_t len;
> +
> +	if (pipe(pipefd) == -1)
> +		return 1;
> +
> +	pid = fork();
> +
> +	switch (pid) {
> +	case -1:
> +		return 1;
> +
> +	case 0:
> +		close(pipefd[0]);
> +		write(pipefd[1], msg, strlen(msg));
> +		close(pipefd[1]);
> +		exit(EXIT_SUCCESS);
> +
> +	default:
> +		close(pipefd[1]);
> +		len = read(pipefd[0], buf, sizeof(buf));
> +		close(pipefd[0]);
> +		waitpid(pid, NULL, 0);
> +
> +		if (len != strlen(msg))
> +			return 1;
> +		return !!memcmp(buf, msg, len);
> +	}
> +}
> +
>  
>  /* Run syscall tests between IDs <min> and <max>.
>   * Return 0 on success, non-zero on failure.
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ