syscalls/munlockall02: fix the outdated TCONF message
PATCH 1/1 syscalls/munlockall02: fix the outdated TCONF message
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.
--- .../kernel/syscalls/munlockall/munlockall02.c | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/munlockall/munlockall02.c +23 -7
@@ -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 )); + } } }
Signature · 1 line
2.17.1
PATCH 1/1 syscalls/munlockall02: fix the outdated TCONF message
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.
Signature · 2 lines
Cyril Hrubis [email protected]