You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/09 12:31:32 UTC
(nuttx) 04/09: sched, binfmt: spawning needs PR_CAP_SPAWN
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5745970b1e6736047b2e8682c28da3478d12e819
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Fri Oct 2 06:56:44 2026 +0400
sched, binfmt: spawning needs PR_CAP_SPAWN
exec_internal(), which posix_spawn(), execve() and exec() all reach,
nxtask_spawn_create() and nxtask_create() check it. nxthread_create()
does not: kernel threads go through it too.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
binfmt/binfmt_exec.c | 6 ++++++
sched/task/task_create.c | 5 +++++
sched/task/task_spawn.c | 5 +++++
3 files changed, 16 insertions(+)
diff --git a/binfmt/binfmt_exec.c b/binfmt/binfmt_exec.c
index ae3e4643b1e..c3d6ac4a2e1 100644
--- a/binfmt/binfmt_exec.c
+++ b/binfmt/binfmt_exec.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include <nuttx/kmalloc.h>
+#include <nuttx/sched.h>
#include <nuttx/binfmt/binfmt.h>
#include "binfmt.h"
@@ -86,6 +87,11 @@ static int exec_internal(FAR const char *filename,
int pid;
int ret;
+ if (!nxsched_capable(PR_CAP_SPAWN))
+ {
+ return -EPERM;
+ }
+
#ifndef CONFIG_BINFMT_LOADABLE
bin = &sbin;
memset(bin, 0, sizeof(*bin));
diff --git a/sched/task/task_create.c b/sched/task/task_create.c
index 7b90822cda9..b9e7f494c50 100644
--- a/sched/task/task_create.c
+++ b/sched/task/task_create.c
@@ -165,6 +165,11 @@ int nxtask_create(FAR const char *name, int priority,
FAR void *stack_addr, int stack_size, main_t entry,
FAR char * const argv[], FAR char * const envp[])
{
+ if (!nxsched_capable(PR_CAP_SPAWN))
+ {
+ return -EPERM;
+ }
+
return nxthread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_addr,
stack_size, entry, argv, envp ? envp : environ);
}
diff --git a/sched/task/task_spawn.c b/sched/task/task_spawn.c
index d223ff259b5..aa74e3af85f 100644
--- a/sched/task/task_spawn.c
+++ b/sched/task/task_spawn.c
@@ -94,6 +94,11 @@ static int nxtask_spawn_create(FAR const char *name, int priority,
pid_t pid;
int ret;
+ if (!nxsched_capable(PR_CAP_SPAWN))
+ {
+ return -EPERM;
+ }
+
/* Allocate a TCB for the new task. */
tcb = kmm_zalloc(sizeof(struct tcb_s));