kfence_test.c (64e34b50d7aeee7082287ec39f9d34d4e60f3a04) | kfence_test.c (98931dd95fd489fcbfa97da563505a6f071d7c77) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Test cases for KFENCE memory safety error detector. Since the interface with 4 * which KFENCE's reports are obtained is via the console, this is the output we 5 * should verify. For each test case checks the presence (or absence) of 6 * generated reports. Relies on 'console' tracepoint to capture reports as they 7 * appear in the kernel log. 8 * --- 282 unchanged lines hidden (view full) --- 291 * even for KFENCE objects; these are required so that 292 * memcg accounting works correctly. 293 */ 294 KUNIT_EXPECT_EQ(test, obj_to_index(s, slab, alloc), 0U); 295 KUNIT_EXPECT_EQ(test, objs_per_slab(s, slab), 1); 296 297 if (policy == ALLOCATE_ANY) 298 return alloc; | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Test cases for KFENCE memory safety error detector. Since the interface with 4 * which KFENCE's reports are obtained is via the console, this is the output we 5 * should verify. For each test case checks the presence (or absence) of 6 * generated reports. Relies on 'console' tracepoint to capture reports as they 7 * appear in the kernel log. 8 * --- 282 unchanged lines hidden (view full) --- 291 * even for KFENCE objects; these are required so that 292 * memcg accounting works correctly. 293 */ 294 KUNIT_EXPECT_EQ(test, obj_to_index(s, slab, alloc), 0U); 295 KUNIT_EXPECT_EQ(test, objs_per_slab(s, slab), 1); 296 297 if (policy == ALLOCATE_ANY) 298 return alloc; |
299 if (policy == ALLOCATE_LEFT && IS_ALIGNED((unsigned long)alloc, PAGE_SIZE)) | 299 if (policy == ALLOCATE_LEFT && PAGE_ALIGNED(alloc)) |
300 return alloc; | 300 return alloc; |
301 if (policy == ALLOCATE_RIGHT && 302 !IS_ALIGNED((unsigned long)alloc, PAGE_SIZE)) | 301 if (policy == ALLOCATE_RIGHT && !PAGE_ALIGNED(alloc)) |
303 return alloc; 304 } else if (policy == ALLOCATE_NONE) 305 return alloc; 306 307 test_free(alloc); 308 309 if (time_after(jiffies, resched_after)) 310 cond_resched(); --- 561 unchanged lines hidden --- | 302 return alloc; 303 } else if (policy == ALLOCATE_NONE) 304 return alloc; 305 306 test_free(alloc); 307 308 if (time_after(jiffies, resched_after)) 309 cond_resched(); --- 561 unchanged lines hidden --- |