Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:lf_is_ehdr_sane - check that it is safe to use the ELF header*@buf_len: size of the buffer in which the ELF file is loaded.

Proto:static bool elf_is_ehdr_sane(const struct elf64_hdr *ehdr, size_t buf_len)

Type:bool

Parameter:

TypeParameterName
const struct elf64_hdr *ehdr
size_tbuf_len
65  If e_phnum > 0 && e_phentsize != size of elf_phdr Then
66  pr_debug("Bad program header size.\n")
67  Return false
68  Else if e_shnum > 0 && e_shentsize != size of elf_shdr Then
70  pr_debug("Bad section header size.\n")
71  Return false
72  Else if ELF "magic number" [EI_VERSION] != EV_CURRENT || e_version != EV_CURRENT Then
74  pr_debug("Unknown ELF version.\n")
75  Return false
78  If Program header table file offset > 0 && e_phnum > 0 Then
85  phdr_size = size of elf_phdr * e_phnum
89  pr_debug("Program headers at invalid location.\n")
90  Return false
92  pr_debug("Program headers truncated.\n")
93  Return false
97  If Section header table file offset > 0 && e_shnum > 0 Then
104  shdr_size = size of elf_shdr * e_shnum
108  pr_debug("Section headers at invalid location.\n")
109  Return false
111  pr_debug("Section headers truncated.\n")
112  Return false
116  Return true
Caller
NameDescribe
elf_read_ehdr