From 2aa4510aa8a6133ec0fc36200899289f434cc768 Mon Sep 17 00:00:00 2001 From: geniusgogo <2041245+geniusgogo@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:25:59 +0800 Subject: [PATCH] execute elf add executable permissions check. (#7769) --- components/lwp/lwp.c | 5 +++++ components/lwp/lwp_syscall.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index a9e34f0921..62fa39e0e7 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -1150,6 +1150,11 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp) return -RT_ERROR; } + if (access(filename, X_OK) != 0) + { + return -EACCES; + } + lwp = lwp_new(); if (lwp == RT_NULL) diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index bc9af4d1fa..e89b2db1c0 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -2246,6 +2246,11 @@ sysret_t sys_execve(const char *path, char *const argv[], char *const envp[]) int i; struct lwp_args_info args_info; + if (access(path, X_OK) != 0) + { + return -EACCES; + } + lwp = lwp_self(); thread = rt_thread_self(); uni_thread = 1;