Lines Matching refs:ptr
128 char *ptr; in kmalloc_oob_right() local
131 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_right()
132 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_right()
134 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_oob_right()
140 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size] = 'x'); in kmalloc_oob_right()
146 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size + 5] = 'y'); in kmalloc_oob_right()
149 KUNIT_EXPECT_KASAN_FAIL(test, ptr[0] = in kmalloc_oob_right()
150 ptr[size + KASAN_GRANULE_SIZE + 5]); in kmalloc_oob_right()
152 kfree(ptr); in kmalloc_oob_right()
157 char *ptr; in kmalloc_oob_left() local
160 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_left()
161 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_left()
163 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_oob_left()
164 KUNIT_EXPECT_KASAN_FAIL(test, *ptr = *(ptr - 1)); in kmalloc_oob_left()
165 kfree(ptr); in kmalloc_oob_left()
170 char *ptr; in kmalloc_node_oob_right() local
173 ptr = kmalloc_node(size, GFP_KERNEL, 0); in kmalloc_node_oob_right()
174 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_node_oob_right()
176 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_node_oob_right()
177 KUNIT_EXPECT_KASAN_FAIL(test, ptr[0] = ptr[size]); in kmalloc_node_oob_right()
178 kfree(ptr); in kmalloc_node_oob_right()
189 char *ptr; in kmalloc_pagealloc_oob_right() local
194 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_oob_right()
195 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_oob_right()
197 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_pagealloc_oob_right()
198 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size + OOB_TAG_OFF] = 0); in kmalloc_pagealloc_oob_right()
200 kfree(ptr); in kmalloc_pagealloc_oob_right()
205 char *ptr; in kmalloc_pagealloc_uaf() local
210 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_uaf()
211 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_uaf()
212 kfree(ptr); in kmalloc_pagealloc_uaf()
214 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[0]); in kmalloc_pagealloc_uaf()
219 char *ptr; in kmalloc_pagealloc_invalid_free() local
224 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_invalid_free()
225 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_invalid_free()
227 KUNIT_EXPECT_KASAN_FAIL(test, kfree(ptr + 1)); in kmalloc_pagealloc_invalid_free()
232 char *ptr; in pagealloc_oob_right() local
245 ptr = page_address(pages); in pagealloc_oob_right()
246 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in pagealloc_oob_right()
248 KUNIT_EXPECT_KASAN_FAIL(test, ptr[0] = ptr[size]); in pagealloc_oob_right()
249 free_pages((unsigned long)ptr, order); in pagealloc_oob_right()
254 char *ptr; in pagealloc_uaf() local
259 ptr = page_address(pages); in pagealloc_uaf()
260 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in pagealloc_uaf()
261 free_pages((unsigned long)ptr, order); in pagealloc_uaf()
263 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[0]); in pagealloc_uaf()
268 char *ptr; in kmalloc_large_oob_right() local
275 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_large_oob_right()
276 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_large_oob_right()
278 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_large_oob_right()
279 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size] = 0); in kmalloc_large_oob_right()
280 kfree(ptr); in kmalloc_large_oob_right()
450 char *ptr; in kmalloc_oob_memset_2() local
453 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_2()
454 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_2()
457 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2)); in kmalloc_oob_memset_2()
458 kfree(ptr); in kmalloc_oob_memset_2()
463 char *ptr; in kmalloc_oob_memset_4() local
466 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_4()
467 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_4()
470 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4)); in kmalloc_oob_memset_4()
471 kfree(ptr); in kmalloc_oob_memset_4()
476 char *ptr; in kmalloc_oob_memset_8() local
479 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_8()
480 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_8()
483 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8)); in kmalloc_oob_memset_8()
484 kfree(ptr); in kmalloc_oob_memset_8()
489 char *ptr; in kmalloc_oob_memset_16() local
492 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_16()
493 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_16()
496 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16)); in kmalloc_oob_memset_16()
497 kfree(ptr); in kmalloc_oob_memset_16()
502 char *ptr; in kmalloc_oob_in_memset() local
505 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_in_memset()
506 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_in_memset()
508 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_oob_in_memset()
511 memset(ptr, 0, size + KASAN_GRANULE_SIZE)); in kmalloc_oob_in_memset()
512 kfree(ptr); in kmalloc_oob_in_memset()
517 char *ptr; in kmalloc_memmove_negative_size() local
528 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_memmove_negative_size()
529 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_memmove_negative_size()
531 memset((char *)ptr, 0, 64); in kmalloc_memmove_negative_size()
532 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_memmove_negative_size()
535 memmove((char *)ptr, (char *)ptr + 4, invalid_size)); in kmalloc_memmove_negative_size()
536 kfree(ptr); in kmalloc_memmove_negative_size()
541 char *ptr; in kmalloc_memmove_invalid_size() local
545 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_memmove_invalid_size()
546 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_memmove_invalid_size()
548 memset((char *)ptr, 0, 64); in kmalloc_memmove_invalid_size()
549 OPTIMIZER_HIDE_VAR(ptr); in kmalloc_memmove_invalid_size()
551 memmove((char *)ptr, (char *)ptr + 4, invalid_size)); in kmalloc_memmove_invalid_size()
552 kfree(ptr); in kmalloc_memmove_invalid_size()
557 char *ptr; in kmalloc_uaf() local
560 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_uaf()
561 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_uaf()
563 kfree(ptr); in kmalloc_uaf()
564 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[8]); in kmalloc_uaf()
569 char *ptr; in kmalloc_uaf_memset() local
578 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_uaf_memset()
579 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_uaf_memset()
581 kfree(ptr); in kmalloc_uaf_memset()
582 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr, 0, size)); in kmalloc_uaf_memset()
617 char *ptr; in kfree_via_page() local
622 ptr = kmalloc(size, GFP_KERNEL); in kfree_via_page()
623 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kfree_via_page()
625 page = virt_to_page(ptr); in kfree_via_page()
626 offset = offset_in_page(ptr); in kfree_via_page()
632 char *ptr; in kfree_via_phys() local
636 ptr = kmalloc(size, GFP_KERNEL); in kfree_via_phys()
637 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kfree_via_phys()
639 phys = virt_to_phys(ptr); in kfree_via_phys()
759 char *ptr; in ksize_unpoisons_memory() local
762 ptr = kmalloc(size, GFP_KERNEL); in ksize_unpoisons_memory()
763 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in ksize_unpoisons_memory()
764 real_size = ksize(ptr); in ksize_unpoisons_memory()
766 OPTIMIZER_HIDE_VAR(ptr); in ksize_unpoisons_memory()
769 ptr[size] = 'x'; in ksize_unpoisons_memory()
772 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[real_size]); in ksize_unpoisons_memory()
774 kfree(ptr); in ksize_unpoisons_memory()
783 char *ptr; in ksize_uaf() local
786 ptr = kmalloc(size, GFP_KERNEL); in ksize_uaf()
787 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in ksize_uaf()
788 kfree(ptr); in ksize_uaf()
790 OPTIMIZER_HIDE_VAR(ptr); in ksize_uaf()
791 KUNIT_EXPECT_KASAN_FAIL(test, ksize(ptr)); in ksize_uaf()
792 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[0]); in ksize_uaf()
793 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[size]); in ksize_uaf()
903 char *ptr; in kasan_memchr() local
915 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_memchr()
916 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_memchr()
918 OPTIMIZER_HIDE_VAR(ptr); in kasan_memchr()
921 kasan_ptr_result = memchr(ptr, '1', size + 1)); in kasan_memchr()
923 kfree(ptr); in kasan_memchr()
928 char *ptr; in kasan_memcmp() local
941 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_memcmp()
942 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_memcmp()
945 OPTIMIZER_HIDE_VAR(ptr); in kasan_memcmp()
948 kasan_int_result = memcmp(ptr, arr, size+1)); in kasan_memcmp()
949 kfree(ptr); in kasan_memcmp()
954 char *ptr; in kasan_strings() local
963 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_strings()
964 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_strings()
966 kfree(ptr); in kasan_strings()
974 ptr += 16; in kasan_strings()
975 KUNIT_EXPECT_KASAN_FAIL(test, kasan_ptr_result = strchr(ptr, '1')); in kasan_strings()
977 KUNIT_EXPECT_KASAN_FAIL(test, kasan_ptr_result = strrchr(ptr, '1')); in kasan_strings()
979 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strcmp(ptr, "2")); in kasan_strings()
981 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strncmp(ptr, "2", 1)); in kasan_strings()
983 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strlen(ptr)); in kasan_strings()
985 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strnlen(ptr, 1)); in kasan_strings()
1066 char *ptr; in kmalloc_double_kzfree() local
1069 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_double_kzfree()
1070 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_double_kzfree()
1072 kfree_sensitive(ptr); in kmalloc_double_kzfree()
1073 KUNIT_EXPECT_KASAN_FAIL(test, kfree_sensitive(ptr)); in kmalloc_double_kzfree()
1078 void *ptr; in vmalloc_helpers_tags() local
1085 ptr = vmalloc(PAGE_SIZE); in vmalloc_helpers_tags()
1086 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in vmalloc_helpers_tags()
1089 KUNIT_EXPECT_GE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_MIN); in vmalloc_helpers_tags()
1090 KUNIT_EXPECT_LT(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL); in vmalloc_helpers_tags()
1093 KUNIT_ASSERT_TRUE(test, is_vmalloc_addr(ptr)); in vmalloc_helpers_tags()
1094 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vmalloc_to_page(ptr)); in vmalloc_helpers_tags()
1101 rv = set_memory_ro((unsigned long)ptr, 1); in vmalloc_helpers_tags()
1103 rv = set_memory_rw((unsigned long)ptr, 1); in vmalloc_helpers_tags()
1108 vfree(ptr); in vmalloc_helpers_tags()
1234 char __percpu *ptr; in vmalloc_percpu() local
1243 ptr = __alloc_percpu(PAGE_SIZE, PAGE_SIZE); in vmalloc_percpu()
1246 char *c_ptr = per_cpu_ptr(ptr, cpu); in vmalloc_percpu()
1255 free_percpu(ptr); in vmalloc_percpu()
1265 char *ptr; in match_all_not_assigned() local
1273 ptr = kmalloc(size, GFP_KERNEL); in match_all_not_assigned()
1274 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in match_all_not_assigned()
1275 KUNIT_EXPECT_GE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_MIN); in match_all_not_assigned()
1276 KUNIT_EXPECT_LT(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL); in match_all_not_assigned()
1277 kfree(ptr); in match_all_not_assigned()
1283 ptr = page_address(pages); in match_all_not_assigned()
1284 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in match_all_not_assigned()
1285 KUNIT_EXPECT_GE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_MIN); in match_all_not_assigned()
1286 KUNIT_EXPECT_LT(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL); in match_all_not_assigned()
1287 free_pages((unsigned long)ptr, order); in match_all_not_assigned()
1295 ptr = vmalloc(size); in match_all_not_assigned()
1296 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in match_all_not_assigned()
1297 KUNIT_EXPECT_GE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_MIN); in match_all_not_assigned()
1298 KUNIT_EXPECT_LT(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL); in match_all_not_assigned()
1299 vfree(ptr); in match_all_not_assigned()
1306 char *ptr; in match_all_ptr_tag() local
1311 ptr = kmalloc(128, GFP_KERNEL); in match_all_ptr_tag()
1312 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in match_all_ptr_tag()
1315 tag = get_tag(ptr); in match_all_ptr_tag()
1319 ptr = set_tag(ptr, KASAN_TAG_KERNEL); in match_all_ptr_tag()
1322 *ptr = 0; in match_all_ptr_tag()
1325 ptr = set_tag(ptr, tag); in match_all_ptr_tag()
1326 kfree(ptr); in match_all_ptr_tag()
1332 char *ptr; in match_all_mem_tag() local
1337 ptr = kmalloc(128, GFP_KERNEL); in match_all_mem_tag()
1338 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in match_all_mem_tag()
1339 KUNIT_EXPECT_NE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL); in match_all_mem_tag()
1343 if (tag == get_tag(ptr)) in match_all_mem_tag()
1347 kasan_poison(ptr, KASAN_GRANULE_SIZE, (u8)tag, false); in match_all_mem_tag()
1350 KUNIT_EXPECT_KASAN_FAIL(test, *ptr = 0); in match_all_mem_tag()
1354 kasan_poison(ptr, KASAN_GRANULE_SIZE, get_tag(ptr), false); in match_all_mem_tag()
1355 kfree(ptr); in match_all_mem_tag()