lapi/syscalls: Add syscall numbers for mlock2
PATCH 1/4 lapi/syscalls: Add syscall numbers for mlock2
--- include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + 13 files changed, 13 insertions(+)
include/lapi/syscalls/aarch64.in +1 -0
@@ -256,5 +256,6 @@ sendmmsg 269 kcmp 272 getrandom 278 memfd_create 279 +mlock2 284 copy_file_range 285 _sysctl 1078
include/lapi/syscalls/arm.in +1 -0
@@ -341,4 +341,5 @@ renameat2 (__NR_SYSCALL_BASE+382) getrandom (__NR_SYSCALL_BASE+384) memfd_create (__NR_SYSCALL_BASE+385) execveat (__NR_SYSCALL_BASE+387) +mlock2 (__NR_SYSCALL_BASE+390) copy_file_range (__NR_SYSCALL_BASE+391)
include/lapi/syscalls/hppa.in +1 -0
@@ -17,4 +17,5 @@ splice 291 tee 293 vmsplice 294 memfd_create 340 +mlock2 345 copy_file_range 346
include/lapi/syscalls/i386.in +1 -0
@@ -341,4 +341,5 @@ renameat2 354 getrandom 355 memfd_create 356 execveat 358 +mlock2 376 copy_file_range 377
include/lapi/syscalls/ia64.in +1 -0
@@ -296,4 +296,5 @@ prlimit64 1325 renameat2 1338 getrandom 1339 memfd_create 1340 +mlock2 1346 copy_file_range 1347
include/lapi/syscalls/powerpc.in +1 -0
@@ -347,4 +347,5 @@ sched_getattr 356 renameat2 357 getrandom 359 memfd_create 360 +mlock2 378 copy_file_range 379
include/lapi/syscalls/powerpc64.in +1 -0
@@ -347,4 +347,5 @@ sched_getattr 356 renameat2 357 getrandom 359 memfd_create 360 +mlock2 378 copy_file_range 379
include/lapi/syscalls/s390.in +1 -0
@@ -332,4 +332,5 @@ renameat2 347 getrandom 349 memfd_create 350 execveat 354 +mlock2 374 copy_file_range 375
include/lapi/syscalls/s390x.in +1 -0
@@ -331,4 +331,5 @@ sched_getattr 346 renameat2 347 getrandom 349 memfd_create 350 +mlock2 374 copy_file_range 375
include/lapi/syscalls/sh.in +1 -0
@@ -364,4 +364,5 @@ fanotify_mark 368 prlimit64 369 kcmp 378 memfd_create 385 +mlock2 390 copy_file_range 391
include/lapi/syscalls/sparc.in +1 -0
@@ -336,4 +336,5 @@ kcmp 341 renameat2 345 getrandom 347 memfd_create 348 +mlock2 356 copy_file_range 357
include/lapi/syscalls/sparc64.in +1 -0
@@ -312,4 +312,5 @@ kcmp 341 renameat2 345 getrandom 347 memfd_create 348 +mlock2 356 copy_file_range 357
include/lapi/syscalls/x86_64.in +1 -0
@@ -308,4 +308,5 @@ renameat2 316 getrandom 318 memfd_create 319 execveat 322 +mlock2 325 copy_file_range 326
Signature · 1 line
1.8.3.1
PATCH 2/4 safe_macros: Add SAFE_MLOCK() and SAFE_MUNLOCK() macros
--- include/tst_safe_macros.h | 8 ++++++++ lib/safe_macros.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/tst_safe_macros.h +8 -0
@@ -482,6 +482,14 @@ int safe_mknod(const char *file, const int lineno, const char *pathname,#define SAFE_MKNOD (pathname, mode, dev) \ safe_mknod(__FILE__, __LINE__, (pathname), (mode), (dev)) +int safe_mlock (const char *file,const int lineno,const char *addr, +size_t len); +#define SAFE_MLOCK (addr, len) safe_mlock(__FILE__, __LINE__, (addr), (len)) + +int safe_munlock (const char *file,const int lineno,const char *addr, +size_t len); +#define SAFE_MUNLOCK (addr, len) safe_munlock(__FILE__, __LINE__, (addr), (len)) +int safe_fanotify_init (const char *file,const int lineno,unsigned int flags,unsigned int event_f_flags);#define SAFE_FANOTIFY_INIT (fan, mode) \
lib/safe_macros.c +28 -0
@@ -1006,3 +1006,31 @@ int safe_mknod(const char *file, const int lineno, const char *pathname,return rval; } + +int safe_mlock (const char *file,const int lineno,const void *addr, +size_t len) +{ +int rval; + + rval =mlock (addr, len); +if (rval ==-1 ) { +tst_brkm (TBROK |TERRNO ,NULL , +"%s:%d: mlock() failed" , file, lineno); + } + +return rval; +} + +int safe_munlock (const char *file,const int lineno,const void *addr, +size_t len) +{ +int rval; + + rval =munlock (addr, len); +if (rval ==-1 ) { +tst_brkm (TBROK |TERRNO ,NULL , +"%s:%d: munlock() failed" , file, lineno); + } + +return rval; +}
Signature · 1 line
1.8.3.1
PATCH 2/4 safe_macros: Add SAFE_MLOCK() and SAFE_MUNLOCK() macros
----- Original Message -----
Quoted 5 lines
Signed-off-by Xiao Yang <[email protected]>--- include/tst_safe_macros.h | 8 ++++++++ lib/safe_macros.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
ACK
PATCH 3/4 syscalls/mlock201: Add new testcase
In reply to Xiao YangCheck the basic functionality of mlock2(2) since kernel v2.6.9.
--- include/lapi/mlock2.h | 16 +++++ runtest/ltplite | 2 + runtest/stress.part3 | 2 + runtest/syscalls | 2 + testcases/kernel/syscalls/mlock2/.gitignore | 1 + testcases/kernel/syscalls/mlock2/Makefile | 8 +++ testcases/kernel/syscalls/mlock2/mlock201.c | 103 ++++++++++++++++++++++++++++ 7 files changed, 134 insertions(+) create mode 100644 include/lapi/mlock2.h create mode 100644 testcases/kernel/syscalls/mlock2/.gitignore create mode 100644 testcases/kernel/syscalls/mlock2/Makefile create mode 100644 testcases/kernel/syscalls/mlock2/mlock201.c
include/lapi/mlock2.h new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +* Author: Xiao Yang <[email protected]> +*/ + +#ifndef LAPI_MLOCK2_H__ +# define LAPI_MLOCK2_H__ + +#include <linux/mman.h> + +#ifndef MLOCK_ONFAULT +# define MLOCK_ONFAULT 0x01 +#endif + +#endif /* LAPI_MLOCK2_H__ */
runtest/ltplite +2 -0
@@ -443,6 +443,8 @@ mknod09 mknod09 mlock01 mlock01 mlock02 mlock02 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
runtest/stress.part3 +2 -0
@@ -369,6 +369,8 @@ mknod09 mknod09 mlock01 mlock01 mlock02 mlock02 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
runtest/syscalls +2 -0
@@ -633,6 +633,8 @@ mlock02 mlock02 mlock03 mlock03 -i 20 mlock04 mlock04 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
testcases/kernel/syscalls/mlock2/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/mlock201
testcases/kernel/syscalls/mlock2/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +# Author: Xiao Yang <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/mlock2/mlock201.c new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/4 syscalls/mlock201: Add new testcase
----- Original Message -----
Quoted 4 lines
Check the basic functionality of mlock2(2) since kernel v2.6.9.
Signed-off-by Xiao Yang <[email protected]>
Quoted 8 lines
+ * Description:
+ * Check the basic functionality of the mlock2(2) since kernel v2.6.9:
+ * 1) Use mlock2(2) withoutMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshows correct size of memory that is locked by PID.
+ * 2) Use mlock2(2) withMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshow correct size of memory that is locked by PID.
Can we also check if MLOCK_ONFAULT doesn't make non-present pages present, but it still locks present pages? (mincore(2) or /proc/pid/pagemap)
Regards,
Jan
PATCH 3/4 syscalls/mlock201: Add new testcase
----- Original Message -----
Quoted 3 lines
----- Original Message -----
Quoted 1 line
Check the basic functionality of mlock2(2) since kernel v2.6.9.
Missed this one:
mlock2() is available since Linux 4.4.
Quoted 21 lines
Quoted 11 lines
Signed-off-by Xiao Yang <[email protected]>+ * Description:
+ * Check the basic functionality of the mlock2(2) since kernel v2.6.9:
+ * 1) Use mlock2(2) withoutMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshows correct size of memory that is locked by PID.
+ * 2) Use mlock2(2) withMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshow correct size of memory that is locked by PID.Can we also check if
MLOCK_ONFAULTdoesn't make non-present pages present, but it still locks present pages? (mincore(2) or/proc/pid/pagemap)Regards,
Jan--
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/4 syscalls/mlock201: Add new testcase
Quoted 5 lines · Jan Stancek
----- Original Message -----
Quoted 2 lines
----- Original Message -----
Quoted 1 line
Check the basic functionality of mlock2(2) since kernel v2.6.9.
Missed this one:
mlock2()is available since Linux 4.4.
Hi Jan,
Thanks for your review.
It seems that mlock2() has been backported by some distros(e.g. RHEL7.6), so i use tst_syscall()
instead of .min_kver to check if mlock2() is supported.
From mlock2() manpage:
Before Linux 2.6.8, a process must be privileged (CAP_IPC_LOCK) in order to lock memory and theRLIMIT_MEMLOCK soft resource limit defines a limit on how much memory the process may lock.
Since Linux 2.6.9, no limits are placed on the amount of memory that a privileged process can lock
and the RLIMIT_MEMLOCK soft resource limit instead defines a limit on how much memory an unprivileged\
process may lock.
I just check the behavior of mlock2() since Linux 2.6.9.
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Signed-off-by Xiao Yang<[email protected]>+ * Description:
+ * Check the basic functionality of the mlock2(2) since kernel v2.6.9:
+ * 1) Use mlock2(2) withoutMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshows correct size of memory that is locked by PID.
+ * 2) Use mlock2(2) withMLOCK_ONFAULTto lock memory in the specified
+ * range that is multiples of page size or not, and the VmLck from
+ */proc/PID/statusshow correct size of memory that is locked by PID.Can we also check if
MLOCK_ONFAULTdoesn't make non-present pages present, but it still locks present pages? (mincore(2) or/proc/pid/pagemap)
I will try to check this point as you suggested.
Thanks,
Xiao Yang
Quoted 8 lines
Quoted 6 lines
Regards,
Jan--
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/4 syscalls/mlock201: Add new testcase
In reply to Jan Stancek1) Add SAFE_MINCORE() macro
2) Check the basic functionality of mlock2(2).
Note:
1) We use tst_syscall() to check if mlock2() is supported.
2) since kernel v2.6.9, the limits and permissions of mlock2() changed, so we just check mlock2() since the version.
--- include/lapi/mlock2.h | 16 ++++ include/tst_safe_macros.h | 5 + lib/safe_macros.c | 14 +++ runtest/ltplite | 2 + runtest/stress.part3 | 2 + runtest/syscalls | 2 + testcases/kernel/syscalls/mlock2/.gitignore | 1 + testcases/kernel/syscalls/mlock2/Makefile | 8 ++ testcases/kernel/syscalls/mlock2/mlock201.c | 144 ++++++++++++++++++++++++++++ 9 files changed, 194 insertions(+) create mode 100644 include/lapi/mlock2.h create mode 100644 testcases/kernel/syscalls/mlock2/.gitignore create mode 100644 testcases/kernel/syscalls/mlock2/Makefile create mode 100644 testcases/kernel/syscalls/mlock2/mlock201.c
include/lapi/mlock2.h new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +* Author: Xiao Yang <[email protected]> +*/ + +#ifndef LAPI_MLOCK2_H__ +# define LAPI_MLOCK2_H__ + +#include <linux/mman.h> + +#ifndef MLOCK_ONFAULT +# define MLOCK_ONFAULT 0x01 +#endif + +#endif /* LAPI_MLOCK2_H__ */
include/tst_safe_macros.h +5 -0
@@ -490,6 +490,11 @@ int safe_munlock(const char *file, const int lineno, const char *addr, size_t len);#define SAFE_MUNLOCK (addr, len) safe_munlock(__FILE__, __LINE__, (addr), (len)) +int safe_mincore (const char *file,const int lineno,void *start, +size_t length,unsigned char *vec); +#define SAFE_MINCORE (start, length, vec) \ + safe_mincore(__FILE__, __LINE__, (start), (length), (vec)) +int safe_fanotify_init (const char *file,const int lineno,unsigned int flags,unsigned int event_f_flags);#define SAFE_FANOTIFY_INIT (fan, mode) \
lib/safe_macros.c +14 -0
@@ -1034,3 +1034,17 @@ int safe_munlock(const char *file, const int lineno, const void *addr,return rval; } + +int safe_mincore (const char *file,const int lineno,void *start, +size_t length,unsigned char *vec) +{ +int rval; + + rval =mincore (start, length, vec); +if (rval ==-1 ) { +tst_brkm (TBROK |TERRNO ,NULL , +"%s:%d: mincore() failed" , file, lineno); + } + +return rval; +}
runtest/ltplite +2 -0
@@ -443,6 +443,8 @@ mknod09 mknod09 mlock01 mlock01 mlock02 mlock02 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
runtest/stress.part3 +2 -0
@@ -369,6 +369,8 @@ mknod09 mknod09 mlock01 mlock01 mlock02 mlock02 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
runtest/syscalls +2 -0
@@ -633,6 +633,8 @@ mlock02 mlock02 mlock03 mlock03 -i 20 mlock04 mlock04 +mlock201 mlock201 + qmm01 mmap001 -m 1 mmap01 mmap01 mmap02 mmap02
testcases/kernel/syscalls/mlock2/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/mlock201
testcases/kernel/syscalls/mlock2/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +# Author: Xiao Yang <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/mlock2/mlock201.c new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 3/4 syscalls/mlock201: Add new testcase
----- Original Message -----
Quoted 9 lines
1) Add
SAFE_MINCORE()macro
2) Check the basic functionality of mlock2(2).Note:
1) We usetst_syscall()to check ifmlock2()is supported.
2) since kernel v2.6.9, the limits and permissions ofmlock2()changed, so we just checkmlock2()since the version.Signed-off-by Xiao Yang <[email protected]>
Looks good to me, some nits below (no need to re-post)
Quoted 13 lines
testcases/kernel/syscalls/mlock2/mlock201.c new file +13
-0+#include <errno.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <linux/mman.h> + +#include "tst_test.h" +#include "lapi/syscalls.h" +#include "lapi/mlock2.h" + +#define PAGES 8 +#define HPAGES (PAGES / 2)
testcases/kernel/syscalls/mlock2/mlock201.c line 40
Quoted 10 lines
testcases/kernel/syscalls/mlock2/mlock201.c new file +10
-0+ +static size_t pgsz; +static unsigned char *vec; + +static struct tcase { + size_t pop_pgs; + size_t lock_pgs; + size_t offset; + size_t exp_vmlcks; + size_t exp_pgs;
Some of these could be more descriptive or have comments.
<snip>
testcases/kernel/syscalls/mlock2/mlock201.c line 128
Quoted 4 lines
testcases/kernel/syscalls/mlock2/mlock201.c new file +4
-0+static void setup (void ) +{ + pgsz =getpagesize (); + vec =SAFE_MALLOC ((PAGES * pgsz + pgsz -1 ) / pgsz);
This value is known at compile time, so malloc isn't needed.
Quoted 5 lines
testcases/kernel/syscalls/mlock2/mlock201.c new file +5
-0+} + +static void cleanup (void ) +{ +if (vec)
testcases/kernel/syscalls/mlock2/mlock201.c line 143
Quoted 10 lines
testcases/kernel/syscalls/mlock2/mlock201.c new file +10
-0+free (vec); +} + +static struct tst_test test = { + .tcnt =ARRAY_SIZE (tcases), + .test = verify_mlock2, + .setup = setup, + .cleanup = cleanup, + .needs_root =1 , + .min_kver ="2.6.9" ,
Ok, "syscall can be backported to older kernels" is valid argument.
Thanks,
Jan
PATCH v2 4/4 syscalls/mlock202: Add new testcase
In reply to Xiao YangCheck various errnos for mlock2(2) since kernel v2.6.9.
Note:
1) We use tst_syscall() to check if mlock2() is supported.
2) since kernel v2.6.9, the limits and permissions of mlock2() changed, so we just check mlock2() since the version.
--- runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/mlock2/.gitignore | 1 + testcases/kernel/syscalls/mlock2/mlock202.c | 113 ++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 testcases/kernel/syscalls/mlock2/mlock202.c
runtest/ltplite +1 -0
@@ -444,6 +444,7 @@ mlock01 mlock01 mlock02 mlock02 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
runtest/stress.part3 +1 -0
@@ -370,6 +370,7 @@ mlock01 mlock01 mlock02 mlock02 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
runtest/syscalls +1 -0
@@ -634,6 +634,7 @@ mlock03 mlock03 -i 20 mlock04 mlock04 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
testcases/kernel/syscalls/mlock2/.gitignore +1 -0
@@ -1 +1,2 @@ /mlock201 +/mlock202
testcases/kernel/syscalls/mlock2/mlock202.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 4/4 syscalls/mlock202: Add new testcase
----- Original Message -----
Quoted 8 lines
Check various errnos for mlock2(2) since kernel v2.6.9.
Note:
1) We usetst_syscall()to check ifmlock2()is supported.
2) since kernel v2.6.9, the limits and permissions ofmlock2()changed, so we just checkmlock2()since the version.Signed-off-by Xiao Yang <[email protected]>
Ack
PATCH v2 4/4 syscalls/mlock202: Add new testcase
----- Original Message -----
Quoted 5 lines
----- Original Message -----
Quoted 2 lines
Check various errnos for mlock2(2) since kernel v2.6.9.
Quoted 8 lines
Quoted 6 lines
Note:
1) We usetst_syscall()to check ifmlock2()is supported.
2) since kernel v2.6.9, the limits and permissions ofmlock2()changed, so we just checkmlock2()since the version.Signed-off-by Xiao Yang <[email protected]>Ack
Series pushed with few tweaks to 3/4:
- couple variables renamed
- added comments
- vec allocated statically, dropped cleanup()
Thanks,
Jan
PATCH 4/4 syscalls/mlock202: Add new testcase
In reply to Xiao YangCheck various errnos for mlock2(2) since kernel v2.6.9.
--- runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/mlock2/.gitignore | 1 + testcases/kernel/syscalls/mlock2/mlock202.c | 110 ++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 testcases/kernel/syscalls/mlock2/mlock202.c
runtest/ltplite +1 -0
@@ -444,6 +444,7 @@ mlock01 mlock01 mlock02 mlock02 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
runtest/stress.part3 +1 -0
@@ -370,6 +370,7 @@ mlock01 mlock01 mlock02 mlock02 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
runtest/syscalls +1 -0
@@ -634,6 +634,7 @@ mlock03 mlock03 -i 20 mlock04 mlock04 mlock201 mlock201 +mlock202 mlock202 qmm01 mmap001 -m 1 mmap01 mmap01
testcases/kernel/syscalls/mlock2/.gitignore +1 -0
@@ -1 +1,2 @@ /mlock201 +/mlock202
testcases/kernel/syscalls/mlock2/mlock202.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/4 syscalls/mlock202: Add new testcase
----- Original Message -----
Quoted 1 line
Check various errnos for mlock2(2) since kernel v2.6.9.
mlock2() is available since Linux 4.4.
testcases/kernel/syscalls/mlock2/mlock202.c line 39
Quoted 6 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +6
-0+static struct tcase { + char **taddr; + int flag; + unsigned long *max_size; + /* 1: nobody expected 0: root expected */ + int exp_user;
I'd drop the "expected" prefix here, this isn't something syscall provides as "output".
Quoted 8 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +8
-0+int exp_err; +} tcases[] = { + {&addr, -1, NULL, 0, EINVAL}, + {&addr, 0, &max_sz1, 1, ENOMEM}, + {&addr, 0, &max_sz2, 1, EPERM}, + {&unmapped_addr, 0, NULL, 0, ENOMEM}, +}; +
..
testcases/kernel/syscalls/mlock2/mlock202.c line 92
Quoted 10 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +10
-0+static void setup (void ) +{ + pgsz =getpagesize (); + nobody =SAFE_GETPWNAM ("nobody" ); + + addr =SAFE_MMAP (NULL , pgsz,PROT_WRITE , +MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); + unmapped_addr =SAFE_MMAP (NULL , pgsz,PROT_READ , +MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); +SAFE_MUNMAP (unmapped_addr, pgsz);
I suggest larger map here (couple M) and pick address in middle. Single page can easily be mapped by glibc for some buffer.
testcases/kernel/syscalls/mlock2/mlock202.c line 96
Quoted 4 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +4
-0+ + max_sz1 = pgsz -1 ; +} +
Regards,
Jan
PATCH 4/4 syscalls/mlock202: Add new testcase
Quoted 11 lines · Jan Stancek
----- Original Message -----
Quoted 1 line
Check various errnos for mlock2(2) since kernel v2.6.9.
mlock2()is available since Linux 4.4.testcases/kernel/syscalls/mlock2/mlock202.c line 39
Quoted 6 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +6
-0+static struct tcase { + char **taddr; + int flag; + unsigned long *max_size; + /* 1: nobody expected 0: root expected */ + int exp_user;I'd drop the "expected" prefix here, this isn't something syscall provides as "output".
Hi Jan,
OK, I will drop it.
Quoted 9 lines
Quoted 8 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +8
-0+int exp_err; +} tcases[] = { + {&addr, -1, NULL, 0, EINVAL}, + {&addr, 0,&max_sz1, 1, ENOMEM}, + {&addr, 0,&max_sz2, 1, EPERM}, + {&unmapped_addr, 0, NULL, 0, ENOMEM}, +}; +..
Quoted 12 lines
testcases/kernel/syscalls/mlock2/mlock202.c line 92
Quoted 10 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +10
-0+static void setup (void ) +{ + pgsz =getpagesize (); + nobody =SAFE_GETPWNAM ("nobody" ); + + addr =SAFE_MMAP (NULL , pgsz,PROT_WRITE , +MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); + unmapped_addr =SAFE_MMAP (NULL , pgsz,PROT_READ , +MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); +SAFE_MUNMAP (unmapped_addr, pgsz);I suggest larger map here (couple M) and pick address in middle. Single page can easily be mapped by glibc for some buffer.
OK, i will map a larger one and pick address in middle.
Thanks,
Xiao Yang
Quoted 9 lines
testcases/kernel/syscalls/mlock2/mlock202.c line 96
Quoted 4 lines
testcases/kernel/syscalls/mlock2/mlock202.c new file +4
-0+ + max_sz1 = pgsz -1 ; +} +Regards,
Jan
PATCH 1/4 lapi/syscalls: Add syscall numbers for mlock2
In reply to Xiao Yang----- Original Message -----
Quoted 16 lines
Signed-off-by Xiao Yang <[email protected]>--- include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + 13 files changed, 13 insertions(+)
ACK