函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\test_user_copy.c Create Date:2022-07-27 07:29:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:test_user_copy_init

函数原型:static int __init test_user_copy_init(void)

返回类型:int

参数:

182  ret等于0
184  __userusermem
194  kmem等于kmalloc(PAGE_SIZE * 2, GFP_KERNEL)
195  如果非kmem则返回:负ENOMEM
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)
201  如果user_addr大于等于TASK_SIZE
202  打印警告信息("Failed to allocate user memory\n")
203  kfree(kmem)
204  返回:负ENOMEM
207  usermem等于user_addr
208  bad_usermem等于user_addr
213  memset(kmem, 0x3a, PAGE_SIZE * 2)
214  ret或等于test(copy_to_user(usermem, kmem, PAGE_SIZE), "legitimate copy_to_user failed")
216  memset(kmem, 0x0, PAGE_SIZE)
217  ret或等于test(copy_from_user(kmem, usermem, PAGE_SIZE), "legitimate copy_from_user failed")
219  ret或等于test(memcmp(kmem, kmem + PAGE_SIZE, PAGE_SIZE), "legitimate usercopy failed to copy data")
239  Legitimate usage: none of these copies should fail.(u8, 0x5a)
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)
257  memset(kmem, 0x5a, PAGE_SIZE)
258  memset(kmem + PAGE_SIZE, 0, 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")
302  Reject kernel-to-kernel copies through copy_from_user(). (u8, 0x5a)
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)
310  vm_munmap(user_addr, PAGE_SIZE * 2)
311  kfree(kmem)
313  如果ret恒等于0则
314  打印信息("tests passed.\n")
315  返回:0
318  返回:负EINVAL