public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/madvise02.c: Fix ENOMEM errno tests
@ 2018-07-27  6:05 Xiao Yang
  2018-07-26  7:46 ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Xiao Yang @ 2018-07-27  6:05 UTC (permalink / raw)
  To: ltp

With commit 212a4b9 on some distros(e.g. RHEL6.9/7.5), running
madvise02 got the following error:
------------------------------------------------------
...
madvise02.c:181: CONF: MADV_UNMERGEABLE is not supported
madvise02.c:196: FAIL: madvise succeeded unexpectedly
madvise02.c:196: FAIL: madvise succeeded unexpectedly
madvise02.c:181: CONF: MADV_WILLNEED is not supported
...
-------------------------------------------------------

If MAP_SIZE was equal to a pagesize, shared_anon may get the same
address which was a part of file2 and already unmapped, so that the
whole address of file2 became valid again.  Subsequently, ENOMEM
errno tests succeeded, so changing the order of mmaps to make
shared_anon get different address.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/madvise/madvise02.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index 53e4f51..f683a99 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -156,11 +156,11 @@ static void setup(void)
 	SAFE_FSTAT(fd, &st);
 
 	file1 = SAFE_MMAP(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+	shared_anon = SAFE_MMAP(0, MAP_SIZE, PROT_READ, MAP_SHARED |
+			 MAP_ANONYMOUS, -1, 0);
 	file2 = SAFE_MMAP(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
 	SAFE_MUNMAP(file2 + st.st_size - pagesize, pagesize);
 	file3 = SAFE_MMAP(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
-	shared_anon = SAFE_MMAP(0, MAP_SIZE, PROT_READ, MAP_SHARED |
-			MAP_ANONYMOUS, -1, 0);
 
 	nonalign = file1 + 100;
 
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-27  6:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-27  6:05 [LTP] [PATCH] syscalls/madvise02.c: Fix ENOMEM errno tests Xiao Yang
2018-07-26  7:46 ` Jan Stancek
2018-07-26  7:51   ` Xiao Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox