Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:create_elf_tables

Proto:static int create_elf_tables(struct linux_binprm *bprm, struct elf64_hdr *exec, unsigned long load_addr, unsigned long interp_load_addr)

Type:int

Parameter:

TypeParameterName
struct linux_binprm *bprm
struct elf64_hdr *exec
unsigned longload_addr
unsigned longinterp_load_addr
167  p = p
168  argc = argc
169  envc = envc
170  elf_addr_t
170  sp
171  elf_addr_t
171  u_platform
172  elf_addr_t
172  u_base_platform
173  elf_addr_t
173  u_rand_bytes
174  k_platform = ELF_PLATFORM
175  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.
178  elf_addr_t * elf_info
179  ei_index = 0
180  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.()
189  p = arch_align_stack(p)
197  u_platform = NULL
198  If k_platform Then
199  len = strlen - Find the length of a string*@s: The string to be sized + 1
201  u_platform = STACK_ALLOC(p, len)
202  If __copy_to_user(u_platform, k_platform, len) Then Return -EFAULT
210  u_base_platform = NULL
211  If k_base_platform Then
212  len = strlen - Find the length of a string*@s: The string to be sized + 1
214  u_base_platform = STACK_ALLOC(p, len)
215  If __copy_to_user(u_base_platform, k_base_platform, len) Then Return -EFAULT
222  get_random_bytes(k_rand_bytes, size of k_rand_bytes )
223  u_rand_bytes = STACK_ALLOC(p, size of k_rand_bytes )
225  If __copy_to_user(u_rand_bytes, k_rand_bytes, size of k_rand_bytes ) Then Return -EFAULT
229  elf_info = saved_auxv
244  ARCH_DLINFO
246  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (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. )
247  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (system page size , ELF_EXEC_PAGESIZE)
248  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (quency at which times() increments , CLOCKS_PER_SEC)
249  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (program headers for program , load_addr + Program header table file offset )
250  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (size of program header entry , size of elf_phdr )
251  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (umber of program headers , e_phnum)
252  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (ase address of interpreter , interp_load_addr)
253  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (lags , 0)
254  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (ry point of program , Entry point virtual address )
255  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (al uid , 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.)
256  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (ctive uid , 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.)
257  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (al gid , 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.)
258  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (ctive gid , 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.)
259  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (secure mode boolean , secureexec)
260  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (address of 16 random bytes , (elf_addr_t)(unsignedlong)u_rand_bytes)
262  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (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.)
264  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (lename of program , exec)
265  If k_platform Then
266  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (string identifying CPU for optimizations , (elf_addr_t)(unsignedlong)u_platform)
269  If k_base_platform Then
270  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (string identifying real platform, may* differ from AT_PLATFORM. , (elf_addr_t)(unsignedlong)u_base_platform)
273  If interp_flags & BINPRM_FLAGS_EXECFD Then
274  update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes (le descriptor of program , interp_data)
278  memset( & elf_info[ei_index], 0, sizeofsaved_auxv - ei_index * sizeofelf_info[0])
282  ei_index += 2
284  sp = STACK_ADD(p, ei_index)
286  items = argc + 1 + envc + 1 + 1
287  p = STACK_ROUND(sp, items)
294  sp = p
302  vma = d a VMA* - we don't extend stack VMAs under NOMMU conditions
303  If Not vma Then Return -EFAULT
307  If Write a simple value into user space, with less checking(argc, sp++) Then Return -EFAULT
311  p = arg_end = arg_start
312  When argc-- > 0 cycle
314  If Write a simple value into user space, with less checking((elf_addr_t)p, sp++) Then Return -EFAULT
316  len = Get the size of a string in user space
317  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
319  p += len
321  If Write a simple value into user space, with less checking(0, sp++) Then Return -EFAULT
323  arg_end = p
326  env_end = env_start = p
327  When envc-- > 0 cycle
329  If Write a simple value into user space, with less checking((elf_addr_t)p, sp++) Then Return -EFAULT
331  len = Get the size of a string in user space
332  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
334  p += len
336  If Write a simple value into user space, with less checking(0, sp++) Then Return -EFAULT
338  env_end = p
341  If copy_to_user(sp, elf_info, ei_index * size of elf_addr_t ) Then Return -EFAULT
343  Return 0
Caller
NameDescribe
load_elf_binary