Function report |
Source Code:lib\test_user_copy.c |
Create Date:2022-07-28 06:32:03 |
Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:test_user_copy_init
Proto:static int __init test_user_copy_init(void)
Type:int
Parameter:Nothing
182 | ret = 0 |
194 | kmem = kmalloc(PAGE_SIZE * 2, GFP_KERNEL) |
198 | user_addr = vm_mmap(NULL, 0, PAGE_SIZE * 2, page can be read | page can be written | page can be executed , don't use a file | Changes are private , 0) |
208 | bad_usermem = user_addr |
219 | ret |= test(memcmp(kmem, kmem + PAGE_SIZE, PAGE_SIZE), "legitimate usercopy failed to copy data") |
240 | Legitimate usage: none of these copies should fail.(u16, 0x5a5b) |
241 | Legitimate usage: none of these copies should fail.(u32, 0x5a5b5c5d) |
243 | Legitimate usage: none of these copies should fail.(u64, 0x5a5b5c5d6a6b6c6d) |
248 | ret |= test_check_nonzero_user(kmem, usermem, 2 * PAGE_SIZE) |
250 | ret |= test_copy_struct_from_user(kmem, usermem, 2 * PAGE_SIZE) |
261 | ret |= test(!copy_from_user(kmem, (char__user * )(kmem + PAGE_SIZE), PAGE_SIZE), "illegal all-kernel copy_from_user passed") |
266 | ret |= test(memcmp(kmem + PAGE_SIZE, kmem, PAGE_SIZE), "zeroing failure for illegal all-kernel copy_from_user") |
280 | ret |= test(!copy_to_user((char__user * )kmem, kmem + PAGE_SIZE, PAGE_SIZE), "illegal all-kernel copy_to_user passed") |
283 | ret |= test(!copy_to_user((char__user * )kmem, bad_usermem, PAGE_SIZE), "illegal reversed copy_to_user passed") |
303 | Reject kernel-to-kernel copies through copy_from_user(). (u16, 0x5a5b) |
304 | Reject kernel-to-kernel copies through copy_from_user(). (u32, 0x5a5b5c5d) |
306 | Reject kernel-to-kernel copies through copy_from_user(). (u64, 0x5a5b5c5d6a6b6c6d) |
313 | If ret == 0 Then |
314 | pr_info("tests passed.\n") |
315 | Return 0 |
318 | Return -EINVAL |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |