Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\binfmt_elf_fdpic.c Create Date:2022-07-28 20:29:04
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:present useful information to the program by shovelling it onto the new* process's stack

Proto:static int create_elf_fdpic_tables(struct linux_binprm *bprm, struct mm_struct *mm, struct elf_fdpic_params *exec_params, struct elf_fdpic_params *interp_params)

Type:int

Parameter:

TypeParameterName
struct linux_binprm *bprm
struct mm_struct *mm
struct elf_fdpic_params *exec_params
struct elf_fdpic_params *interp_params
502  cred = current_cred - Access the current task's subjective credentials* Access the subjective credentials of the current task. RCU-safe,* since nobody else can modify it.()
504  __user * argv
505  platform_len = 0
507  __user * u_platform
517  sp = arch_align_stack(p)
533  k_platform = ELF_PLATFORM
534  u_platform = NULL
536  If k_platform Then
537  platform_len = strlen - Find the length of a string*@s: The string to be sized + 1
538  sp -= platform_len
539  u_platform = sp
540  If __copy_to_user(u_platform, k_platform, platform_len) != 0 Then Return -EFAULT
548  k_base_platform = AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.* If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value* will be copied to the user stack in the same manner as AT_PLATFORM.
549  u_base_platform = NULL
551  If k_base_platform Then
552  platform_len = strlen - Find the length of a string*@s: The string to be sized + 1
553  sp -= platform_len
554  u_base_platform = sp
555  If __copy_to_user(u_base_platform, k_base_platform, platform_len) != 0 Then Return -EFAULT
559  sp &= ~7UL
562  len = sizeof(structelf32_fdpic_loadmap)
563  len += sizeof(structelf32_fdpic_loadseg) * number of segments
564  sp = sp - len & ~7UL
565  mapped loadmap user address = sp
567  If copy_to_user((void__user * )sp, loadmap to be passed to userspace , len) != 0 Then Return -EFAULT
570  exec_fdpic_loadmap = sp
572  If loadmap to be passed to userspace Then
573  len = sizeof(structelf32_fdpic_loadmap)
574  len += sizeof(structelf32_fdpic_loadseg) * number of segments
576  sp = sp - len & ~7UL
577  mapped loadmap user address = sp
579  If copy_to_user((void__user * )sp, loadmap to be passed to userspace , len) != 0 Then Return -EFAULT
583  interp_fdpic_loadmap = sp
589  nitems = 1 + rce 16 byte _final_ alignment here for generality + If k_platform Then 1 Else 0 + If k_base_platform Then 1 Else 0 + ries in ARCH_DLINFO:
592  If interp_flags & BINPRM_FLAGS_EXECFD Then nitems++
595  csp = sp
596  sp -= nitems * 2 * sizeof(unsignedlong)
597  sp -= (envc + 1) * size of *
598  sp -= (argc + 1) * size of *
599  sp -= 1 * sizeof(unsignedlong)
601  csp -= sp & 15UL
602  sp -= sp & 15UL
615  nr = 0
616  csp -= 2 * sizeof(unsignedlong)
617  put the ELF interpreter info on the stack (d of vector , 0)
618  If k_platform Then
619  nr = 0
620  csp -= 2 * sizeof(unsignedlong)
621  put the ELF interpreter info on the stack (string identifying CPU for optimizations , (elf_addr_t)(unsignedlong)u_platform)
625  If k_base_platform Then
626  nr = 0
627  csp -= 2 * sizeof(unsignedlong)
628  put the ELF interpreter info on the stack (string identifying real platform, may* differ from AT_PLATFORM. , (elf_addr_t)(unsignedlong)u_base_platform)
632  If interp_flags & BINPRM_FLAGS_EXECFD Then
633  nr = 0
634  csp -= 2 * sizeof(unsignedlong)
635  put the ELF interpreter info on the stack (le descriptor of program , interp_data)
638  nr = 0
639  csp -= rce 16 byte _final_ alignment here for generality * 2 * sizeof(unsignedlong)
640  put the ELF interpreter info on the stack (arch dependent hints at CPU capabilities , This yields a mask that user programs can use to figure out whatinstruction set this CPU supports. This could be done in user space,but it's not easy, and we've already done it here. )
642  put the ELF interpreter info on the stack (xtension of AT_HWCAP , HWCAP2 supplies mask with kernel enabled CPU features, so that* the application can discover that it can safely use them.* The bits are defined in uapi/asm/hwcap2.h.)
644  put the ELF interpreter info on the stack (system page size , PAGE_SIZE)
645  put the ELF interpreter info on the stack (quency at which times() increments , CLOCKS_PER_SEC)
646  put the ELF interpreter info on the stack (program headers for program , mapped PT_PHDR user address )
647  put the ELF interpreter info on the stack (size of program header entry , size of elf_phdr )
648  put the ELF interpreter info on the stack (umber of program headers , e_phnum)
649  put the ELF interpreter info on the stack (ase address of interpreter , mapped ELF header user address )
650  put the ELF interpreter info on the stack (lags , 0)
651  put the ELF interpreter info on the stack (ry point of program , mapped entry user address )
652  put the ELF interpreter info on the stack (al uid , (elf_addr_t)m_kuid_munged - Create a uid from a kuid user-namespace pair.*@targ: The user namespace we want a uid in.*@kuid: The kernel internal uid to start with.* Map @kuid into the user-namespace specified by @targ and* return the resulting uid.)
653  put the ELF interpreter info on the stack (ctive uid , (elf_addr_t)m_kuid_munged - Create a uid from a kuid user-namespace pair.*@targ: The user namespace we want a uid in.*@kuid: The kernel internal uid to start with.* Map @kuid into the user-namespace specified by @targ and* return the resulting uid.)
654  put the ELF interpreter info on the stack (al gid , (elf_addr_t)m_kgid_munged - Create a gid from a kgid user-namespace pair.*@targ: The user namespace we want a gid in.*@kgid: The kernel internal gid to start with.* Map @kgid into the user-namespace specified by @targ and* return the resulting gid.)
655  put the ELF interpreter info on the stack (ctive gid , (elf_addr_t)m_kgid_munged - Create a gid from a kgid user-namespace pair.*@targ: The user namespace we want a gid in.*@kgid: The kernel internal gid to start with.* Map @kgid into the user-namespace specified by @targ and* return the resulting gid.)
656  put the ELF interpreter info on the stack (secure mode boolean , secureexec)
657  put the ELF interpreter info on the stack (lename of program , exec)
660  nr = 0
661  csp -= ries in ARCH_DLINFO: * 2 * sizeof(unsignedlong)
666  ARCH_DLINFO
671  csp -= (envc + 1) * sizeof(elf_caddr_t)
672  envp = csp
673  csp -= (argc + 1) * sizeof(elf_caddr_t)
674  argv = csp
677  csp -= sizeof(unsignedlong)
678  Write a simple value into user space, with less checking(argc, (unsignedlong__user * )csp)
680  BUG_ON(csp != sp)
684  arg_start = p
690  p = arg_start
691  When loop > 0 cycle
692  Write a simple value into user space, with less checking((elf_caddr_t)p, argv++)
693  len = Get the size of a string in user space
694  If Not len || len > These are the maximum length and maximum number of strings passed to the* execve() system call. MAX_ARG_STRLEN is essentially random but serves to* prevent the kernel from being unduly impacted by misaddressed pointers. Then Return -EINVAL
696  p += len
698  Write a simple value into user space, with less checking(NULL, argv)
699  arg_end = p
702  env_start = p
703  When loop > 0 cycle
704  Write a simple value into user space, with less checking((elf_caddr_t)(unsignedlong)p, envp++)
705  len = Get the size of a string in user space
706  If Not len || len > These are the maximum length and maximum number of strings passed to the* execve() system call. MAX_ARG_STRLEN is essentially random but serves to* prevent the kernel from being unduly impacted by misaddressed pointers. Then Return -EINVAL
708  p += len
710  Write a simple value into user space, with less checking(NULL, envp)
711  env_end = p
713  start_stack = sp
714  Return 0
Caller
NameDescribe
load_elf_fdpic_binaryload an fdpic binary into various bits of memory