ERRNO链条分析

ERRNO链条纵览

sys_execve
 └─ do_execveat_common()                    [ENOMEM, E2BIG]
     └─ bprm_execve()
         ├─ do_open_execat()                [ENOENT, ENOTDIR, ELOOP, EACCES=13, ETXTBSY]
         │    ├─ do_filp_open()             [ENOENT, ENOTDIR, ELOOP]
         │    ├─ may_open / MAY_EXEC        [EACCES=13]  ← 无执行位 / LSM 拒绝
         │    ├─ S_ISREG + path_noexec      [EACCES=13]  ← 非普通文件 / noexec 挂载
         │    └─ deny_write_access()        [ETXTBSY]
         │
         ├─ prepare_binprm() 读 128B 文件头  [EIO]
         │
         └─ exec_binprm()
             └─ search_binary_handler()     [ENOEXEC=8]  ← 所有 handler 拒绝
                 └─ fmt->load_binary()
                     └─ load_elf_binary()
                         ├─ 校验 e_ident/e_machine/EI_CLASS  [ENOEXEC=8]  ← 架构不匹配
                         ├─ 校验段/权限            [ENOEXEC=8, EINVAL]
                         ├─ open interpreter (ld.so)         [EACCES=13, ENOENT]  ← 再次走 open_exec
                         ├─ vm_mmap 映射段                    [ENOMEM, EACCES=13]
                         └─ point_of_no_return 之后失败 → SIGSEGV / SIGKILL(不返回 errno)


ERRNO=8 (ENOEXEC)

提示:"Exec format error"

源码:
fs/exec.c
image

返回 ENOEXEC

系统调用
do_execveat_common -> bprm_execve -> exec_binprm -> search_binary_handler -> fmt接口方法 -> load_elf_binary()

ERRNO=13 (EACCES)

一般提示:"Permission denied"

do_open_execat 的 rwx 类型权限检查

posted @ 2026-04-21 15:31  蓝天上的云℡  阅读(17)  评论(0)    收藏  举报