函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:test_copy_struct_from_user

函数原型:static int test_copy_struct_from_user(char *kmem, char __user *umem, size_t size)

返回类型:int

参数:

类型参数名称
char *kmem
char __user *umem
size_tsize
108  ret等于0
109  char * umem_src = NULL, * expected = NULL
112  umem_src等于kmalloc(size, GFP_KERNEL)
113  ret等于test(umem_src == NULL, "kmalloc failed")
114  如果ret则转到:out_free
117  expected等于kmalloc(size, GFP_KERNEL)
118  ret等于test(expected == NULL, "kmalloc failed")
119  如果ret则转到:out_free
123  memset(umem_src, 0x3e, size)
124  ret或等于test(copy_to_user(umem, umem_src, size), "legitimate copy_to_user failed")
128  ksize等于size
129  usize等于size
131  内存复制(expected, umem_src, ksize)
133  memset(kmem, 0x0, size)
134  ret或等于test(py_struct_from_user: copy a struct from userspace*@dst: Destination address, in kernel space, "copy_struct_from_user(usize == ksize) failed")
136  ret或等于test(memcmp(kmem, expected, ksize), "copy_struct_from_user(usize == ksize) gives unexpected copy")
140  ksize等于size
141  usize等于size除2
143  内存复制(expected, umem_src, usize)
144  memset(expected + usize, 0x0, ksize - usize)
146  memset(kmem, 0x0, size)
147  ret或等于test(py_struct_from_user: copy a struct from userspace*@dst: Destination address, in kernel space, "copy_struct_from_user(usize < ksize) failed")
149  ret或等于test(memcmp(kmem, expected, ksize), "copy_struct_from_user(usize < ksize) gives unexpected copy")
153  ksize等于size除2
154  usize等于size
156  memset(kmem, 0x0, size)
157  ret或等于test(py_struct_from_user: copy a struct from userspace*@dst: Destination address, in kernel space != - E2BIG, "copy_struct_from_user(usize > ksize) didn't give E2BIG")
161  ksize等于size除2
162  usize等于size
164  内存复制(expected, umem_src, ksize)
165  ret或等于test(用户内存块清零, "legitimate clear_user failed")
168  memset(kmem, 0x0, size)
169  ret或等于test(py_struct_from_user: copy a struct from userspace*@dst: Destination address, in kernel space, "copy_struct_from_user(usize > ksize) failed")
171  ret或等于test(memcmp(kmem, expected, ksize), "copy_struct_from_user(usize > ksize) gives unexpected copy")
174  out_free :
175  kfree(expected)
176  kfree(umem_src)
177  返回:ret
调用者
名称描述
test_user_copy_init