public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH ltp] syscalls/munlockall02: fix the outdated TCONF message
  2018-08-28 15:52 [LTP] [PATCH ltp] syscalls/munlockall02: fix the outdated TCONF message Junchi Chen
@ 2018-08-28 13:35 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2018-08-28 13:35 UTC (permalink / raw)
  To: ltp

Hi!
Given that 2.6.11 is quite old, 13 years to be exact I would be in favor
for dropping this particular EPERM test completely.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH ltp] syscalls/munlockall02: fix the outdated TCONF message
@ 2018-08-28 15:52 Junchi Chen
  2018-08-28 13:35 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Junchi Chen @ 2018-08-28 15:52 UTC (permalink / raw)
  To: ltp

ISSUE:
  This TCONF message: "Some distros... support
   non-superuser munlockall calls."
   has unnecessarily shown for years.

REASON:
  EPERM is the error expected, which, by man page, is occurring due
   to the lack of privilege (CAP_IPC_LOCK).
   The intersection of munlockall syscall and CAP_IPC_LOCK macro is only
   in /mm/mlock.c file.

  From v2.6, in /mm/mlock.c, there are no privilege check when using
   munlockall syscall.
   - For older version, the execution of do_mlockall()
   with flag 0 is done right after the request for the semlock.
   By comparison, mlockall syscall checked via capable(CAP_IPC_LOCK)
   before do_mlockall() with flags.
   - For newer version, apply_mlockall_flags()
   substituted do_mlockall(), but nothing changed regarding privilege check.

ACTION:
  Add tst_kvercmp() to test kernel version.

Signed-off-by: Junchi Chen <junchi.chen@intel.com>
---
 .../kernel/syscalls/munlockall/munlockall02.c | 30 ++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/munlockall/munlockall02.c b/testcases/kernel/syscalls/munlockall/munlockall02.c
index f97905473..2e2695c52 100644
--- a/testcases/kernel/syscalls/munlockall/munlockall02.c
+++ b/testcases/kernel/syscalls/munlockall/munlockall02.c
@@ -48,6 +48,8 @@
  *	 otherwise,
  *	  Issue sys call fails with unexpected errno.
  *
+ *	 Since V2.6.11, the mainline kernel support none-superuser
+ *	  munlockall calls. So the test pass with a success.
  *
  * 	Cleanup:
  *      change effective user id to root
@@ -69,6 +71,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <sys/mman.h>
+#include "tst_kvercmp.h"
 #include "test.h"
 #include "safe_macros.h"
 
@@ -98,14 +101,27 @@ int main(int ac, char **av)
 
 		TEST(munlockall());
 		/* check return code */
-		if ((TEST_RETURN == -1) && (TEST_ERRNO == EPERM)) {
-			tst_resm(TPASS, "munlockall() failed"
-				 " as expected for non-superuser" ":GOT EPERM");
+		if (tst_kvercmp(2, 6, 11) < 0) {
+			if ((TEST_RETURN == -1) && (TEST_ERRNO == EPERM)) {
+				tst_resm(TPASS, "munlockall() failed"
+						" as expected for non-superuser"
+						":GOT EPERM");
+			} else {
+				tst_resm(TCONF, "munlockall() failed to produce "
+						"expected errno :%d Got : %d, %s. ***Some distros, "
+						"such as Red Hat Enterprise Linux, support "
+						"non-superuser munlockall calls.***",
+						EPERM, TEST_ERRNO, strerror(TEST_ERRNO));
+			}
 		} else {
-			tst_resm(TCONF, "munlockall() failed to produce "
-				 "expected errno :%d Got : %d, %s. ***Some distros, such as Red Hat Enterprise Linux, support non-superuser munlockall calls.***",
-				 EPERM, TEST_ERRNO, strerror(TEST_ERRNO));
-
+			if (TEST_RETURN == 0) {
+				tst_resm(TPASS, "munlockall() succeeded"
+						" as expected for non-superuser");
+			} else {
+				tst_resm(TFAIL, "munlockall() failed to run"
+						" as non-superuser, Got : %d, %s.",
+						TEST_ERRNO, strerror(TEST_ERRNO));
+			}
 		}
 	}
 
-- 
2.17.1


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

end of thread, other threads:[~2018-08-28 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-28 15:52 [LTP] [PATCH ltp] syscalls/munlockall02: fix the outdated TCONF message Junchi Chen
2018-08-28 13:35 ` Cyril Hrubis

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