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]
Date:   Thu, 22 Jun 2023 21:56:19 +0200
From:   Thomas Weißschuh <thomas@...ch.de>
To:     Zhangjin Wu <falcon@...ylab.org>
Cc:     arnd@...db.de, david.laight@...lab.com,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        linux-riscv@...ts.infradead.org, w@....eu
Subject: Re: [PATCH v4 10/10] selftests/nolibc: add mmap and munmap test cases

Hi Zhangjin,

On 2023-06-23 03:32:49+0800, Zhangjin Wu wrote:
> > On 2023-06-19 23:55:41+0800, Zhangjin Wu wrote:
> > > Three mmap/munmap related test cases are added:
> > > 
> > > - mmap(NULL, 0, PROT_READ, MAP_PRIVATE, 0, 0), MAP_FAILED, EINVAL)
> > > 
> > >   The length argument must be greater than 0, otherwise, fail with -EINVAL.
> > > 
> > > - munmap((void *)-1, 4*1024), -1, EINVAL)
> > > 
> > >   Invalid (void *)-1 address fail with -EINVAL.
> > > 
> > > - test_mmap_munmap(4*1024)
> > > 
> > >   It finds a init file, mmap() it and then munmap().
> > > 
> > > Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
> > > ---
> > >  tools/testing/selftests/nolibc/nolibc-test.c | 31 ++++++++++++++++++++
> > >  1 file changed, 31 insertions(+)
> > > 
> > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> > > index 80ab29e2887c..f7c0ca72cb28 100644
> > > --- a/tools/testing/selftests/nolibc/nolibc-test.c
> > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> > > @@ -592,6 +592,34 @@ static int test_stat_timestamps(void)
> > >  	return 0;
> > >  }
> > >  
> > > +int test_mmap_munmap(int size)
> > > +{
> > > +	char init_files[5][20] = {"/init", "/sbin/init", "/etc/init", "/bin/init", "/bin/sh"};
> > 
> > Why not /proc/1/exe or even /proc/self/exe?
> > 
> > I know your other series tries to remove the procfs dependency, but
> > we're not there yet :-).
> > 
> 
> Yeah, '/proc/self/exe' is a choice, if so, the 'has_proc' should be added ;-)

Currently procfs is a hard requirement. So I would leave 'has_proc' to
the other series that may change this.

> > Also does it make sense to pass a size parameter?
> > Why not use either PAGE_SIZE or the real size of the binary from
> > fstat().
> > 
> 
> Ok, as the manpage of mmap shows:
> 
>        For mmap(), offset must be a multiple of the underlying huge page
>        size.  The system automatically aligns length to be a multiple of
>        the underlying huge page size.
> 
>        For munmap(), addr, and length must both be a multiple of the
>        underlying huge page size.
> 
> perhaps we should do further tests:
> 
> * the real size/length
> * even > the real size
> * the PAGE_SIZE
> * not aligned with PAGE_SIZE
> 
> If such tests are required, the 'size' and even 'offset' arguments could be
> provided to cover different combination or we do such tests internally, then,
> the arguments are not required.

I think task of nolibc-test is to test the code in nolibc itself.
The custom mmap implementation is trivial and directly calls the
syscall. These additionally proposed tests would effectively test the
core kernels implementation of mmap() and not the code of nolibc.

Therefore I don't think they are necessary in nolibc-test and the
functionality is hopefully already be tested in another testsuite.


Note:

Testing mmap is indeed useful to test the implementation of
my_syscall6() by providing a bogus value in the 'offset' parameter.
I think we do have such a testcase.

<snip>

Thomas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ