Lines Matching refs:e
50 struct aa_ext *e; member
58 struct aa_ext *e; in build_aa_ext_struct() local
63 e = kunit_kmalloc(test, sizeof(*e), GFP_USER); in build_aa_ext_struct()
64 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, e); in build_aa_ext_struct()
66 e->start = buf; in build_aa_ext_struct()
67 e->end = e->start + buf_size; in build_aa_ext_struct()
68 e->pos = e->start; in build_aa_ext_struct()
72 strscpy(buf + 3, TEST_STRING_NAME, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
74 buf = e->start + TEST_STRING_BUF_OFFSET; in build_aa_ext_struct()
77 strscpy(buf + 3, TEST_STRING_DATA, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
78 buf = e->start + TEST_NAMED_U32_BUF_OFFSET; in build_aa_ext_struct()
81 strscpy(buf + 3, TEST_U32_NAME, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
85 buf = e->start + TEST_NAMED_U64_BUF_OFFSET; in build_aa_ext_struct()
88 strscpy(buf + 3, TEST_U64_NAME, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
92 buf = e->start + TEST_NAMED_BLOB_BUF_OFFSET; in build_aa_ext_struct()
95 strscpy(buf + 3, TEST_BLOB_NAME, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
101 buf = e->start + TEST_NAMED_ARRAY_BUF_OFFSET; in build_aa_ext_struct()
104 strscpy(buf + 3, TEST_ARRAY_NAME, e->end - (void *)(buf + 3)); in build_aa_ext_struct()
108 return e; in build_aa_ext_struct()
120 puf->e = build_aa_ext_struct(puf, test, e_size); in policy_unpack_test_init()
130 KUNIT_EXPECT_TRUE(test, aa_inbounds(puf->e, 0)); in policy_unpack_test_inbounds_when_inbounds()
131 KUNIT_EXPECT_TRUE(test, aa_inbounds(puf->e, puf->e_size / 2)); in policy_unpack_test_inbounds_when_inbounds()
132 KUNIT_EXPECT_TRUE(test, aa_inbounds(puf->e, puf->e_size)); in policy_unpack_test_inbounds_when_inbounds()
139 KUNIT_EXPECT_FALSE(test, aa_inbounds(puf->e, puf->e_size + 1)); in policy_unpack_test_inbounds_when_out_of_bounds()
147 puf->e->pos += TEST_ARRAY_BUF_OFFSET; in policy_unpack_test_unpack_array_with_null_name()
149 KUNIT_EXPECT_TRUE(test, aa_unpack_array(puf->e, NULL, &array_size)); in policy_unpack_test_unpack_array_with_null_name()
151 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_with_null_name()
152 puf->e->start + TEST_ARRAY_BUF_OFFSET + sizeof(u16) + 1); in policy_unpack_test_unpack_array_with_null_name()
161 puf->e->pos += TEST_NAMED_ARRAY_BUF_OFFSET; in policy_unpack_test_unpack_array_with_name()
163 KUNIT_EXPECT_TRUE(test, aa_unpack_array(puf->e, name, &array_size)); in policy_unpack_test_unpack_array_with_name()
165 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_with_name()
166 puf->e->start + TEST_ARRAY_BUF_OFFSET + sizeof(u16) + 1); in policy_unpack_test_unpack_array_with_name()
175 puf->e->pos += TEST_NAMED_ARRAY_BUF_OFFSET; in policy_unpack_test_unpack_array_out_of_bounds()
176 puf->e->end = puf->e->start + TEST_ARRAY_BUF_OFFSET + sizeof(u16); in policy_unpack_test_unpack_array_out_of_bounds()
178 KUNIT_EXPECT_FALSE(test, aa_unpack_array(puf->e, name, &array_size)); in policy_unpack_test_unpack_array_out_of_bounds()
179 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_out_of_bounds()
180 puf->e->start + TEST_NAMED_ARRAY_BUF_OFFSET); in policy_unpack_test_unpack_array_out_of_bounds()
189 puf->e->pos += TEST_BLOB_BUF_OFFSET; in policy_unpack_test_unpack_blob_with_null_name()
190 size = aa_unpack_blob(puf->e, &blob, NULL); in policy_unpack_test_unpack_blob_with_null_name()
203 puf->e->pos += TEST_NAMED_BLOB_BUF_OFFSET; in policy_unpack_test_unpack_blob_with_name()
204 size = aa_unpack_blob(puf->e, &blob, TEST_BLOB_NAME); in policy_unpack_test_unpack_blob_with_name()
218 puf->e->pos += TEST_NAMED_BLOB_BUF_OFFSET; in policy_unpack_test_unpack_blob_out_of_bounds()
219 start = puf->e->pos; in policy_unpack_test_unpack_blob_out_of_bounds()
220 puf->e->end = puf->e->start + TEST_BLOB_BUF_OFFSET in policy_unpack_test_unpack_blob_out_of_bounds()
223 size = aa_unpack_blob(puf->e, &blob, TEST_BLOB_NAME); in policy_unpack_test_unpack_blob_out_of_bounds()
226 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_blob_out_of_bounds()
235 puf->e->pos += TEST_STRING_BUF_OFFSET; in policy_unpack_test_unpack_str_with_null_name()
236 size = aa_unpack_str(puf->e, &string, NULL); in policy_unpack_test_unpack_str_with_null_name()
248 size = aa_unpack_str(puf->e, &string, TEST_STRING_NAME); in policy_unpack_test_unpack_str_with_name()
258 void *start = puf->e->pos; in policy_unpack_test_unpack_str_out_of_bounds()
261 puf->e->end = puf->e->pos + TEST_STRING_BUF_OFFSET in policy_unpack_test_unpack_str_out_of_bounds()
264 size = aa_unpack_str(puf->e, &string, TEST_STRING_NAME); in policy_unpack_test_unpack_str_out_of_bounds()
267 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_str_out_of_bounds()
276 puf->e->pos += TEST_STRING_BUF_OFFSET; in policy_unpack_test_unpack_strdup_with_null_name()
277 size = aa_unpack_strdup(puf->e, &string, NULL); in policy_unpack_test_unpack_strdup_with_null_name()
281 ((uintptr_t)puf->e->start <= (uintptr_t)string) in policy_unpack_test_unpack_strdup_with_null_name()
282 && ((uintptr_t)string <= (uintptr_t)puf->e->end)); in policy_unpack_test_unpack_strdup_with_null_name()
292 size = aa_unpack_strdup(puf->e, &string, TEST_STRING_NAME); in policy_unpack_test_unpack_strdup_with_name()
296 ((uintptr_t)puf->e->start <= (uintptr_t)string) in policy_unpack_test_unpack_strdup_with_name()
297 && ((uintptr_t)string <= (uintptr_t)puf->e->end)); in policy_unpack_test_unpack_strdup_with_name()
304 void *start = puf->e->pos; in policy_unpack_test_unpack_strdup_out_of_bounds()
308 puf->e->end = puf->e->pos + TEST_STRING_BUF_OFFSET in policy_unpack_test_unpack_strdup_out_of_bounds()
311 size = aa_unpack_strdup(puf->e, &string, TEST_STRING_NAME); in policy_unpack_test_unpack_strdup_out_of_bounds()
315 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_strdup_out_of_bounds()
323 puf->e->pos += TEST_U32_BUF_OFFSET; in policy_unpack_test_unpack_nameX_with_null_name()
325 success = aa_unpack_nameX(puf->e, AA_U32, NULL); in policy_unpack_test_unpack_nameX_with_null_name()
328 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_null_name()
329 puf->e->start + TEST_U32_BUF_OFFSET + 1); in policy_unpack_test_unpack_nameX_with_null_name()
337 puf->e->pos += TEST_U32_BUF_OFFSET; in policy_unpack_test_unpack_nameX_with_wrong_code()
339 success = aa_unpack_nameX(puf->e, AA_BLOB, NULL); in policy_unpack_test_unpack_nameX_with_wrong_code()
342 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_wrong_code()
343 puf->e->start + TEST_U32_BUF_OFFSET); in policy_unpack_test_unpack_nameX_with_wrong_code()
352 puf->e->pos += TEST_NAMED_U32_BUF_OFFSET; in policy_unpack_test_unpack_nameX_with_name()
354 success = aa_unpack_nameX(puf->e, AA_U32, name); in policy_unpack_test_unpack_nameX_with_name()
357 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_name()
358 puf->e->start + TEST_U32_BUF_OFFSET + 1); in policy_unpack_test_unpack_nameX_with_name()
367 puf->e->pos += TEST_NAMED_U32_BUF_OFFSET; in policy_unpack_test_unpack_nameX_with_wrong_name()
369 success = aa_unpack_nameX(puf->e, AA_U32, name); in policy_unpack_test_unpack_nameX_with_wrong_name()
372 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_wrong_name()
373 puf->e->start + TEST_NAMED_U32_BUF_OFFSET); in policy_unpack_test_unpack_nameX_with_wrong_name()
382 puf->e->pos += TEST_U16_OFFSET; in policy_unpack_test_unpack_u16_chunk_basic()
388 puf->e->end += TEST_U16_DATA; in policy_unpack_test_unpack_u16_chunk_basic()
390 size = aa_unpack_u16_chunk(puf->e, &chunk); in policy_unpack_test_unpack_u16_chunk_basic()
393 puf->e->start + TEST_U16_OFFSET + 2); in policy_unpack_test_unpack_u16_chunk_basic()
395 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, (chunk + TEST_U16_DATA)); in policy_unpack_test_unpack_u16_chunk_basic()
405 puf->e->pos = puf->e->end - 1; in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
407 size = aa_unpack_u16_chunk(puf->e, &chunk); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
411 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->end - 1); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
421 puf->e->pos += TEST_U16_OFFSET; in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
427 puf->e->end = puf->e->pos + TEST_U16_DATA - 1; in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
429 size = aa_unpack_u16_chunk(puf->e, &chunk); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
433 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->start + TEST_U16_OFFSET); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
442 puf->e->pos += TEST_U32_BUF_OFFSET; in policy_unpack_test_unpack_u32_with_null_name()
444 success = aa_unpack_u32(puf->e, &data, NULL); in policy_unpack_test_unpack_u32_with_null_name()
448 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_with_null_name()
449 puf->e->start + TEST_U32_BUF_OFFSET + sizeof(u32) + 1); in policy_unpack_test_unpack_u32_with_null_name()
459 puf->e->pos += TEST_NAMED_U32_BUF_OFFSET; in policy_unpack_test_unpack_u32_with_name()
461 success = aa_unpack_u32(puf->e, &data, name); in policy_unpack_test_unpack_u32_with_name()
465 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_with_name()
466 puf->e->start + TEST_U32_BUF_OFFSET + sizeof(u32) + 1); in policy_unpack_test_unpack_u32_with_name()
476 puf->e->pos += TEST_NAMED_U32_BUF_OFFSET; in policy_unpack_test_unpack_u32_out_of_bounds()
477 puf->e->end = puf->e->start + TEST_U32_BUF_OFFSET + sizeof(u32); in policy_unpack_test_unpack_u32_out_of_bounds()
479 success = aa_unpack_u32(puf->e, &data, name); in policy_unpack_test_unpack_u32_out_of_bounds()
482 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_out_of_bounds()
483 puf->e->start + TEST_NAMED_U32_BUF_OFFSET); in policy_unpack_test_unpack_u32_out_of_bounds()
492 puf->e->pos += TEST_U64_BUF_OFFSET; in policy_unpack_test_unpack_u64_with_null_name()
494 success = aa_unpack_u64(puf->e, &data, NULL); in policy_unpack_test_unpack_u64_with_null_name()
498 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_with_null_name()
499 puf->e->start + TEST_U64_BUF_OFFSET + sizeof(u64) + 1); in policy_unpack_test_unpack_u64_with_null_name()
509 puf->e->pos += TEST_NAMED_U64_BUF_OFFSET; in policy_unpack_test_unpack_u64_with_name()
511 success = aa_unpack_u64(puf->e, &data, name); in policy_unpack_test_unpack_u64_with_name()
515 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_with_name()
516 puf->e->start + TEST_U64_BUF_OFFSET + sizeof(u64) + 1); in policy_unpack_test_unpack_u64_with_name()
526 puf->e->pos += TEST_NAMED_U64_BUF_OFFSET; in policy_unpack_test_unpack_u64_out_of_bounds()
527 puf->e->end = puf->e->start + TEST_U64_BUF_OFFSET + sizeof(u64); in policy_unpack_test_unpack_u64_out_of_bounds()
529 success = aa_unpack_u64(puf->e, &data, name); in policy_unpack_test_unpack_u64_out_of_bounds()
532 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_out_of_bounds()
533 puf->e->start + TEST_NAMED_U64_BUF_OFFSET); in policy_unpack_test_unpack_u64_out_of_bounds()
539 bool success = aa_unpack_X(puf->e, AA_NAME); in policy_unpack_test_unpack_X_code_match()
542 KUNIT_EXPECT_TRUE(test, puf->e->pos == puf->e->start + 1); in policy_unpack_test_unpack_X_code_match()
548 bool success = aa_unpack_X(puf->e, AA_STRING); in policy_unpack_test_unpack_X_code_mismatch()
551 KUNIT_EXPECT_TRUE(test, puf->e->pos == puf->e->start); in policy_unpack_test_unpack_X_code_mismatch()
559 puf->e->pos = puf->e->end; in policy_unpack_test_unpack_X_out_of_bounds()
560 success = aa_unpack_X(puf->e, AA_NAME); in policy_unpack_test_unpack_X_out_of_bounds()