[LTP] [PATCH v2 2/4] syscalls/mprotect01: Invoke the syscall directly instead of the libc wrapper
Tudor Cretu
tudor.cretu@arm.com
Mon Aug 22 13:39:17 CEST 2022
per POSIX: The mprotect() function shall change the access protections
to be that specified by prot for those whole pages containing any part
of the address space of the process starting at address addr and
continuing for len bytes.
Issue 6 of POSIX introduces: The implementation may require that addr
be a multiple of the page size as returned by sysconf().
Therefore it's not strictly required that addr is a multiple of the page
size. Some libcs (e.g. Musl) indeed don't have this requirement, so calling
the C standard library function doesn't fail in their case. As the
testsuite focuses on mprotect(2), the testcases should call the syscall
directly instead of the libc function.
Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
---
testcases/kernel/syscalls/mprotect/mprotect01.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/mprotect/mprotect01.c b/testcases/kernel/syscalls/mprotect/mprotect01.c
index be4d982ea..aa4685258 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect01.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect01.c
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <unistd.h>
#include "test.h"
+#include "lapi/syscalls.h"
#include "safe_macros.h"
char *TCID = "mprotect01";
@@ -97,7 +98,7 @@ int main(int ac, char **av)
if (TC[i].setupfunc != NULL)
TC[i].setupfunc(&TC[i]);
- TEST(mprotect(TC[i].addr, TC[i].len, TC[i].prot));
+ TEST(tst_syscall(__NR_mprotect, TC[i].addr, TC[i].len, TC[i].prot));
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "call succeeded unexpectedly");
--
2.25.1
More information about the ltp
mailing list