LoongArch: Preserve syscall nr across execve()
authorHengqi Chen <hengqi.chen@gmail.com>
Sat, 9 Dec 2023 07:49:15 +0000 (15:49 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 9 Dec 2023 07:49:15 +0000 (15:49 +0800)
commitd6c5f06e46a836e6a70c7cfd95bb38a67d9252ec
tree4c0f0e9285c938ebb4ed74d3366e62be36107996
parent97ceddbc9404a7d1e2c4049435bff29427d762cc
LoongArch: Preserve syscall nr across execve()

Currently, we store syscall nr in pt_regs::regs[11] and syscall execve()
accidentally overrides it during its execution:

    sys_execve()
      -> do_execve()
        -> do_execveat_common()
          -> bprm_execve()
            -> exec_binprm()
              -> search_binary_handler()
                -> load_elf_binary()
                  -> ELF_PLAT_INIT()

ELF_PLAT_INIT() reset regs[11] to 0, so in syscall_exit_to_user_mode()
we later get a wrong syscall nr. This breaks tools like execsnoop since
it relies on execve() tracepoints.

Skip pt_regs::regs[11] reset in ELF_PLAT_INIT() to fix the issue.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/elf.h