函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:load an fdpic binary into various bits of memory

函数原型:static int load_elf_fdpic_binary(struct linux_binprm *bprm)

返回类型:int

参数:

类型参数名称
struct linux_binprm *bprm
185  regs等于current_pt_regs()
194  struct file * interpreter = NULL
195  char * interpreter_name = NULL
200  kdebug("____ LOAD %d ____", pid)
202  memset( & exec_params, 0, exec_params的长度)
203  memset( & interp_params, 0, interp_params的长度)
205  copy of ELF header 等于buf
206  flags等于T if this object is present 按位或T if this object is the executable
209  retval等于负ENOEXEC
210  如果非is_elf( & copy of ELF header , file)则转到:error
212  如果非That's for binfmt_elf_fdpic to deal with ( & copy of ELF header )则
215  转到:error
224  retval等于ad the program headers table into memory
225  如果retval小于0则转到:error
229  phdr等于 copy of PT_PHDR table
231 i小于e_phnum循环
233  :p_type恒等于PT_INTERP
234  retval等于负ENOMEM
237  retval等于负ENOENT
238  如果p_filesz小于2则转到:error
243  如果非interpreter_name则转到:error
246  pos等于p_offset
250  如果retval大于等于0则retval等于负ENOEXEC
252  转到:error
255  retval等于负ENOENT
256  如果interpreter_name[p_filesz - 1]不等于'\0'则转到:error
259  kdebug("Using ELF interpreter %s", interpreter_name)
263  retval等于错误
264  如果是错误
265  interpreter = NULL
266  转到:error
276  pos等于0
280  如果retval大于等于0则retval等于负ENOEXEC
282  转到:error
286  退出
288  :p_type恒等于PT_LOAD
293  退出
298  如果is_constdisp( & copy of ELF header )则flags或等于PT_LOADs require constant* displacement
302  如果interpreter_name
303  retval等于负ELIBBAD
304  如果非is_elf( & copy of ELF header , interpreter)则转到:error
307  flags等于T if this object is present
310  retval等于ad the program headers table into memory
311  如果retval小于0则转到:error
315  stack_size等于stack size requested (PT_GNU_STACK)
316  如果flags按位与T if stack to be executable executable_stack等于Enable executable stacks
318  否则如果flags按位与T if stack not to be executable executable_stack等于Disable executable stacks
320  否则executable_stack等于Whatever the arch defaults to
323  如果stack_size恒等于0则
324  stack_size等于stack size requested (PT_GNU_STACK)
325  如果flags按位与T if stack to be executable executable_stack等于Enable executable stacks
327  否则如果flags按位与T if stack not to be executable executable_stack等于Disable executable stacks
329  否则executable_stack等于Whatever the arch defaults to
333  retval等于负ENOEXEC
334  如果stack_size恒等于0则stack_size等于131072UL
337  如果is_constdisp( & copy of ELF header )则flags或等于PT_LOADs require constant* displacement
341  retval等于Calling this is the point of no return. None of the failures will be* seen by userspace since either the process is already taking a fatal* signal (via de_thread() or coredump), or will have SEGV raised
342  如果retval则转到:error
348  如果That's for binfmt_elf_fdpic to deal with ( & copy of ELF header )则Change personality of the currently running process.(PER_LINUX_FDPIC)
350  否则Change personality of the currently running process.(PER_LINUX)
352  如果An executable for which elf_read_implies_exec() returns TRUE will* have the READ_IMPLIES_EXEC personality flag set automatically.( & copy of ELF header , executable_stack)则personality或等于READ_IMPLIES_EXEC
355  setup_new_exec(bprm)
357  set_binfmt( & elf_fdpic_format)
359  start_code等于0
360  end_code等于0
361  start_stack等于0
362  start_data等于0
363  end_data等于0
364  exec_fdpic_loadmap等于0
365  interp_fdpic_loadmap等于0
368  elf_fdpic_arch_lay_out_mm( & exec_params, & interp_params, & start_stack, & start_brk)
373  retval等于Finalizes the stack vm_area_struct. The flags and permissions are updated,* the stack is optionally relocated, and some extra space is added.
375  如果retval小于0则转到:error
378  retval等于arch_setup_additional_pages(bprm, !!interpreter_name)
379  如果retval小于0则转到:error
385  retval等于load the appropriate binary image (executable or interpreter) into memory* - we assume no MMU is available* - if no other PIC bits are set in params->hdr->e_flags* - we assume that the LOADable segments in the binary are independently relocatable* - we
387  如果retval小于0则转到:error
390  如果interpreter_name
391  retval等于load the appropriate binary image (executable or interpreter) into memory* - we assume no MMU is available* - if no other PIC bits are set in params->hdr->e_flags* - we assume that the LOADable segments in the binary are independently relocatable* - we
393  如果retval小于0则
395  转到:error
398  allow_write_access(interpreter)
399  fput(interpreter)
400  interpreter = NULL
404  如果非start_brkstart_brk等于end_data
407  brk等于start_brk等于 align the pointer to the (next) page boundary (start_brk)
437  stall the new credentials for this executable
438  如果present useful information to the program by shovelling it onto the new* process's stack小于0则转到:error
442  kdebug("- start_code %lx", start_code)
443  kdebug("- end_code %lx", end_code)
444  kdebug("- start_data %lx", start_data)
445  kdebug("- end_data %lx", end_data)
446  kdebug("- start_brk %lx", start_brk)
447  kdebug("- brk %lx", brk)
448  kdebug("- start_stack %lx", start_stack)
462  Runs immediately before start_thread() takes over.
464  entryaddr等于如果mapped entry user address 否则mapped entry user address
465  start_thread(regs, entryaddr, start_stack)
467  retval等于0
469  error :
470  如果interpreter
471  allow_write_access(interpreter)
472  fput(interpreter)
474  释放内存
475  释放内存
476  释放内存
477  释放内存
478  释放内存
479  返回:retval