函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:kernel_read_file

函数原型:int kernel_read_file(struct file *file, void **buf, loff_t *size, loff_t max_size, enum kernel_read_file_id id)

返回类型:int

参数:

类型参数名称
struct file *file
void **buf
loff_t *size
loff_tmax_size
enum kernel_read_file_idid
899  bytes等于0
902  如果非S_ISREG(i_mode)或max_size小于0则返回:负EINVAL
905  ret等于deny_write_access(file)
906  如果ret则返回:ret
909  ret等于security_kernel_read_file(file, id)
910  如果ret则转到:out
913  i_size等于NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they
914  如果i_size小于等于0则
915  ret等于负EINVAL
916  转到:out
918  如果i_size大于SIZE_MAXmax_size大于0且i_size大于max_size
919  ret等于负EFBIG
920  转到:out
923  如果id不等于READING_FIRMWARE_PREALLOC_BUFFERbuf等于vmalloc - allocate virtually contiguous memory*@size: allocation size* Allocate enough pages to cover @size from the page level* allocator and map them into contiguous kernel virtual space.* For tight control over page level allocator and protection flags
925  如果非buf
926  ret等于负ENOMEM
927  转到:out
930  pos等于0
931 pos小于i_size循环
932  bytes等于kernel_read(file, * buf + pos, i_size - pos, & pos)
933  如果bytes小于0则
934  ret等于bytes
935  转到:out_free
938  如果bytes恒等于0则退出
942  如果pos不等于i_size
943  ret等于负EIO
944  转到:out_free
947  ret等于security_kernel_post_read_file(file, * buf, i_size, id)
948  如果非retsize等于pos
951  out_free :
952  如果ret小于0则
953  如果id不等于READING_FIRMWARE_PREALLOC_BUFFER
954  vfree( * buf)
955  * buf = NULL
959  out :
960  allow_write_access(file)
961  返回:ret
调用者
名称描述
kernel_read_file_from_path
kernel_read_file_from_fd