Skip to contentSkip to conversation

syscalls/kill11, abort01: Also raise hard limit when possible

PATCH New Yang Xu 3 participants 4 messages Feb 13, 2020 – Feb 14, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH v2 1/2 syscalls/kill11, abort01: Also raise hard limit when possible

Currently, running this two cases will report EINVAL error if I run "ulimit -c 1023" command firstly. From setrlimit(2)manpage, it got EINVAL error because rlim->rlim_cur was greater than rlim->rlim_max. So raise the limit when possible.

---
 testcases/kernel/syscalls/abort/abort01.c | 9 +++++++++
 testcases/kernel/syscalls/kill/kill11.c   | 8 ++++++++
 2 files changed, 17 insertions(+)
testcases/kernel/syscalls/abort/abort01.c +9 -0
index 386a22f26..6fde3721c 100644
@@ -70,6 +70,15 @@ static void setup(void)
 
 	/* make sure we get core dumps */
 	SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
+
+	if (rlim.rlim_max < MIN_RLIMIT_CORE) {
+		if (geteuid() != 0) {
+			tst_brk(TCONF, "hard limit(%lu)less than MIN_RLIMT_CORE(%i)",
+				rlim.rlim_max, MIN_RLIMIT_CORE);
+		}
+		tst_res(TINFO, "Raising rlim_max to %i", MIN_RLIMIT_CORE);
+		rlim.rlim_max = MIN_RLIMIT_CORE;
+	}
 	if (rlim.rlim_cur < MIN_RLIMIT_CORE) {
 		rlim.rlim_cur = MIN_RLIMIT_CORE;
 		SAFE_SETRLIMIT(RLIMIT_CORE, &rlim);
testcases/kernel/syscalls/kill/kill11.c +8 -0
index 83fba5beb..4025fcc87 100644
@@ -201,6 +201,14 @@ void setup(void)
 
 	SAFE_GETRLIMIT(NULL, RLIMIT_CORE, &rlim);
 
+	if (rlim.rlim_max < MIN_RLIMIT_CORE) {
+		if (geteuid() != 0) {
+			tst_brkm(TCONF, NULL, "hard limit(%lu)less than MIN_RLIMT_CORE(%i)",
+				rlim.rlim_max, MIN_RLIMIT_CORE);
+		}
+		tst_resm(TINFO, "Raising rlim_max to %i", MIN_RLIMIT_CORE);
+		rlim.rlim_max = MIN_RLIMIT_CORE;
+	}
 	if (rlim.rlim_cur < MIN_RLIMIT_CORE) {
 		tst_resm(TINFO, "Adjusting RLIMIT_CORE to %i", MIN_RLIMIT_CORE);
 		rlim.rlim_cur = MIN_RLIMIT_CORE;
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v2 2/2 syscalls/kill11, abort01: lower MIN_RLIMIT_CORE size

From ulimit manpage, ulimit -c options used 512-bytes-block in posix mode and used 1024-bytes-block in common mode. Usually, this case used "ulimit
-c 1024" to test, but it will report TCONF in posix mode under unprivileged user.
Since these two cases only check correct signal, lower this size doesn't affect this result. This also can avoid github issue(640[1],83[2]).

[1]https://github.com/linux-test-project/ltp/issues/640 [2]https://github.com/linux-test-project/ltp/issues/83

---
 testcases/kernel/syscalls/abort/abort01.c | 2 +-
 testcases/kernel/syscalls/kill/kill11.c   | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/abort/abort01.c +1 -1
index 6fde3721c..9505a5eec 100644
@@ -62,7 +62,7 @@ void verify_abort(void)
 		tst_res(TFAIL, "abort() raised %s", tst_strsig(sig));
 }
 
-#define MIN_RLIMIT_CORE (1024 * 1024)
+#define MIN_RLIMIT_CORE (512 * 1024)
 
 static void setup(void)
 {
testcases/kernel/syscalls/kill/kill11.c +1 -2
index 4025fcc87..9b81e0095 100644
@@ -192,8 +192,7 @@ void do_child(void)
 	exit(1);
 }
 
-/* 1024 GNU blocks */
-#define MIN_RLIMIT_CORE (1024 * 1024)
+#define MIN_RLIMIT_CORE (512 * 1024)
 
 void setup(void)
 {
Signature · 1 line
2.18.0
#2 lore raw

PATCH v2 2/2 syscalls/kill11, abort01: lower MIN_RLIMIT_CORE size

----- Original Message -----

Quoted 8 lines

From ulimit manpage, ulimit -c options used 512-bytes-block in posix mode and used 1024-bytes-block in common mode. Usually, this case used "ulimit
-c 1024" to test, but it will report TCONF in posix mode under unprivileged user.
Since these two cases only check correct signal, lower this size doesn't affect
this result. This also can avoid github issue(640[1],83[2]).

Quoted 4 lines

[1]https://github.com/linux-test-project/ltp/issues/640 [2]https://github.com/linux-test-project/ltp/issues/83

both look good to me, ack

#3 lore raw

PATCH v2 2/2 syscalls/kill11, abort01: lower MIN_RLIMIT_CORE size

Quoted 12 lines · Jan Stancek

----- Original Message -----

Quoted 3 lines

From ulimit manpage, ulimit -c options used 512-bytes-block in posix mode and used 1024-bytes-block in common mode. Usually, this case used "ulimit
-c 1024" to test, but it will report TCONF in posix mode under

unprivileged

Quoted 5 lines

user.
Since these two cases only check correct signal, lower this size doesn't affect
this result. This also can avoid github issue(640[1],83[2]).

Quoted 7 lines
Quoted 4 lines

[1]https://github.com/linux-test-project/ltp/issues/640 [2]https://github.com/linux-test-project/ltp/issues/83

both look good to me, ack

Tested and pushed. Thanks!

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200214/c4d5764b/attachment.htm>