Lines Matching refs:ptr
80 char *ptr; in kmalloc_oob_right() local
83 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_right()
84 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_right()
86 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size + OOB_TAG_OFF] = 'x'); in kmalloc_oob_right()
87 kfree(ptr); in kmalloc_oob_right()
92 char *ptr; in kmalloc_oob_left() local
95 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_left()
96 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_left()
98 KUNIT_EXPECT_KASAN_FAIL(test, *ptr = *(ptr - 1)); in kmalloc_oob_left()
99 kfree(ptr); in kmalloc_oob_left()
104 char *ptr; in kmalloc_node_oob_right() local
107 ptr = kmalloc_node(size, GFP_KERNEL, 0); in kmalloc_node_oob_right()
108 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_node_oob_right()
110 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size] = 0); in kmalloc_node_oob_right()
111 kfree(ptr); in kmalloc_node_oob_right()
116 char *ptr; in kmalloc_pagealloc_oob_right() local
127 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_oob_right()
128 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_oob_right()
130 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size + OOB_TAG_OFF] = 0); in kmalloc_pagealloc_oob_right()
131 kfree(ptr); in kmalloc_pagealloc_oob_right()
136 char *ptr; in kmalloc_pagealloc_uaf() local
144 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_uaf()
145 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_uaf()
147 kfree(ptr); in kmalloc_pagealloc_uaf()
148 KUNIT_EXPECT_KASAN_FAIL(test, ptr[0] = 0); in kmalloc_pagealloc_uaf()
153 char *ptr; in kmalloc_pagealloc_invalid_free() local
161 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_pagealloc_invalid_free()
162 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_pagealloc_invalid_free()
164 KUNIT_EXPECT_KASAN_FAIL(test, kfree(ptr + 1)); in kmalloc_pagealloc_invalid_free()
169 char *ptr; in kmalloc_large_oob_right() local
174 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_large_oob_right()
175 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_large_oob_right()
177 KUNIT_EXPECT_KASAN_FAIL(test, ptr[size] = 0); in kmalloc_large_oob_right()
178 kfree(ptr); in kmalloc_large_oob_right()
255 char *ptr; in kmalloc_oob_memset_2() local
258 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_2()
259 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_2()
261 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + 7 + OOB_TAG_OFF, 0, 2)); in kmalloc_oob_memset_2()
262 kfree(ptr); in kmalloc_oob_memset_2()
267 char *ptr; in kmalloc_oob_memset_4() local
270 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_4()
271 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_4()
273 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + 5 + OOB_TAG_OFF, 0, 4)); in kmalloc_oob_memset_4()
274 kfree(ptr); in kmalloc_oob_memset_4()
280 char *ptr; in kmalloc_oob_memset_8() local
283 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_8()
284 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_8()
286 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + 1 + OOB_TAG_OFF, 0, 8)); in kmalloc_oob_memset_8()
287 kfree(ptr); in kmalloc_oob_memset_8()
292 char *ptr; in kmalloc_oob_memset_16() local
295 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_memset_16()
296 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_memset_16()
298 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + 1 + OOB_TAG_OFF, 0, 16)); in kmalloc_oob_memset_16()
299 kfree(ptr); in kmalloc_oob_memset_16()
304 char *ptr; in kmalloc_oob_in_memset() local
307 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_oob_in_memset()
308 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_oob_in_memset()
310 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr, 0, size + 5 + OOB_TAG_OFF)); in kmalloc_oob_in_memset()
311 kfree(ptr); in kmalloc_oob_in_memset()
316 char *ptr; in kmalloc_memmove_invalid_size() local
320 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_memmove_invalid_size()
321 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_memmove_invalid_size()
323 memset((char *)ptr, 0, 64); in kmalloc_memmove_invalid_size()
326 memmove((char *)ptr, (char *)ptr + 4, invalid_size)); in kmalloc_memmove_invalid_size()
327 kfree(ptr); in kmalloc_memmove_invalid_size()
332 char *ptr; in kmalloc_uaf() local
335 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_uaf()
336 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_uaf()
338 kfree(ptr); in kmalloc_uaf()
339 KUNIT_EXPECT_KASAN_FAIL(test, *(ptr + 8) = 'x'); in kmalloc_uaf()
344 char *ptr; in kmalloc_uaf_memset() local
347 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_uaf_memset()
348 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_uaf_memset()
350 kfree(ptr); in kmalloc_uaf_memset()
351 KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr, 0, size)); in kmalloc_uaf_memset()
375 char *ptr; in kfree_via_page() local
380 ptr = kmalloc(size, GFP_KERNEL); in kfree_via_page()
381 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kfree_via_page()
383 page = virt_to_page(ptr); in kfree_via_page()
384 offset = offset_in_page(ptr); in kfree_via_page()
390 char *ptr; in kfree_via_phys() local
394 ptr = kmalloc(size, GFP_KERNEL); in kfree_via_phys()
395 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kfree_via_phys()
397 phys = virt_to_phys(ptr); in kfree_via_phys()
466 char *ptr; in ksize_unpoisons_memory() local
469 ptr = kmalloc(size, GFP_KERNEL); in ksize_unpoisons_memory()
470 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in ksize_unpoisons_memory()
471 real_size = ksize(ptr); in ksize_unpoisons_memory()
473 ptr[size] = 'x'; in ksize_unpoisons_memory()
475 KUNIT_EXPECT_KASAN_FAIL(test, ptr[real_size] = 'y'); in ksize_unpoisons_memory()
476 kfree(ptr); in ksize_unpoisons_memory()
585 char *ptr; in kasan_memchr() local
598 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_memchr()
599 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_memchr()
602 kasan_ptr_result = memchr(ptr, '1', size + 1)); in kasan_memchr()
604 kfree(ptr); in kasan_memchr()
609 char *ptr; in kasan_memcmp() local
623 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_memcmp()
624 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_memcmp()
628 kasan_int_result = memcmp(ptr, arr, size+1)); in kasan_memcmp()
629 kfree(ptr); in kasan_memcmp()
634 char *ptr; in kasan_strings() local
644 ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); in kasan_strings()
645 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kasan_strings()
647 kfree(ptr); in kasan_strings()
655 ptr += 16; in kasan_strings()
656 KUNIT_EXPECT_KASAN_FAIL(test, kasan_ptr_result = strchr(ptr, '1')); in kasan_strings()
658 KUNIT_EXPECT_KASAN_FAIL(test, kasan_ptr_result = strrchr(ptr, '1')); in kasan_strings()
660 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strcmp(ptr, "2")); in kasan_strings()
662 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strncmp(ptr, "2", 1)); in kasan_strings()
664 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strlen(ptr)); in kasan_strings()
666 KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strnlen(ptr, 1)); in kasan_strings()
753 char *ptr; in kmalloc_double_kzfree() local
756 ptr = kmalloc(size, GFP_KERNEL); in kmalloc_double_kzfree()
757 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); in kmalloc_double_kzfree()
759 kfree_sensitive(ptr); in kmalloc_double_kzfree()
760 KUNIT_EXPECT_KASAN_FAIL(test, kfree_sensitive(ptr)); in kmalloc_double_kzfree()