1 // SPDX-License-Identifier: GPL-2.0
7 #include <sys/resource.h>
8 #include "../kselftest.h"
10 static void test_limit(void)
15 if (getrlimit(RLIMIT_MEMLOCK, &lims))
16 ksft_exit_fail_msg("getrlimit: %s\n", strerror(errno));
18 if (mlockall(MCL_ONFAULT | MCL_FUTURE))
19 ksft_exit_fail_msg("mlockall: %s\n", strerror(errno));
21 map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
22 MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
24 ksft_test_result(map == MAP_FAILED, "The map failed respecting mlock limits\n");
26 if (map != MAP_FAILED)
27 munmap(map, 2 * lims.rlim_max);
31 int main(int argc, char **argv)
37 ksft_test_result_skip("The test must be run from a normal user\n");