NetBSD-Bugs archive

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

Re: PR/56780 CVS commit: src/tests/lib/libc/sys



The following reply was made to PR kern/56780; it has been noted by GNATS.

From: Andreas Gustafsson <gson%gson.org@localhost>
To: Robert Elz <kre%munnari.OZ.AU@localhost>, gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: PR/56780 CVS commit: src/tests/lib/libc/sys
Date: Wed, 6 Apr 2022 09:57:02 +0300

 Robert Elz wrote:
 >  A test for an attempt to mmap() an allocated addr would be a useful
 >  thing to add though.   But just &stack_var isn't going to cut it,
 >  not even &anything_else -- a suitably aligned data struct would need
 >  to be hand crafted first, and probably avoid using anything malloc()'d
 >  as that might be mmap'd, and that might be confusing.  So most likely
 >  
 >  	static char array[4 * PAGE_SIZE];
 >  	intptr_t a = array;
 >  	a += ALIGNMENT;
 >  	a &= ~(ALIGNMENT - 1);
 >  	void *addr = a;
 >  	/* etc, try to mmap(addr, ...) 1 or 2 pages */
 
 I'm all for improving the test coverage of mmap(), but I consider it
 outside the scope of this PR which is about a specific case of false
 positives, not about deficiencies in test coverage.
 
 That said, if we were to test mmapping an address in static data
 storage or the stack with MAP_FIXED, what would the expected result
 be?  Since you say "attempt", it sounds like you think it should be an
 error, but the man page doesn't really say, and what will actually
 happen is that the call succeeds (assuming the arguments to mmap are
 otherwise valid), both on NetBSD and two other operating systems
 I tried it on.
 
 See also: https://lwn.net/Articles/741369/
 -- 
 Andreas Gustafsson, gson%gson.org@localhost
 


Home | Main Index | Thread Index | Old Index