Lines Matching full:size
37 size_t size; member
40 static bool is_zeroed(void *from, size_t size) in is_zeroed() argument
42 return memchr_inv(from, 0x0, size) == NULL; in is_zeroed()
52 size_t size = priv->size; in usercopy_test_check_nonzero_user() local
54 KUNIT_ASSERT_GE_MSG(test, size, 2 * PAGE_SIZE, "buffer too small"); in usercopy_test_check_nonzero_user()
58 * effectively. We also don't want to make the size we scan too large, in usercopy_test_check_nonzero_user()
62 size = 1024; in usercopy_test_check_nonzero_user()
63 start = PAGE_SIZE - (size / 2); in usercopy_test_check_nonzero_user()
68 zero_start = size / 4; in usercopy_test_check_nonzero_user()
69 zero_end = size - zero_start; in usercopy_test_check_nonzero_user()
82 memset(kmem, 0x0, size); in usercopy_test_check_nonzero_user()
85 for (i = zero_end; i < size; i += 2) in usercopy_test_check_nonzero_user()
88 KUNIT_EXPECT_EQ_MSG(test, copy_to_user(umem, kmem, size), 0, in usercopy_test_check_nonzero_user()
91 for (start = 0; start <= size; start++) { in usercopy_test_check_nonzero_user()
92 for (end = start; end <= size; end++) { in usercopy_test_check_nonzero_user()
111 size_t size = priv->size; in usercopy_test_copy_struct_from_user() local
114 umem_src = kunit_kmalloc(test, size, GFP_KERNEL); in usercopy_test_copy_struct_from_user()
117 expected = kunit_kmalloc(test, size, GFP_KERNEL); in usercopy_test_copy_struct_from_user()
121 memset(umem_src, 0x3e, size); in usercopy_test_copy_struct_from_user()
122 KUNIT_ASSERT_EQ_MSG(test, copy_to_user(umem, umem_src, size), 0, in usercopy_test_copy_struct_from_user()
126 ksize = size; in usercopy_test_copy_struct_from_user()
127 usize = size; in usercopy_test_copy_struct_from_user()
131 memset(kmem, 0x0, size); in usercopy_test_copy_struct_from_user()
138 ksize = size; in usercopy_test_copy_struct_from_user()
139 usize = size / 2; in usercopy_test_copy_struct_from_user()
144 memset(kmem, 0x0, size); in usercopy_test_copy_struct_from_user()
151 ksize = size / 2; in usercopy_test_copy_struct_from_user()
152 usize = size; in usercopy_test_copy_struct_from_user()
154 memset(kmem, 0x0, size); in usercopy_test_copy_struct_from_user()
159 ksize = size / 2; in usercopy_test_copy_struct_from_user()
160 usize = size; in usercopy_test_copy_struct_from_user()
166 memset(kmem, 0x0, size); in usercopy_test_copy_struct_from_user()
191 #define test_legit(size, check) \ in usercopy_test_valid() argument
193 size val_##size = (check); \ in usercopy_test_valid()
195 put_user(val_##size, (size __user *)usermem), \ in usercopy_test_valid()
196 "legitimate put_user (" #size ") failed"); \ in usercopy_test_valid()
197 val_##size = 0; \ in usercopy_test_valid()
199 get_user(val_##size, (size __user *)usermem), \ in usercopy_test_valid()
200 "legitimate get_user (" #size ") failed"); \ in usercopy_test_valid()
201 KUNIT_EXPECT_EQ_MSG(test, val_##size, check, \ in usercopy_test_valid()
202 "legitimate get_user (" #size ") failed to do copy"); \ in usercopy_test_valid()
263 #define test_illegal(size, check) \ in usercopy_test_invalid() argument
265 size val_##size = (check); \ in usercopy_test_invalid()
267 KUNIT_EXPECT_NE_MSG(test, get_user(val_##size, (size __user *)kmem), 0, \ in usercopy_test_invalid()
268 "illegal get_user (" #size ") passed"); \ in usercopy_test_invalid()
269 KUNIT_EXPECT_EQ_MSG(test, val_##size, 0, \ in usercopy_test_invalid()
270 "zeroing failure for illegal get_user (" #size ")"); \ in usercopy_test_invalid()
273 KUNIT_EXPECT_NE_MSG(test, put_user(val_##size, (size __user *)kmem), 0, \ in usercopy_test_invalid()
274 "illegal put_user (" #size ") passed"); \ in usercopy_test_invalid()
276 "illegal put_user (" #size ") wrote to kernel memory!"); \ in usercopy_test_invalid()
301 priv->size = PAGE_SIZE * 2; in usercopy_test_init()
303 priv->kmem = kunit_kmalloc(test, priv->size, GFP_KERNEL); in usercopy_test_init()
306 user_addr = kunit_vm_mmap(test, NULL, 0, priv->size, in usercopy_test_init()