All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 00/18] Collection of fixes
@ 2017-10-26 14:14 Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib Punit Agrawal
                   ` (17 more replies)
  0 siblings, 18 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

Hi,

This series collects fixes for issues encountered when running ltp on
internal test platforms. The fixes touch a variety of tests - I've
grouped patches touching related tests togther.

The patches fix issue with missing kernel feature detection, improper
synchronisation in certain scenarios, and executing on systems with
minimal userspace such as busybox.

Although the problems were encountered on internal platforms the
patches improve the robustness of the tests and are applicable in wide
ranging test scenarios.

Please consider merging them.

Thanks,
Punit

James Morse (2):
  hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug
  hotplug/cpu_hotplug: Remove bashism disown from kill_pid()

Lorenzo Pieralisi (1):
  hugeshmget02: add missing SHM_HUGETLB flag on segment creation

Mark Rutland (2):
  inotify: fix inotify.h breakage
  ioctl: fix stty usage for busybox

Punit Agrawal (1):
  Move check_hugepage() helper to mem/lib

Suzuki K. Poulose (5):
  hugeshmctl01: Fix synchronisation with child processes
  hugeshmctl01: Fix synchronization issue in parent process
  hugeshmctl02: Fix allocation size for odd number of hugepages
  getdtablesize01: Handle ENFILE errno
  perf_event_open: Handle absence of PMU gracefully

Will Deacon (7):
  thp: ensure THP/hugetlbfs is available
  vma03: accept ENOMEM return value from mremap
  creat08: ensure test directories are created in /tmp/
  kill05: fix race on getpwnam
  sigwaitinfo01: fix race between sending and dequeueing RT signals
  sigwaitinfo: catch SEGV and report success for bad_address2 testcase
  syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'

 .../cpu_hotplug/include/cpuhotplug_hotplug.sh      | 36 ++++++++++++
 .../cpu_hotplug/include/cpuhotplug_testsuite.sh    |  1 -
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c   | 64 ++++++++--------------
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c   |  2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c   |  3 +-
 testcases/kernel/mem/hugetlb/lib/hugetlb.c         |  6 --
 testcases/kernel/mem/hugetlb/lib/hugetlb.h         |  1 -
 testcases/kernel/mem/include/mem.h                 |  2 +
 testcases/kernel/mem/lib/mem.c                     |  6 ++
 testcases/kernel/mem/thp/thp01.c                   |  3 +
 testcases/kernel/mem/thp/thp02.c                   |  2 +
 testcases/kernel/mem/thp/thp03.c                   |  2 +
 testcases/kernel/mem/vma/vma03.c                   |  2 +-
 testcases/kernel/syscalls/creat/creat08.c          |  4 +-
 .../syscalls/getdtablesize/getdtablesize01.c       | 17 +++---
 testcases/kernel/syscalls/inotify/inotify.h        |  8 +--
 testcases/kernel/syscalls/ioctl/test_ioctl         |  2 +-
 testcases/kernel/syscalls/kill/kill05.c            |  7 ++-
 testcases/kernel/syscalls/mount/mount03.c          |  4 +-
 .../syscalls/perf_event_open/perf_event_open01.c   |  3 +-
 .../syscalls/perf_event_open/perf_event_open02.c   |  4 +-
 .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    | 36 +++++++++++-
 22 files changed, 141 insertions(+), 74 deletions(-)

-- 
2.14.2


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

* [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 10:53   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 02/18] thp: ensure THP/hugetlbfs is available Punit Agrawal
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

Move the check_hugepage() helper to mem/lib to be more widely available
to testcases. Specifically, it will be used in a subsequent commit to
check for the presence of hugepage support when running the thp tests.

Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/hugetlb/lib/hugetlb.c | 6 ------
 testcases/kernel/mem/hugetlb/lib/hugetlb.h | 1 -
 testcases/kernel/mem/include/mem.h         | 2 ++
 testcases/kernel/mem/lib/mem.c             | 6 ++++++
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
index 7afc7d4b4..2f86e3558 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
@@ -40,12 +40,6 @@
 #include <pwd.h>
 #include "hugetlb.h"
 
-void check_hugepage(void)
-{
-	if (access(PATH_HUGEPAGES, F_OK))
-		tst_brk(TCONF, "Huge page is not supported.");
-}
-
 /*
  * getipckey() - generates and returns a message key used by the "get"
  *		 calls to create an IPC resource.
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
index c6d2016b7..f4a1a75d7 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
@@ -45,7 +45,6 @@
  * from shmid_ds.ipc_perm.mode
  */
 #define MODE_MASK	0x01FF
-#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
 
 key_t shmkey;			/* an IPC key generated by ftok() */
 
diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 287f8b3f6..95d0bda72 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -56,8 +56,10 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages);
 
 /* HUGETLB */
 
+#define PATH_HUGEPAGES		"/sys/kernel/mm/hugepages/"
 #define PATH_SHMMAX		"/proc/sys/kernel/shmmax"
 
+void check_hugepage(void);
 void write_memcg(void);
 
 /* cpuset/memcg */
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index dd82b08d2..9ac3160ac 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -346,6 +346,12 @@ static void verify(char **memory, char value, int proc,
 	free(s);
 }
 
+void check_hugepage(void)
+{
+	if (access(PATH_HUGEPAGES, F_OK))
+		tst_brk(TCONF, "Huge page is not supported.");
+}
+
 void write_memcg(void)
 {
 	SAFE_FILE_PRINTF(MEMCG_LIMIT, "%ld", TESTMEM);
-- 
2.14.2


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

* [LTP] [PATCH 02/18] thp: ensure THP/hugetlbfs is available
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes Punit Agrawal
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

The THP tests can't pass if THP is unavailable or disabled. Add the
missing detection to thp01.c.

Also add tests for the presence of hugetlbfs for tests relying on this
kernel feature.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/thp/thp01.c | 3 +++
 testcases/kernel/mem/thp/thp02.c | 2 ++
 testcases/kernel/mem/thp/thp03.c | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/testcases/kernel/mem/thp/thp01.c b/testcases/kernel/mem/thp/thp01.c
index 2f2bb2bdb..939c01b98 100644
--- a/testcases/kernel/mem/thp/thp01.c
+++ b/testcases/kernel/mem/thp/thp01.c
@@ -116,6 +116,9 @@ static void setup(void)
 	int i;
 	long arg_len, arg_count;
 
+	if (access(PATH_THP, F_OK) == -1)
+		tst_brk(TCONF, "THP not enabled in kernel?");
+
 	bst = SAFE_MMAP(NULL, sizeof(*bst),
 			   PROT_READ | PROT_WRITE,
 			   MAP_SHARED | MAP_ANONYMOUS, -1, 0);
diff --git a/testcases/kernel/mem/thp/thp02.c b/testcases/kernel/mem/thp/thp02.c
index acc70e215..6502210e5 100644
--- a/testcases/kernel/mem/thp/thp02.c
+++ b/testcases/kernel/mem/thp/thp02.c
@@ -90,6 +90,8 @@ static void setup(void)
 	if (access(PATH_THP, F_OK) == -1)
 		tst_brk(TCONF, "THP not enabled in kernel?");
 
+	check_hugepage();
+
 	ps = sysconf(_SC_PAGESIZE);
 	hps = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	size = hps * 4;
diff --git a/testcases/kernel/mem/thp/thp03.c b/testcases/kernel/mem/thp/thp03.c
index 19db44944..c6062505f 100644
--- a/testcases/kernel/mem/thp/thp03.c
+++ b/testcases/kernel/mem/thp/thp03.c
@@ -82,6 +82,8 @@ static void setup(void)
 	if (access(PATH_THP, F_OK) == -1)
 		tst_brk(TCONF, "THP not enabled in kernel?");
 
+	check_hugepage();
+
 	hugepage_size = SAFE_READ_MEMINFO("Hugepagesize:") * KB;
 	unaligned_size = hugepage_size * 4 - 1;
 	page_size = SAFE_SYSCONF(_SC_PAGESIZE);
-- 
2.14.2


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

* [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 02/18] thp: ensure THP/hugetlbfs is available Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:04   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process Punit Agrawal
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>

hugeshmctl01 spawns child processes to perform shm operations and uses
signal (SIGUSR1) to communicate the completion of test 1, to the
children waiting at sigprocmask(). However, there is no guarantee that a
child has reached sigprocmask() before the parent issues a SIGUSR1 and
things go wrong.

This patch fixes this issue by 'stopping' the children, waiting for all
of them and then issuing SIGCONT to communicate the completion.

While we are at it, also handle unknown signals as a hint to exit the
test with TBROK.

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c   | 56 +++++++---------------
 1 file changed, 16 insertions(+), 40 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
index ad7a80d70..37a8a0d6f 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
@@ -141,6 +141,7 @@ void *set_shmat(void)
  */
 static void stat_setup(void)
 {
+	int status;
 	int i, rval;
 	void *test;
 	pid_t pid;
@@ -150,10 +151,10 @@ static void stat_setup(void)
 	memset (&sa, '\0', sizeof(sa));
 	sa.sa_handler = sighandler;
 	sa.sa_flags = 0;
-	TEST(sigaction(SIGUSR1, &sa, NULL));
+	TEST(sigaction(SIGCONT, &sa, NULL));
 	if (TEST_RETURN == -1)
 		tst_brk(TBROK | TRERRNO,
-				"SIGSEGV signal setup failed");
+				"SIGCONT signal setup failed");
 	/*
 	 * The first time through, let the children attach the memory.
 	 * The second time through, attach the memory first and let
@@ -168,21 +169,6 @@ static void stat_setup(void)
 		set_shared = set_shmat();
 	}
 
-	/*
-	 * Block SIGUSR1 before children pause for a signal
-	 * Doing so to avoid the risk that the parent cleans up
-	 * children by calling stat_cleanup() before children call
-	 * call pause() so that children sleep forever(this is a
-	 * side effect of the arbitrary usleep time below).
-	 * In FIRST, children call shmat. If children sleep forever,
-	 * those attached shm can't be released so some other shm
-	 * tests will fail a lot.
-	 */
-	sigemptyset(&newmask);
-	sigaddset(&newmask, SIGUSR1);
-	if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
-		tst_brk(TBROK | TERRNO, "block SIGUSR1 error");
-
 	for (i = 0; i < N_ATTACH; i++) {
 		switch (pid = SAFE_FORK()) {
 		case 0:
@@ -191,22 +177,8 @@ static void stat_setup(void)
 			/* do an assignement for fun */
 			*(int *)test = i;
 
-			/*
-			 * sigsuspend until we get a signal from stat_cleanup()
-			 * use sigsuspend instead of pause to avoid children
-			 * infinite sleep without getting SIGUSR1 from parent
-			 */
-			rval = sigsuspend(&oldmask);
-			if (rval != -1)
-				tst_brk(TBROK | TERRNO, "sigsuspend");
-
-			/*
-			 * don't have to block SIGUSR1 any more,
-			 * recover the mask
-			 */
-			if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
-				tst_brk(TBROK | TERRNO,
-					 "child sigprocmask");
+			/* Wait until the parent cleans up after the first test */
+			raise(SIGSTOP);
 
 			/* now we're back - detach the memory and exit */
 			if (shmdt(test) == -1)
@@ -219,11 +191,15 @@ static void stat_setup(void)
 		}
 	}
 
-	/* parent doesn't have to block SIGUSR1, recover the mask */
-	if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
-		tst_brk(TBROK, "parent sigprocmask");
-
-	usleep(250000);
+	/*
+	 * Wait for the children process to stop after they have touched
+	 * shm.
+	 */
+	for (i = 0; i < N_ATTACH; i++) {
+		SAFE_WAITPID(pid_arr[i], &status, WUNTRACED);
+		if (!WIFSTOPPED(status))
+			tst_brk(TBROK, "pid %d didn't stop", pid_arr[i]);
+	}
 }
 
 /*
@@ -287,7 +263,7 @@ static void stat_cleanup(void)
 
 	/* wake up the childern so they can detach the memory and exit */
 	for (i = 0; i < N_ATTACH; i++)
-		SAFE_KILL(pid_arr[i], SIGUSR1);
+		SAFE_KILL(pid_arr[i], SIGCONT);
 
 	/* remove the parent's shared memory the second time through */
 	if (stat_time == SECOND)
@@ -298,7 +274,7 @@ static void stat_cleanup(void)
 
 static void sighandler(int sig)
 {
-	if (sig != SIGUSR1)
+	if (sig != SIGCONT)
 		tst_res(TFAIL, "received unexpected signal %d", sig);
 }
 
-- 
2.14.2


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

* [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (2 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:05   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages Punit Agrawal
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>

Wait for the children from the first test to detach and exit, before
proceeding to the next round. Otherwise we could have incorrect
references on the shm_id lying around from the previous run.

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
index 37a8a0d6f..ea249d1b6 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
@@ -260,10 +260,16 @@ fail:
 static void stat_cleanup(void)
 {
 	int i;
+	int status;
 
 	/* wake up the childern so they can detach the memory and exit */
-	for (i = 0; i < N_ATTACH; i++)
+	for (i = 0; i < N_ATTACH; i++) {
 		SAFE_KILL(pid_arr[i], SIGCONT);
+		/* Wait for the child to exit */
+		if (waitpid(pid_arr[i], &status, 0) != pid_arr[i] &&
+			!WIFEXITED(status))
+			tst_brk(TBROK | TERRNO, "waitpid for exit");
+	}
 
 	/* remove the parent's shared memory the second time through */
 	if (stat_time == SECOND)
-- 
2.14.2


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

* [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (3 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:05   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 06/18] hugeshmget02: add missing SHM_HUGETLB flag on segment creation Punit Agrawal
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>

The test tries to allocate 2 * (half the number of available hugepages).
If we have odd number hugepages, the calculated allocation size is not
page-aligned and allocation fails.

e.g, (use -s option to trigger it manually)

$ hugeshmctl02 -s 7 -i 5
hugeshmctl02    0  TINFO  :  set nr_hugepages to 7
hugeshmctl02    1  TBROK  :  hugeshmctl02.c:153: shmget #2: errno=ENOMEM(12): Cannot allocate memory
hugeshmctl02    2  TBROK  :  hugeshmctl02.c:153: Remaining cases broken
hugeshmctl02    0  TINFO  :  set nr_hugepages to 0

Align the size to hugepage_size.

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
index 6079d9937..82964a327 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
@@ -101,7 +101,7 @@ static void setup(void)
 	set_sys_tune("nr_hugepages", hugepages, 1);
 	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
-	shm_size = hpage_size * hugepages / 2;
+	shm_size = hpage_size * (hugepages / 2);
 	update_shm_size(&shm_size);
 	shmkey = getipckey();
 
-- 
2.14.2


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

* [LTP] [PATCH 06/18] hugeshmget02: add missing SHM_HUGETLB flag on segment creation
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (4 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap Punit Agrawal
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

On test setup, hugeshmget02 detects the number of huge pages available
and uses that number to size a shared memory segment that is allocated
to carry out subsequent syscalls checks.

The setup() function detects the number of huge pages available so that
it can size the share memory segment to allocate with a reasonable size
value, but fails to pass the SHM_HUGETLB on shared memory segment
creation which defeats the whole purpose of detecting the available
number of huge pages before creating the segment.

This omission can result in test failures, eg:

hugeshmget02    0  TINFO  :  set nr_hugepages to 128
hugeshmget02    0  TINFO  :  Using 21 hugepages
hugeshmget02    1  TBROK  :  hugeshmget02.c:155: shmget #setup:
errno=ENOMEM(12): Cannot allocate memory
hugeshmget02    2  TBROK  :  hugeshmget02.c:155: Remaining cases broken
hugeshmget02    0  TINFO  :  set nr_hugepages to 0

This patch adds the missing SHM_HUGETLB flag to the shmget call in the
setup() function.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
index 7db8b4ede..0abd1aaf8 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
@@ -99,7 +99,8 @@ void setup(void)
 
 	shmkey = getipckey();
 	shmkey2 = shmkey + 1;
-	shm_id_1 = shmget(shmkey, shm_size, IPC_CREAT | IPC_EXCL | SHM_RW);
+	shm_id_1 = shmget(shmkey, shm_size,
+			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 	if (shm_id_1 == -1)
 		tst_brk(TBROK | TERRNO, "shmget #setup");
 }
-- 
2.14.2


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

* [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (5 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 06/18] hugeshmget02: add missing SHM_HUGETLB flag on segment creation Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:11   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/ Punit Agrawal
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

Attempting to map a wrapping region with mremap should fail (that's the
whole point of this test). Accept ENOMEM as well as EINVAL.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/mem/vma/vma03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/vma/vma03.c b/testcases/kernel/mem/vma/vma03.c
index 4b34ab0a0..5f231e5bb 100644
--- a/testcases/kernel/mem/vma/vma03.c
+++ b/testcases/kernel/mem/vma/vma03.c
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
 
 		remap = mremap(map, pgsz, 2 * pgsz, 0);
 		if (remap == MAP_FAILED) {
-			if (errno == EINVAL)
+			if (errno == EINVAL || errno == ENOMEM)
 				tst_resm(TPASS, "mremap failed as expected.");
 			else
 				tst_resm(TFAIL | TERRNO, "mremap");
-- 
2.14.2


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

* [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (6 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:07   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 09/18] kill05: fix race on getpwnam Punit Agrawal
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

runltp runs tests in the ${LTP_ROOT}/bin directory. If this is NFS
mounted, we can run into problems that need to use setgid. Fix this by
ensuring that creat08 creates directories in /tmp/

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/creat/creat08.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/creat/creat08.c b/testcases/kernel/syscalls/creat/creat08.c
index 284ae5f1a..bd8368e28 100644
--- a/testcases/kernel/syscalls/creat/creat08.c
+++ b/testcases/kernel/syscalls/creat/creat08.c
@@ -63,8 +63,8 @@ int local_flag;
 
 #define MODE_RWX        (S_IRWXU|S_IRWXG|S_IRWXO)
 #define MODE_SGID       (S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
-#define DIR_A_TEMP	"testdir.A.%d"
-#define DIR_B_TEMP	"testdir.B.%d"
+#define DIR_A_TEMP	"/tmp/testdir.A.%d"
+#define DIR_B_TEMP	"/tmp/testdir.B.%d"
 #define SETGID		"setgid"
 #define NOSETGID	"nosetgid"
 #define ROOT_SETGID	"root_setgid"
-- 
2.14.2


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

* [LTP] [PATCH 09/18] kill05: fix race on getpwnam
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (7 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/ Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 12:01   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 10/18] sigwaitinfo01: fix race between sending and dequeueing RT signals Punit Agrawal
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

Two threads doing getpwnam to a static struct in the library, sometimes
end up using the same UID. Fix this.

Reported-by: Tony Thompson <anthony.thompson@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/kill/kill05.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
index ccef5afd6..2ae046130 100644
--- a/testcases/kernel/syscalls/kill/kill05.c
+++ b/testcases/kernel/syscalls/kill/kill05.c
@@ -174,15 +174,16 @@ void do_master_child(char **av)
 		do_child();
 #endif
 	}
+
+	/* wait until child sets its euid (and has finished with the static getpwnam result struct) */
+	wait_for_flag(1);
+
 	ltpuser2 = SAFE_GETPWNAM(NULL, user2name);
 	if (setreuid(ltpuser2->pw_uid, ltpuser2->pw_uid) == -1) {
 		perror("seteuid failed");
 		exit(1);
 	}
 
-	/* wait until child sets its euid */
-	wait_for_flag(1);
-
 	TEST(kill(pid1, TEST_SIG));
 
 	/* signal the child that we're done */
-- 
2.14.2


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

* [LTP] [PATCH 10/18] sigwaitinfo01: fix race between sending and dequeueing RT signals
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (8 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 09/18] kill05: fix race on getpwnam Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase Punit Agrawal
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

Although RT signals are dequeued in order, there is a race where only
the higher signal may have been sent and will therefore be dequeued
first, leading to a false failure.

This patch waits on the signal sending tasks so that we can be sure both
of the signals have been sent before dequeuing them.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index 35acd67c4..16b5096b8 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -249,6 +249,7 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	sigset_t sigs, oldmask;
 	siginfo_t si;
 	pid_t child[2];
+	int status;
 
 	signo = SIGRTMIN + 1;
 
@@ -268,6 +269,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	child[0] = create_sig_proc(0, signo, 1);
 	child[1] = create_sig_proc(0, signo + 1, 1);
 
+	/* Ensure that the signals have been sent */
+	waitpid(child[0], &status, 0);
+	waitpid(child[1], &status, 0);
+
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
 			    && si.si_code == SI_USER
-- 
2.14.2


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

* [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (9 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 10/18] sigwaitinfo01: fix race between sending and dequeueing RT signals Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 12:12   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 12/18] inotify: fix inotify.h breakage Punit Agrawal
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

The bad_address2 testcase passes (void *)1 as a sigset pointer to the
sigwaitinfo syscall. Unsurprisingly, this segfaults in libc rather than
returning -1 (errno = EFAULT) as LTP expects.

This patch registers a SIGSEGV handler to catch any SEGV's generated by
the sigwaitinfo syscall and treat them as success.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index 16b5096b8..44aa849af 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -23,6 +23,8 @@
 #include "test.h"
 #include <errno.h>
 #include <signal.h>
+#include <sys/ucontext.h>
+#include <setjmp.h>
 #include "../utils/include_j_h.h"
 #include "../utils/common_j_h.c"
 #include <limits.h>
@@ -361,9 +363,36 @@ void test_bad_address(swi_func sigwaitinfo, int signo)
 	kill(child, SIGTERM);
 }
 
+sigjmp_buf jmpbuf;
+
+static void segv_handler(int signal, siginfo_t *info, struct ucontext *ut)
+{
+	if (signal == SIGSEGV)
+		longjmp(jmpbuf, 1);
+
+	fprintf(stderr, "caught unexpected signal - %d --- exiting\n", signal);
+	_exit(-1);
+}
+
 void test_bad_address2(swi_func sigwaitinfo, int signo)
 {
-	TEST(sigwaitinfo((void *)1, NULL, NULL));
+	struct sigaction sigptr, oldact;
+
+	sigptr.sa_sigaction = segv_handler;
+	sigfillset(&sigptr.sa_mask);
+	sigdelset(&sigptr.sa_mask, SIGSEGV);
+	sigptr.sa_flags = SA_SIGINFO;
+
+	SUCCEED_OR_DIE(sigaction, "sigaction failed", SIGSEGV, &sigptr, &oldact);
+
+	if (setjmp(jmpbuf) == 0) {
+		TEST(sigwaitinfo((void*)1, NULL, NULL));
+	} else {
+		TEST_RETURN = -1;
+		TEST_ERRNO = EFAULT;
+	}
+
+	SUCCEED_OR_DIE(sigaction, "sigaction failed", SIGSEGV, &oldact, NULL);
 	REPORT_SUCCESS(-1, EFAULT);
 }
 
-- 
2.14.2


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

* [LTP] [PATCH 12/18] inotify: fix inotify.h breakage
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (10 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 11:16   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 13/18] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE' Punit Agrawal
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Mark Rutland <mark.rutland@arm.com>

359980f68b: "rename syscall() macro to ltp_syscall()" renamed syscall()
to ltp_syscall, but didn't update all callers. This had the side effect
of making some callers refer to syscall.h's definition of syscall()
instead. This caused some tests to start failing unexpectedly.

This patch fixes up inotify.h to use ltp_syscall.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/inotify/inotify.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/inotify/inotify.h b/testcases/kernel/syscalls/inotify/inotify.h
index ac731bcb2..a364e1472 100644
--- a/testcases/kernel/syscalls/inotify/inotify.h
+++ b/testcases/kernel/syscalls/inotify/inotify.h
@@ -32,16 +32,16 @@
 
 #if __NR_inotify_init != __LTP__NR_INVALID_SYSCALL
 #define	myinotify_init() \
-	syscall(__NR_inotify_init)
+	ltp_syscall(__NR_inotify_init)
 #else
 #define	myinotify_init() \
-	syscall(__NR_inotify_init1, 0)
+	ltp_syscall(__NR_inotify_init1, 0)
 #endif
 
 #define	myinotify_add_watch(fd, pathname, mask)	\
-	syscall(__NR_inotify_add_watch, fd, pathname, mask)
+	ltp_syscall(__NR_inotify_add_watch, fd, pathname, mask)
 
 #define	myinotify_rm_watch(fd, wd) \
-	syscall(__NR_inotify_rm_watch, fd, wd)
+	ltp_syscall(__NR_inotify_rm_watch, fd, wd)
 
 #endif /* _INOTIFY_H */
-- 
2.14.2


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

* [LTP] [PATCH 13/18] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (11 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 12/18] inotify: fix inotify.h breakage Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox Punit Agrawal
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Will Deacon <will.deacon@arm.com>

When testing the MS_NOSUID mount flag, mount03 forgets to copy
setuid_test into the new filesystem. Instead it writes 'TEST FILE' into
a new file and attempts to execute it with S_ISUID. This fails, but not
for the reasons ltp expects.

Signed-off-by: Will Deacon <will.deacon@arm.com>
[Added commit message, changed to use tst_resource_copy()]
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/mount/mount03.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index bf78c797f..abdef80fd 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -261,8 +261,10 @@ int test_rwflag(int i, int cnt)
 	case 5:
 		/* Validate MS_NOSUID flag of mount call */
 
+		tst_resource_copy(__FILE__, __LINE__, cleanup, "setuid_test",
+				  path_name);
+
 		snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
-		SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");
 
 		SAFE_STAT(cleanup, file, &file_stat);
 
-- 
2.14.2


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

* [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (12 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 13/18] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE' Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-31 12:36   ` Cyril Hrubis
  2017-10-26 14:14 ` [LTP] [PATCH 15/18] getdtablesize01: Handle ENFILE errno Punit Agrawal
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: Mark Rutland <mark.rutland@arm.com>

The ioctl tests rely on stty to test if a tty is usable, and use the
long form "--file=" flag to tell stty which tty to test. Busybox doesn't
understand the long "--file=" flag, and this causes the LTP test harness
to skip tests:

> stty: invalid argument '--file=/dev/tty0'
> ioctl01_02    0  TINFO  :  Skipping ioctl01 with /dev/tty0

Luckily, both busybox stty and GNU stty understand the equivalent "-F"
flag. This patch makes LTP use this more common option.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/ioctl/test_ioctl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/test_ioctl b/testcases/kernel/syscalls/ioctl/test_ioctl
index 1151b55eb..923275433 100755
--- a/testcases/kernel/syscalls/ioctl/test_ioctl
+++ b/testcases/kernel/syscalls/ioctl/test_ioctl
@@ -26,7 +26,7 @@ export TST_COUNT=0
 has_tty()
 {
     if command -v stty >/dev/null 2>&1; then
-        stty --file=$1 > /dev/null
+        stty -F $1 > /dev/null
         if [ $? -ne 0 ]; then
             return 0
         fi
-- 
2.14.2


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

* [LTP] [PATCH 15/18] getdtablesize01: Handle ENFILE errno
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (13 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 16/18] perf_event_open: Handle absence of PMU gracefully Punit Agrawal
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>

getdtablesize01 testcase attempts to open RLIMIT_NOFILE-1 (Maximum open
files for a process) file descriptors. However if we hit an
ENFILE (system wide limit of maximum number of open files) we should
break the test, rather than failing. This is more relevant for runs on
VMs where the rootfs could be a 9p fs or any other emulated fs.

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 .../kernel/syscalls/getdtablesize/getdtablesize01.c     | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c b/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
index 7ee231adf..eecf44b18 100644
--- a/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
+++ b/testcases/kernel/syscalls/getdtablesize/getdtablesize01.c
@@ -54,7 +54,7 @@ int TST_TOTAL = 1;
 
 int main(void)
 {
-	int table_size, loop, fd, count = 0;
+	int table_size, loop, fd = 0, count = 0;
 	int max_val_opfiles;
 	struct rlimit rlp;
 
@@ -82,24 +82,27 @@ int main(void)
 		 "Checking Max num of files that can be opened by a process.Should be: RLIMIT_NOFILE - 1");
 	for (loop = 1; loop <= max_val_opfiles; loop++) {
 		fd = open("/etc/hosts", O_RDONLY);
+
+		if (fd == -1)
+			break;
+		count = fd;
 #ifdef DEBUG
 		printf("Opened file num %d\n", fd);
 #endif
-		if (fd == -1)
-			break;
-		else
-			count = fd;
 	}
 
 //Now the max files opened should be RLIMIT_NOFILE - 1 , why ? read getdtablesize man page
 
-	if (count > 0)
-		close(count);
 	if (count == (max_val_opfiles - 1))
 		tst_resm(TPASS, "%d = %d", count, (max_val_opfiles - 1));
+	else if (fd < 0 && errno == ENFILE)
+		tst_brkm(TBROK, cleanup, "Reached maximum number of open files for the system");
 	else
 		tst_resm(TFAIL, "%d != %d", count, (max_val_opfiles - 1));
 
+	if (count > 0)
+		close(count);
+
 	cleanup();
 	tst_exit();
 }
-- 
2.14.2


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

* [LTP] [PATCH 16/18] perf_event_open: Handle absence of PMU gracefully
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (14 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 15/18] getdtablesize01: Handle ENFILE errno Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 17/18] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 18/18] hotplug/cpu_hotplug: Remove bashism disown from kill_pid() Punit Agrawal
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>

The perf_event_open0{1,2} syscall tests fail for an absence of a
PMU (which returns ENODEV). Handle the return code gracefully as we
check for ENOENT.

Without the patch:

$ perf_event_open01
perf_event_open01    1  TFAIL  :  perf_event_open01.c:162: perf_event_open \
		failed unexpectedly: TEST_ERRNO=ENODEV(19): No such device

With the patch:

$ perf_event_open01
perf_event_open01    1  TCONF  :  perf_event_open01.c:159: perf_event_open for PERF_COUNT_HW_INSTRUCTIONS : No such device
perf_event_open01    2  TCONF  :  perf_event_open01.c:159: perf_event_open for PERF_COUNT_HW_CACHE_REFERENCES : No such device
perf_event_open01    3  TCONF  :  perf_event_open01.c:159: perf_event_open for PERF_COUNT_HW_CACHE_MISSES : No such device
perf_event_open01    4  TCONF  :  perf_event_open01.c:159: perf_event_open for PERF_COUNT_HW_BRANCH_INSTRUCTIONS : No such file or directory
perf_event_open01    5  TCONF  :  perf_event_open01.c:159: perf_event_open for PERF_COUNT_HW_BRANCH_MISSES : No such device
perf_event_open01    0  TINFO  :  read event counter succeeded, value: 833765520
perf_event_open01    6  TPASS  :  test PERF_TYPE_HARDWARE: PERF_COUNT_SW_CPU_CLOCK succeeded
perf_event_open01    0  TINFO  :  read event counter succeeded, value: 833967380
perf_event_open01    7  TPASS  :  test PERF_TYPE_HARDWARE: PERF_COUNT_SW_TASK_CLOCK succeeded

Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/syscalls/perf_event_open/perf_event_open01.c | 3 ++-
 testcases/kernel/syscalls/perf_event_open/perf_event_open02.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
index 5c814b60c..5568035d9 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
@@ -149,7 +149,8 @@ static void verify(struct test_case_t *tc)
 
 	TEST(perf_event_open(&pe, 0, -1, -1, 0));
 	if (TEST_RETURN == -1) {
-		if (TEST_ERRNO == ENOENT || TEST_ERRNO == EOPNOTSUPP) {
+		if (TEST_ERRNO == ENOENT || TEST_ERRNO == EOPNOTSUPP ||
+		    TEST_ERRNO == ENODEV) {
 			tst_resm(TCONF | TTERRNO,
 			         "perf_event_open for %s not supported",
 			         tc->config_name);
diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index 7d54cbd52..13a17948a 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -160,8 +160,8 @@ static int count_hardware_counters(void)
 	for (i = 0; i < MAX_CTRS; i++) {
 		fdarry[i] = perf_event_open(&hw_event, 0, -1, -1, 0);
 		if (fdarry[i] == -1) {
-			if (errno == ENOENT) {
-				tst_brkm(TCONF, cleanup,
+			if (errno == ENOENT || errno == ENODEV) {
+				tst_brkm(TCONF | TERRNO, cleanup,
 				         "PERF_COUNT_HW_INSTRUCTIONS not supported");
 			}
 			tst_brkm(TBROK | TERRNO, cleanup,
-- 
2.14.2


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

* [LTP] [PATCH 17/18] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (15 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 16/18] perf_event_open: Handle absence of PMU gracefully Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  2017-10-26 14:14 ` [LTP] [PATCH 18/18] hotplug/cpu_hotplug: Remove bashism disown from kill_pid() Punit Agrawal
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: James Morse <james.morse@arm.com>

When LTP is started over ssh, systemd will use cgroups to group all the
tasks started by this session. LTPs cpuhotplug04 will remove all but one
CPU as part of its test.

In the kernel cpuset_hotplug_workfn() is documented thus: "Non-root
cpusets are only affected by offlining". This means cpuhotplug04 will
cause all future tasks to only have one available CPU. cpuhotplug04
effectively looses those CPUs for all users until the next reboot.

This problem has been reported, and was fixed for the unified hierarchy
by be4c9dd7aee5 ("cpuset: enable onlined cpu/node in effective
masks"). Since v3.17, this behaviour could be selected by passing '-o
__DEVEL__sane_behavior' to the cgroup mount.  Linux v4.4 grouped all the
ABI breakage together into a new filesystem: cgroup2, removing the
__DEVEL__sane_behavior flag.

With v226 Systemd can be forced to use cgroup2 by passing
'systemd.unified_cgroup_hierarchy=1' on the kernel command line.

Ubuntu 15.04 ships with systemd v219.

LTP tests that online CPUs must test for the legacy cgroup hierarchy and
update the cpusets for all users/sessions. Add this code the
cpu_online() helper.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 .../cpu_hotplug/include/cpuhotplug_hotplug.sh      | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
index 9f856e554..35ec7c86b 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
@@ -58,6 +58,39 @@ set_affinity()
     return $?
 }
 
+# repopulate_cpusets()
+#
+# If the legacy cgroup hierarchy is in use, and cpuset is mounted, copy
+# the permitted cpus from the root group, which always has all available
+# cpus and memory, into the other hierarchy nodes. This prevents hotplug
+# tests from losing CPUs, and affecting the results of later tests.
+#
+CPUSET="/sys/fs/cgroup/cpuset"
+repopulate_cpusets()
+{
+	# Only if we have cpusets
+	if [ ! -d ${CPUSET} ] ; then
+		return;
+	fi
+
+	# And then only legacy cpusets
+	if grep --quiet "/sys/fs/cgroup/cpuset[ ]*cgroup2" /proc/mounts ; then
+		return;
+	fi
+
+	# Copy root cpus into system and user slices
+	cat ${CPUSET}/cpuset.cpus > ${CPUSET}/system.slice/cpuset.cpus
+	cat ${CPUSET}/cpuset.cpus > ${CPUSET}/user.slice/cpuset.cpus
+
+	# Fix each session of each user
+	for TUSER in ${CPUSET}/user.slice/user-*.slice ; do
+		cat ${CPUSET}/cpuset.cpus > ${TUSER}/cpuset.cpus
+		for SESSION in ${TUSER}/session-*.scope; do
+			cat ${CPUSET}/cpuset.cpus > ${SESSION}/cpuset.cpus
+		done
+	done
+}
+
 # online_cpu(CPU)
 #
 #  Onlines the given CPU.  Returns a true value if it was able
@@ -77,6 +110,9 @@ online_cpu()
 
     $TIME echo 1 > /sys/devices/system/cpu/cpu${CPU}/online
     RC=$?
+
+    repopulate_cpusets
+
     report_timing "Online cpu ${CPU}"
     return $RC
 }
-- 
2.14.2


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

* [LTP] [PATCH 18/18] hotplug/cpu_hotplug: Remove bashism disown from kill_pid()
  2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
                   ` (16 preceding siblings ...)
  2017-10-26 14:14 ` [LTP] [PATCH 17/18] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug Punit Agrawal
@ 2017-10-26 14:14 ` Punit Agrawal
  17 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-26 14:14 UTC (permalink / raw)
  To: ltp

From: James Morse <james.morse@arm.com>

disown is a bashism not present in dash. kill_pid() already sends the
process SIGKILL.

Remove the "disown" to allow running in shells that don't support
disown.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
---
 testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_testsuite.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_testsuite.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_testsuite.sh
index 2d0166cc6..7dd0ebaae 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_testsuite.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_testsuite.sh
@@ -74,7 +74,6 @@ pid_is_valid()
 kill_pid()
 {
     PID=$1
-    disown $PID
     kill -9 $PID > /dev/null 2>&1
 }
 
-- 
2.14.2


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

* [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib
  2017-10-26 14:14 ` [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib Punit Agrawal
@ 2017-10-31 10:53   ` Cyril Hrubis
  2017-10-31 12:45     ` Punit Agrawal
  0 siblings, 1 reply; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 10:53 UTC (permalink / raw)
  To: ltp

Hi!
> diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
> index c6d2016b7..f4a1a75d7 100644
> --- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
> +++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
> @@ -45,7 +45,6 @@
>   * from shmid_ds.ipc_perm.mode
>   */
>  #define MODE_MASK	0x01FF
> -#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
>  
>  key_t shmkey;			/* an IPC key generated by ftok() */

We should remove the check_hugepage() prototype from this header as
well, otherwise it's fine.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes
  2017-10-26 14:14 ` [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes Punit Agrawal
@ 2017-10-31 11:04   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:04 UTC (permalink / raw)
  To: ltp

Hi!
> hugeshmctl01 spawns child processes to perform shm operations and uses
> signal (SIGUSR1) to communicate the completion of test 1, to the
> children waiting at sigprocmask(). However, there is no guarantee that a
> child has reached sigprocmask() before the parent issues a SIGUSR1 and
> things go wrong.
> 
> This patch fixes this issue by 'stopping' the children, waiting for all
> of them and then issuing SIGCONT to communicate the completion.
> 
> While we are at it, also handle unknown signals as a hint to exit the
> test with TBROK.

We do have a checkpoint synchronization primitives in the test library
exactly for this kind of synchronization. Can you, pretty please, use
them instead?

https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#229-fork-and-parent-child-synchronization

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process
  2017-10-26 14:14 ` [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process Punit Agrawal
@ 2017-10-31 11:05   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:05 UTC (permalink / raw)
  To: ltp

Hi!
> +		/* Wait for the child to exit */
> +		if (waitpid(pid_arr[i], &status, 0) != pid_arr[i] &&
> +			!WIFEXITED(status))

Please use SAFE_WAITPID() here, otherwise it's fine.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages
  2017-10-26 14:14 ` [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages Punit Agrawal
@ 2017-10-31 11:05   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:05 UTC (permalink / raw)
  To: ltp

Hi!
> The test tries to allocate 2 * (half the number of available hugepages).
> If we have odd number hugepages, the calculated allocation size is not
> page-aligned and allocation fails.
> 
> e.g, (use -s option to trigger it manually)
> 
> $ hugeshmctl02 -s 7 -i 5
> hugeshmctl02    0  TINFO  :  set nr_hugepages to 7
> hugeshmctl02    1  TBROK  :  hugeshmctl02.c:153: shmget #2: errno=ENOMEM(12): Cannot allocate memory
> hugeshmctl02    2  TBROK  :  hugeshmctl02.c:153: Remaining cases broken
> hugeshmctl02    0  TINFO  :  set nr_hugepages to 0
> 
> Align the size to hugepage_size.

This one is obviously OK.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/
  2017-10-26 14:14 ` [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/ Punit Agrawal
@ 2017-10-31 11:07   ` Cyril Hrubis
  2017-10-31 12:46     ` Punit Agrawal
  0 siblings, 1 reply; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:07 UTC (permalink / raw)
  To: ltp

Hi!
> runltp runs tests in the ${LTP_ROOT}/bin directory. If this is NFS
> mounted, we can run into problems that need to use setgid. Fix this by
> ensuring that creat08 creates directories in /tmp/

The test setup calls tst_tmpdir() which creates temporary directory in
/tmp/ and changes $PWD to point into it. So these directories has to be
created in /tmp/. If that is not the case something is wrong with the
test.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap
  2017-10-26 14:14 ` [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap Punit Agrawal
@ 2017-10-31 11:11   ` Cyril Hrubis
  2017-11-14 13:10     ` Punit Agrawal
  0 siblings, 1 reply; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:11 UTC (permalink / raw)
  To: ltp

Hi!
> Attempting to map a wrapping region with mremap should fail (that's the
> whole point of this test). Accept ENOMEM as well as EINVAL.

I'm missing any background info here about the specific conditions where
this happens. The test is supposed to run only on 32bit kernel, so I
suppose that there is some older board with 32bit ARM that is able to
execute this test and that we get a different errno there, but that is
only speculation. Can you, pretty please, elaborate more on that?

> Signed-off-by: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
> ---
>  testcases/kernel/mem/vma/vma03.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/mem/vma/vma03.c b/testcases/kernel/mem/vma/vma03.c
> index 4b34ab0a0..5f231e5bb 100644
> --- a/testcases/kernel/mem/vma/vma03.c
> +++ b/testcases/kernel/mem/vma/vma03.c
> @@ -100,7 +100,7 @@ int main(int argc, char *argv[])
>  
>  		remap = mremap(map, pgsz, 2 * pgsz, 0);
>  		if (remap == MAP_FAILED) {
> -			if (errno == EINVAL)
> +			if (errno == EINVAL || errno == ENOMEM)
>  				tst_resm(TPASS, "mremap failed as expected.");
>  			else
>  				tst_resm(TFAIL | TERRNO, "mremap");
> -- 
> 2.14.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 12/18] inotify: fix inotify.h breakage
  2017-10-26 14:14 ` [LTP] [PATCH 12/18] inotify: fix inotify.h breakage Punit Agrawal
@ 2017-10-31 11:16   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 11:16 UTC (permalink / raw)
  To: ltp

Hi!
Good catch, applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 09/18] kill05: fix race on getpwnam
  2017-10-26 14:14 ` [LTP] [PATCH 09/18] kill05: fix race on getpwnam Punit Agrawal
@ 2017-10-31 12:01   ` Cyril Hrubis
  2017-11-14 13:11     ` Punit Agrawal
  0 siblings, 1 reply; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 12:01 UTC (permalink / raw)
  To: ltp

Hi!
> Two threads doing getpwnam to a static struct in the library, sometimes
> end up using the same UID. Fix this.

Hmm these getpwnam() calls are done from different processes, so I
suppose that this happens on uClinux, or do I miss something?

Also we should move these calls to the test setup anyways.

> Reported-by: Tony Thompson <anthony.thompson@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
> ---
>  testcases/kernel/syscalls/kill/kill05.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
> index ccef5afd6..2ae046130 100644
> --- a/testcases/kernel/syscalls/kill/kill05.c
> +++ b/testcases/kernel/syscalls/kill/kill05.c
> @@ -174,15 +174,16 @@ void do_master_child(char **av)
>  		do_child();
>  #endif
>  	}
> +
> +	/* wait until child sets its euid (and has finished with the static getpwnam result struct) */
> +	wait_for_flag(1);
> +
>  	ltpuser2 = SAFE_GETPWNAM(NULL, user2name);
>  	if (setreuid(ltpuser2->pw_uid, ltpuser2->pw_uid) == -1) {
>  		perror("seteuid failed");
>  		exit(1);
>  	}
>  
> -	/* wait until child sets its euid */
> -	wait_for_flag(1);
> -
>  	TEST(kill(pid1, TEST_SIG));
>  
>  	/* signal the child that we're done */
> -- 
> 2.14.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase
  2017-10-26 14:14 ` [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase Punit Agrawal
@ 2017-10-31 12:12   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 12:12 UTC (permalink / raw)
  To: ltp

Hi!
> The bad_address2 testcase passes (void *)1 as a sigset pointer to the
> sigwaitinfo syscall. Unsurprisingly, this segfaults in libc rather than
> returning -1 (errno = EFAULT) as LTP expects.
> 
> This patch registers a SIGSEGV handler to catch any SEGV's generated by
> the sigwaitinfo syscall and treat them as success.

Can we, pretty please, rather run the test in a child process and catch
the SEGFAULT using the waitpid()?

The whole longjmp() stuff is overcomplicated solution for the problem.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox
  2017-10-26 14:14 ` [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox Punit Agrawal
@ 2017-10-31 12:36   ` Cyril Hrubis
  0 siblings, 0 replies; 33+ messages in thread
From: Cyril Hrubis @ 2017-10-31 12:36 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib
  2017-10-31 10:53   ` Cyril Hrubis
@ 2017-10-31 12:45     ` Punit Agrawal
  0 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-31 12:45 UTC (permalink / raw)
  To: ltp

Hi Cyril,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
>> index c6d2016b7..f4a1a75d7 100644
>> --- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
>> +++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
>> @@ -45,7 +45,6 @@
>>   * from shmid_ds.ipc_perm.mode
>>   */
>>  #define MODE_MASK	0x01FF
>> -#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
>>  
>>  key_t shmkey;			/* an IPC key generated by ftok() */
>
> We should remove the check_hugepage() prototype from this header as
> well, otherwise it's fine.

Fixed locally.

Thanks for reviewing the patches (hopefully you can reach the end of the
series :) ). Some of your suggestions are straight forward but others
will take some time.

I am about to disappear for a few days and will aim to act on your
suggestions once I'm back.

Thanks,
Punit

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

* [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/
  2017-10-31 11:07   ` Cyril Hrubis
@ 2017-10-31 12:46     ` Punit Agrawal
  0 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-10-31 12:46 UTC (permalink / raw)
  To: ltp

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> runltp runs tests in the ${LTP_ROOT}/bin directory. If this is NFS
>> mounted, we can run into problems that need to use setgid. Fix this by
>> ensuring that creat08 creates directories in /tmp/
>
> The test setup calls tst_tmpdir() which creates temporary directory in
> /tmp/ and changes $PWD to point into it. So these directories has to be
> created in /tmp/. If that is not the case something is wrong with the
> test.

Hah.. it looks like we are carrying this one around since before
tst_tmpdir() was used. Another reason to try and track upstream as
closely as we can.

I'll drop this from the next version after confirming that it is no
longer needed.

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

* [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap
  2017-10-31 11:11   ` Cyril Hrubis
@ 2017-11-14 13:10     ` Punit Agrawal
  0 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-11-14 13:10 UTC (permalink / raw)
  To: ltp

Hi Cyril,

Picking up where I'd left off after the previous posting.

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> Attempting to map a wrapping region with mremap should fail (that's the
>> whole point of this test). Accept ENOMEM as well as EINVAL.
>
> I'm missing any background info here about the specific conditions where
> this happens. The test is supposed to run only on 32bit kernel, so I
> suppose that there is some older board with 32bit ARM that is able to
> execute this test and that we get a different errno there, but that is
> only speculation. Can you, pretty please, elaborate more on that?

After digging into the patch history I've failed to find an explanation
for why we are carrying the patch. Looks like the details of the issue
it was fixing have been lost.

The unpatched version of the test passes on TC2 (a 32bit big.LITTLE ARM
Platform).

I'll drop this patch from the next version.

Thanks,
Punit

>
>> Signed-off-by: Will Deacon <will.deacon@arm.com>
>> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
>> ---
>>  testcases/kernel/mem/vma/vma03.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/testcases/kernel/mem/vma/vma03.c b/testcases/kernel/mem/vma/vma03.c
>> index 4b34ab0a0..5f231e5bb 100644
>> --- a/testcases/kernel/mem/vma/vma03.c
>> +++ b/testcases/kernel/mem/vma/vma03.c
>> @@ -100,7 +100,7 @@ int main(int argc, char *argv[])
>>  
>>  		remap = mremap(map, pgsz, 2 * pgsz, 0);
>>  		if (remap == MAP_FAILED) {
>> -			if (errno == EINVAL)
>> +			if (errno == EINVAL || errno == ENOMEM)
>>  				tst_resm(TPASS, "mremap failed as expected.");
>>  			else
>>  				tst_resm(TFAIL | TERRNO, "mremap");
>> -- 
>> 2.14.2
>> 
>> 
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 09/18] kill05: fix race on getpwnam
  2017-10-31 12:01   ` Cyril Hrubis
@ 2017-11-14 13:11     ` Punit Agrawal
  0 siblings, 0 replies; 33+ messages in thread
From: Punit Agrawal @ 2017-11-14 13:11 UTC (permalink / raw)
  To: ltp

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> Two threads doing getpwnam to a static struct in the library, sometimes
>> end up using the same UID. Fix this.
>
> Hmm these getpwnam() calls are done from different processes, so I
> suppose that this happens on uClinux, or do I miss something?

This is another patch we've been carrying for long enough to have lost
context around it's origin.

I don't see a reasonable explanation for why the change makes sense,
especially as it was done on a non-uClinux stack.

I'll drop this patch from the next posting.

>
> Also we should move these calls to the test setup anyways.
>
>> Reported-by: Tony Thompson <anthony.thompson@arm.com>
>> Signed-off-by: Will Deacon <will.deacon@arm.com>
>> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
>> ---
>>  testcases/kernel/syscalls/kill/kill05.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>> 
>> diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
>> index ccef5afd6..2ae046130 100644
>> --- a/testcases/kernel/syscalls/kill/kill05.c
>> +++ b/testcases/kernel/syscalls/kill/kill05.c
>> @@ -174,15 +174,16 @@ void do_master_child(char **av)
>>  		do_child();
>>  #endif
>>  	}
>> +
>> +	/* wait until child sets its euid (and has finished with the static getpwnam result struct) */
>> +	wait_for_flag(1);
>> +
>>  	ltpuser2 = SAFE_GETPWNAM(NULL, user2name);
>>  	if (setreuid(ltpuser2->pw_uid, ltpuser2->pw_uid) == -1) {
>>  		perror("seteuid failed");
>>  		exit(1);
>>  	}
>>  
>> -	/* wait until child sets its euid */
>> -	wait_for_flag(1);
>> -
>>  	TEST(kill(pid1, TEST_SIG));
>>  
>>  	/* signal the child that we're done */
>> -- 
>> 2.14.2
>> 
>> 
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2017-11-14 13:11 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 14:14 [LTP] [PATCH 00/18] Collection of fixes Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 01/18] Move check_hugepage() helper to mem/lib Punit Agrawal
2017-10-31 10:53   ` Cyril Hrubis
2017-10-31 12:45     ` Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 02/18] thp: ensure THP/hugetlbfs is available Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 03/18] hugeshmctl01: Fix synchronisation with child processes Punit Agrawal
2017-10-31 11:04   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 04/18] hugeshmctl01: Fix synchronization issue in parent process Punit Agrawal
2017-10-31 11:05   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 05/18] hugeshmctl02: Fix allocation size for odd number of hugepages Punit Agrawal
2017-10-31 11:05   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 06/18] hugeshmget02: add missing SHM_HUGETLB flag on segment creation Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 07/18] vma03: accept ENOMEM return value from mremap Punit Agrawal
2017-10-31 11:11   ` Cyril Hrubis
2017-11-14 13:10     ` Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 08/18] creat08: ensure test directories are created in /tmp/ Punit Agrawal
2017-10-31 11:07   ` Cyril Hrubis
2017-10-31 12:46     ` Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 09/18] kill05: fix race on getpwnam Punit Agrawal
2017-10-31 12:01   ` Cyril Hrubis
2017-11-14 13:11     ` Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 10/18] sigwaitinfo01: fix race between sending and dequeueing RT signals Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 11/18] sigwaitinfo: catch SEGV and report success for bad_address2 testcase Punit Agrawal
2017-10-31 12:12   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 12/18] inotify: fix inotify.h breakage Punit Agrawal
2017-10-31 11:16   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 13/18] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE' Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 14/18] ioctl: fix stty usage for busybox Punit Agrawal
2017-10-31 12:36   ` Cyril Hrubis
2017-10-26 14:14 ` [LTP] [PATCH 15/18] getdtablesize01: Handle ENFILE errno Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 16/18] perf_event_open: Handle absence of PMU gracefully Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 17/18] hotplug/cpu_hotplug: Repopulate cgroup:cpusets after testing hotplug Punit Agrawal
2017-10-26 14:14 ` [LTP] [PATCH 18/18] hotplug/cpu_hotplug: Remove bashism disown from kill_pid() Punit Agrawal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.