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: <C3AF612281F87D1A+733ce5c0d1efe1f81423e6885203d92cdb4eaee7.camel@tinylab.org>
Date:   Mon, 31 Jul 2023 20:35:28 +0800
From:   Yuan Tan <tanyuan@...ylab.org>
To:     Thomas Weißschuh <thomas@...ch.de>
Cc:     falcon@...ylab.org, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org, w@....eu
Subject: Re: [PATCH v2 2/2] selftests/nolibc: add testcase for pipe

Hi Thomas,

On Mon, 2023-07-31 at 08:10 +0200, Thomas Weißschuh wrote:
> 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.
> 

The pipe is commonly used for process communication, and I think as a
test case it is supposed to cover the most common scenarios.

> > Here we use memcmp() to avoid the output buffer issue.
> 
> This sentence is meaningless without the background from v1.
> You can drop it.
> 

Got 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