Lines Matching full:size
26 int size = 0; in get_vma_size() local
38 size = addr_end - addr_start; in get_vma_size()
50 return size; in get_vma_size()
65 static int sys_mprotect(void *ptr, size_t size, unsigned long prot) in sys_mprotect() argument
70 sret = syscall(__NR_mprotect, ptr, size, prot); in sys_mprotect()
74 static int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, in sys_mprotect_pkey() argument
80 sret = syscall(__NR_pkey_mprotect, ptr, size, orig_prot, pkey); in sys_mprotect_pkey()
84 static int sys_munmap(void *ptr, size_t size) in sys_munmap() argument
89 sret = syscall(__NR_munmap, ptr, size); in sys_munmap()
170 static void setup_single_address(int size, void **ptrOut) in setup_single_address() argument
174 ptr = mmap(NULL, size, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); in setup_single_address()
178 static void setup_single_address_rw(int size, void **ptrOut) in setup_single_address_rw() argument
183 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, mapflags, -1, 0); in setup_single_address_rw()
187 static int clean_single_address(void *ptr, int size) in clean_single_address() argument
190 ret = munmap(ptr, size); in clean_single_address()
194 static int seal_single_address(void *ptr, int size) in seal_single_address() argument
197 ret = sys_mseal(ptr, size); in seal_single_address()
234 unsigned long size = 4 * page_size; in test_seal_addseal() local
236 setup_single_address(size, &ptr); in test_seal_addseal()
239 ret = sys_mseal(ptr, size); in test_seal_addseal()
250 unsigned long size = 4 * page_size; in test_seal_unmapped_start() local
252 setup_single_address(size, &ptr); in test_seal_unmapped_start()
260 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_unmapped_start()
264 ret = sys_mseal(ptr, size); in test_seal_unmapped_start()
278 unsigned long size = 4 * page_size; in test_seal_unmapped_middle() local
280 setup_single_address(size, &ptr); in test_seal_unmapped_middle()
288 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_unmapped_middle()
292 ret = sys_mseal(ptr, size); in test_seal_unmapped_middle()
310 unsigned long size = 4 * page_size; in test_seal_unmapped_end() local
312 setup_single_address(size, &ptr); in test_seal_unmapped_end()
320 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_unmapped_end()
324 ret = sys_mseal(ptr, size); in test_seal_unmapped_end()
339 unsigned long size = 4 * page_size; in test_seal_multiple_vmas() local
341 setup_single_address(size, &ptr); in test_seal_multiple_vmas()
350 ret = sys_mprotect(ptr, size, PROT_READ); in test_seal_multiple_vmas()
359 ret = sys_mseal(ptr, size); in test_seal_multiple_vmas()
370 unsigned long size = 4 * page_size; in test_seal_split_start() local
372 setup_single_address(size, &ptr); in test_seal_split_start()
395 unsigned long size = 4 * page_size; in test_seal_split_end() local
397 setup_single_address(size, &ptr); in test_seal_split_end()
419 unsigned long size = 4 * page_size; in test_seal_invalid_input() local
428 ret = syscall(__NR_mseal, ptr, size, 0x20); in test_seal_invalid_input()
454 unsigned long size = 4 * page_size; in test_seal_zero_length() local
457 setup_single_address(size, &ptr); in test_seal_zero_length()
468 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_zero_length()
478 unsigned long size = 4 * page_size; in test_seal_zero_address() local
483 ptr = mmap(0, size, PROT_NONE, in test_seal_zero_address()
487 size = get_vma_size(ptr, &prot); in test_seal_zero_address()
488 FAIL_TEST_IF_FALSE(size == 4 * page_size); in test_seal_zero_address()
490 ret = sys_mseal(ptr, size); in test_seal_zero_address()
494 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_zero_address()
505 unsigned long size = 4 * page_size; in test_seal_twice() local
507 setup_single_address(size, &ptr); in test_seal_twice()
510 ret = sys_mseal(ptr, size); in test_seal_twice()
514 ret = sys_mseal(ptr, size); in test_seal_twice()
524 unsigned long size = 4 * page_size; in test_seal_mprotect() local
527 setup_single_address(size, &ptr); in test_seal_mprotect()
531 ret = seal_single_address(ptr, size); in test_seal_mprotect()
535 ret = sys_mprotect(ptr, size, PROT_READ | PROT_WRITE); in test_seal_mprotect()
548 unsigned long size = 4 * page_size; in test_seal_start_mprotect() local
551 setup_single_address(size, &ptr); in test_seal_start_mprotect()
578 unsigned long size = 4 * page_size; in test_seal_end_mprotect() local
581 setup_single_address(size, &ptr); in test_seal_end_mprotect()
608 unsigned long size = 4 * page_size; in test_seal_mprotect_unalign_len() local
611 setup_single_address(size, &ptr); in test_seal_mprotect_unalign_len()
637 unsigned long size = 4 * page_size; in test_seal_mprotect_unalign_len_variant_2() local
640 setup_single_address(size, &ptr); in test_seal_mprotect_unalign_len_variant_2()
665 unsigned long size = 4 * page_size; in test_seal_mprotect_two_vma() local
668 setup_single_address(size, &ptr); in test_seal_mprotect_two_vma()
700 unsigned long size = 4 * page_size; in test_seal_mprotect_two_vma_with_split() local
703 setup_single_address(size, &ptr); in test_seal_mprotect_two_vma_with_split()
747 unsigned long size = 4 * page_size; in test_seal_mprotect_partial_mprotect() local
750 setup_single_address(size, &ptr); in test_seal_mprotect_partial_mprotect()
773 unsigned long size = 2 * page_size; in test_seal_mprotect_partial_mprotect_tail() local
782 setup_single_address(size, &ptr); in test_seal_mprotect_partial_mprotect_tail()
790 ret = sys_mprotect(ptr, size, PROT_EXEC); in test_seal_mprotect_partial_mprotect_tail()
809 unsigned long size = 4 * page_size; in test_seal_mprotect_two_vma_with_gap() local
812 setup_single_address(size, &ptr); in test_seal_mprotect_two_vma_with_gap()
852 unsigned long size = 4 * page_size; in test_seal_mprotect_split() local
855 setup_single_address(size, &ptr); in test_seal_mprotect_split()
889 unsigned long size = 4 * page_size; in test_seal_mprotect_merge() local
892 setup_single_address(size, &ptr); in test_seal_mprotect_merge()
923 unsigned long size = 4 * page_size; in test_seal_munmap() local
926 setup_single_address(size, &ptr); in test_seal_munmap()
930 ret = sys_mseal(ptr, size); in test_seal_munmap()
935 ret = sys_munmap(ptr, size); in test_seal_munmap()
954 unsigned long size = 4 * page_size; in test_seal_munmap_two_vma() local
957 setup_single_address(size, &ptr); in test_seal_munmap_two_vma()
965 ret = sys_mseal(ptr, size); in test_seal_munmap_two_vma()
995 unsigned long size = 4 * page_size; in test_seal_munmap_vma_with_gap() local
998 setup_single_address(size, &ptr); in test_seal_munmap_vma_with_gap()
1006 ret = sys_mseal(ptr, size); in test_seal_munmap_vma_with_gap()
1016 ret = sys_munmap(ptr, size); in test_seal_munmap_vma_with_gap()
1026 unsigned long size = 2 * page_size; in test_seal_munmap_partial_across_vmas() local
1030 setup_single_address(size, &ptr); in test_seal_munmap_partial_across_vmas()
1038 ret = sys_munmap(ptr, size); in test_seal_munmap_partial_across_vmas()
1056 unsigned long size = 4 * page_size; in test_munmap_start_freed() local
1060 setup_single_address(size, &ptr); in test_munmap_start_freed()
1074 ret = sys_munmap(ptr, size); in test_munmap_start_freed()
1078 size = get_vma_size(ptr + page_size, &prot); in test_munmap_start_freed()
1079 FAIL_TEST_IF_FALSE(size == page_size * 3); in test_munmap_start_freed()
1085 size = get_vma_size(ptr + page_size, &prot); in test_munmap_start_freed()
1086 FAIL_TEST_IF_FALSE(size == 0); in test_munmap_start_freed()
1096 unsigned long size = 4 * page_size; in test_munmap_end_freed() local
1099 setup_single_address(size, &ptr); in test_munmap_end_freed()
1113 ret = sys_munmap(ptr, size); in test_munmap_end_freed()
1126 unsigned long size = 4 * page_size; in test_munmap_middle_freed() local
1130 setup_single_address(size, &ptr); in test_munmap_middle_freed()
1144 ret = sys_munmap(ptr, size); in test_munmap_middle_freed()
1148 size = get_vma_size(ptr, &prot); in test_munmap_middle_freed()
1149 FAIL_TEST_IF_FALSE(size == page_size); in test_munmap_middle_freed()
1151 size = get_vma_size(ptr + page_size * 3, &prot); in test_munmap_middle_freed()
1152 FAIL_TEST_IF_FALSE(size == page_size); in test_munmap_middle_freed()
1156 size = get_vma_size(ptr, &prot); in test_munmap_middle_freed()
1157 FAIL_TEST_IF_FALSE(size == 0); in test_munmap_middle_freed()
1159 size = get_vma_size(ptr + page_size * 3, &prot); in test_munmap_middle_freed()
1160 FAIL_TEST_IF_FALSE(size == 0); in test_munmap_middle_freed()
1170 unsigned long size = 4 * page_size; in test_seal_mremap_shrink() local
1174 setup_single_address(size, &ptr); in test_seal_mremap_shrink()
1178 ret = sys_mseal(ptr, size); in test_seal_mremap_shrink()
1183 ret2 = sys_mremap(ptr, size, 2 * page_size, 0, 0); in test_seal_mremap_shrink()
1199 unsigned long size = 4 * page_size; in test_seal_mremap_expand() local
1203 setup_single_address(size, &ptr); in test_seal_mremap_expand()
1231 unsigned long size = page_size; in test_seal_mremap_move() local
1235 setup_single_address(size, &ptr); in test_seal_mremap_move()
1237 setup_single_address(size, &newPtr); in test_seal_mremap_move()
1239 ret = clean_single_address(newPtr, size); in test_seal_mremap_move()
1243 ret = sys_mseal(ptr, size); in test_seal_mremap_move()
1248 ret2 = sys_mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, newPtr); in test_seal_mremap_move()
1264 unsigned long size = page_size; in test_seal_mmap_overwrite_prot() local
1268 setup_single_address(size, &ptr); in test_seal_mmap_overwrite_prot()
1272 ret = sys_mseal(ptr, size); in test_seal_mmap_overwrite_prot()
1277 ret2 = mmap(ptr, size, PROT_NONE, in test_seal_mmap_overwrite_prot()
1292 unsigned long size = 12 * page_size; in test_seal_mmap_expand() local
1296 setup_single_address(size, &ptr); in test_seal_mmap_expand()
1308 ret2 = mmap(ptr, size, PROT_READ, in test_seal_mmap_expand()
1323 unsigned long size = 12 * page_size; in test_seal_mmap_shrink() local
1327 setup_single_address(size, &ptr); in test_seal_mmap_shrink()
1331 ret = sys_mseal(ptr, size); in test_seal_mmap_shrink()
1352 unsigned long size = 4 * page_size; in test_seal_mremap_shrink_fixed() local
1356 setup_single_address(size, &ptr); in test_seal_mremap_shrink_fixed()
1358 setup_single_address(size, &newAddr); in test_seal_mremap_shrink_fixed()
1362 ret = sys_mseal(ptr, size); in test_seal_mremap_shrink_fixed()
1367 ret2 = sys_mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED, in test_seal_mremap_shrink_fixed()
1383 unsigned long size = 4 * page_size; in test_seal_mremap_expand_fixed() local
1389 setup_single_address(size, &newAddr); in test_seal_mremap_expand_fixed()
1393 ret = sys_mseal(newAddr, size); in test_seal_mremap_expand_fixed()
1398 ret2 = sys_mremap(ptr, page_size, size, MREMAP_MAYMOVE | MREMAP_FIXED, in test_seal_mremap_expand_fixed()
1414 unsigned long size = 4 * page_size; in test_seal_mremap_move_fixed() local
1418 setup_single_address(size, &ptr); in test_seal_mremap_move_fixed()
1420 setup_single_address(size, &newAddr); in test_seal_mremap_move_fixed()
1424 ret = sys_mseal(newAddr, size); in test_seal_mremap_move_fixed()
1429 ret2 = sys_mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, newAddr); in test_seal_mremap_move_fixed()
1443 unsigned long size = 4 * page_size; in test_seal_mremap_move_fixed_zero() local
1447 setup_single_address(size, &ptr); in test_seal_mremap_move_fixed_zero()
1451 ret = sys_mseal(ptr, size); in test_seal_mremap_move_fixed_zero()
1458 ret2 = sys_mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED, in test_seal_mremap_move_fixed_zero()
1474 unsigned long size = 4 * page_size; in test_seal_mremap_move_dontunmap() local
1478 setup_single_address(size, &ptr); in test_seal_mremap_move_dontunmap()
1482 ret = sys_mseal(ptr, size); in test_seal_mremap_move_dontunmap()
1487 ret2 = sys_mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, 0); in test_seal_mremap_move_dontunmap()
1503 unsigned long size = 4 * page_size; in test_seal_mremap_move_dontunmap_anyaddr() local
1507 setup_single_address(size, &ptr); in test_seal_mremap_move_dontunmap_anyaddr()
1511 ret = sys_mseal(ptr, size); in test_seal_mremap_move_dontunmap_anyaddr()
1519 setup_single_address(size, &ptr2); in test_seal_mremap_move_dontunmap_anyaddr()
1521 ret = sys_munmap(ptr2, size); in test_seal_mremap_move_dontunmap_anyaddr()
1527 ret2 = sys_mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, in test_seal_mremap_move_dontunmap_anyaddr()
1544 unsigned long size; in test_seal_merge_and_split() local
1558 size = get_vma_size(ptr + page_size, &prot); in test_seal_merge_and_split()
1559 FAIL_TEST_IF_FALSE(size == 22 * page_size); in test_seal_merge_and_split()
1566 size = get_vma_size(ptr + page_size, &prot); in test_seal_merge_and_split()
1567 FAIL_TEST_IF_FALSE(size == page_size); in test_seal_merge_and_split()
1569 size = get_vma_size(ptr + 2 * page_size, &prot); in test_seal_merge_and_split()
1570 FAIL_TEST_IF_FALSE(size == 21 * page_size); in test_seal_merge_and_split()
1577 size = get_vma_size(ptr + 22 * page_size, &prot); in test_seal_merge_and_split()
1578 FAIL_TEST_IF_FALSE(size == page_size); in test_seal_merge_and_split()
1580 size = get_vma_size(ptr + 2 * page_size, &prot); in test_seal_merge_and_split()
1581 FAIL_TEST_IF_FALSE(size == 20 * page_size); in test_seal_merge_and_split()
1588 size = get_vma_size(ptr + page_size, &prot); in test_seal_merge_and_split()
1589 FAIL_TEST_IF_FALSE(size == 2 * page_size); in test_seal_merge_and_split()
1596 size = get_vma_size(ptr + 21 * page_size, &prot); in test_seal_merge_and_split()
1597 FAIL_TEST_IF_FALSE(size == 2 * page_size); in test_seal_merge_and_split()
1604 size = get_vma_size(ptr + 1 * page_size, &prot); in test_seal_merge_and_split()
1605 FAIL_TEST_IF_FALSE(size == 3 * page_size); in test_seal_merge_and_split()
1617 size = get_vma_size(ptr + 20 * page_size, &prot); in test_seal_merge_and_split()
1618 FAIL_TEST_IF_FALSE(size == 3 * page_size); in test_seal_merge_and_split()
1625 size = get_vma_size(ptr + page_size, &prot); in test_seal_merge_and_split()
1626 FAIL_TEST_IF_FALSE(size == 22 * page_size); in test_seal_merge_and_split()
1636 unsigned long size = 4 * page_size; in test_seal_discard_ro_anon_on_rw() local
1639 setup_single_address_rw(size, &ptr); in test_seal_discard_ro_anon_on_rw()
1643 ret = sys_mseal(ptr, size); in test_seal_discard_ro_anon_on_rw()
1648 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon_on_rw()
1652 ret = sys_munmap(ptr, size); in test_seal_discard_ro_anon_on_rw()
1665 unsigned long size = 4 * page_size; in test_seal_discard_ro_anon_on_pkey() local
1671 setup_single_address_rw(size, &ptr); in test_seal_discard_ro_anon_on_pkey()
1677 ret = sys_mprotect_pkey((void *)ptr, size, PROT_READ | PROT_WRITE, pkey); in test_seal_discard_ro_anon_on_pkey()
1681 ret = sys_mseal(ptr, size); in test_seal_discard_ro_anon_on_pkey()
1687 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon_on_pkey()
1692 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon_on_pkey()
1699 ret = sys_munmap(ptr, size); in test_seal_discard_ro_anon_on_pkey()
1712 unsigned long size = 4 * page_size; in test_seal_discard_ro_anon_on_filebacked() local
1720 ret = fallocate(fd, 0, 0, size); in test_seal_discard_ro_anon_on_filebacked()
1723 ptr = mmap(NULL, size, PROT_READ, mapflags, fd, 0); in test_seal_discard_ro_anon_on_filebacked()
1727 ret = sys_mseal(ptr, size); in test_seal_discard_ro_anon_on_filebacked()
1732 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon_on_filebacked()
1735 ret = sys_munmap(ptr, size); in test_seal_discard_ro_anon_on_filebacked()
1749 unsigned long size = 4 * page_size; in test_seal_discard_ro_anon_on_shared() local
1753 ptr = mmap(NULL, size, PROT_READ, mapflags, -1, 0); in test_seal_discard_ro_anon_on_shared()
1757 ret = sys_mseal(ptr, size); in test_seal_discard_ro_anon_on_shared()
1762 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon_on_shared()
1765 ret = sys_munmap(ptr, size); in test_seal_discard_ro_anon_on_shared()
1778 unsigned long size = 4 * page_size; in test_seal_discard_ro_anon() local
1781 setup_single_address(size, &ptr); in test_seal_discard_ro_anon()
1785 ret = seal_single_address(ptr, size); in test_seal_discard_ro_anon()
1789 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_ro_anon()
1795 ret = sys_munmap(ptr, size); in test_seal_discard_ro_anon()
1808 unsigned long size = 2 * page_size; in test_seal_discard_across_vmas() local
1811 setup_single_address(size, &ptr); in test_seal_discard_across_vmas()
1819 ret = sys_madvise(ptr, size, MADV_DONTNEED); in test_seal_discard_across_vmas()
1825 ret = sys_munmap(ptr, size); in test_seal_discard_across_vmas()
1839 unsigned long size = 4 * page_size; in test_seal_madvise_nodiscard() local
1842 setup_single_address(size, &ptr); in test_seal_madvise_nodiscard()
1846 ret = seal_single_address(ptr, size); in test_seal_madvise_nodiscard()
1855 ret = sys_madvise(ptr, size, MADV_RANDOM); in test_seal_madvise_nodiscard()
1858 ret = sys_munmap(ptr, size); in test_seal_madvise_nodiscard()