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:28 UTC
(nuttx) branch master updated (fdf5ea919e1 -> 24368b8008e)
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from fdf5ea919e1 boards/arm64/qemu/qemu-armv8a: switch citest/citest_smp to nxinit
new e70cd6bf455 sched: process capabilities
new 90ab43a7f5f drivers/bch: nxstyle in bchdev_driver.c
new e55c0737997 fs: raw storage needs PR_CAP_RAWIO
new 5745970b1e6 sched, binfmt: spawning needs PR_CAP_SPAWN
new ab63263b7f9 boards: nxstyle in boardctl.c
new 66eac21f687 boards: reset and power-off need PR_CAP_ADMIN
new 36cb05ca2f6 Documentation: codespell in os/scheduling/index.rst
new 4c76b78e932 Documentation: describe process capabilities
new 24368b8008e boards/stm32g4: leave capabilities out of the cansock configs
The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Documentation/os/scheduling/capabilities.rst | 27 ++++++++
Documentation/os/scheduling/index.rst | 9 +--
binfmt/binfmt_exec.c | 6 ++
.../stm32g4/b-g431b-esc1/configs/cansock/defconfig | 1 +
.../nucleo-g431rb/configs/cansock/defconfig | 1 +
boards/boardctl.c | 78 +++++++++++++---------
drivers/bch/bchdev_driver.c | 32 +++++----
fs/mount/fs_mount.c | 6 ++
fs/mount/fs_umount2.c | 6 ++
fs/vfs/fs_open.c | 7 ++
include/nuttx/sched.h | 8 +++
include/sys/prctl.h | 7 ++
sched/Kconfig | 11 +++
sched/group/group_create.c | 4 ++
sched/init/nx_start.c | 1 +
sched/task/task_create.c | 5 ++
sched/task/task_prctl.c | 16 +++--
sched/task/task_spawn.c | 5 ++
18 files changed, 175 insertions(+), 55 deletions(-)
create mode 100644 Documentation/os/scheduling/capabilities.rst
(nuttx) 08/09: Documentation: describe process capabilities
Posted by ac...@apache.org.
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 4c76b78e93286f27439f88d945abeccfa8a48086
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Thu Oct 1 15:12:24 2026 +0400
Documentation: describe process capabilities
What each capability guards, the prctl() interface, inheritance through
the task group, and where the checks sit.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
Documentation/os/scheduling/capabilities.rst | 27 +++++++++++++++++++++++++++
Documentation/os/scheduling/index.rst | 1 +
2 files changed, 28 insertions(+)
diff --git a/Documentation/os/scheduling/capabilities.rst b/Documentation/os/scheduling/capabilities.rst
new file mode 100644
index 00000000000..23e979a8294
--- /dev/null
+++ b/Documentation/os/scheduling/capabilities.rst
@@ -0,0 +1,27 @@
+.. _capabilities:
+
+====================
+Process capabilities
+====================
+
+A process holds three capabilities. Without one, the calls it guards fail
+with ``EPERM``. Every build, the kernel and init start with all three.
+``CONFIG_SCHED_CAPABILITIES``, off with ``DEFAULT_SMALL``, builds the checks.
+
+================= ==================================================
+``PR_CAP_RAWIO`` ``open()`` of block, MTD and BCH nodes,
+ ``mount()``, ``umount2()``
+``PR_CAP_SPAWN`` ``posix_spawn()``, ``task_spawn()``,
+ ``task_create()``, ``exec()``, ``execve()``
+``PR_CAP_ADMIN`` ``boardctl()`` reset and poweroff
+================= ==================================================
+
+.. code-block:: c
+
+ prctl(PR_CAPS_DROP, PR_CAP_RAWIO | PR_CAP_SPAWN);
+ int caps = prctl(PR_CAPS_GET);
+
+A drop is permanent. The set lives in the task group and a new group copies
+its creator's. The checks sit in the internal functions, so kernel code
+running for a process is held to that process's set. Kernel threads hold
+all three.
diff --git a/Documentation/os/scheduling/index.rst b/Documentation/os/scheduling/index.rst
index 334870776e7..6668ff4695b 100644
--- a/Documentation/os/scheduling/index.rst
+++ b/Documentation/os/scheduling/index.rst
@@ -237,3 +237,4 @@ In this section
wqueue.rst
tls.rst
user_identity.rst
+ capabilities.rst
(nuttx) 02/09: drivers/bch: nxstyle in bchdev_driver.c
Posted by ac...@apache.org.
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 90ab43a7f5f73a93f454b6e5c38193253a5a8352
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Thu Oct 1 20:53:34 2026 +0400
drivers/bch: nxstyle in bchdev_driver.c
Indent the bch_seek() switch cases so the file passes nxstyle.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
drivers/bch/bchdev_driver.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c
index a7a05859721..0d4660264c8 100644
--- a/drivers/bch/bchdev_driver.c
+++ b/drivers/bch/bchdev_driver.c
@@ -240,24 +240,24 @@ static off_t bch_seek(FAR struct file *filep, off_t offset, int whence)
switch (whence)
{
- case SEEK_CUR:
- newpos = filep->f_pos + offset;
- break;
+ case SEEK_CUR:
+ newpos = filep->f_pos + offset;
+ break;
- case SEEK_SET:
- newpos = offset;
- break;
+ case SEEK_SET:
+ newpos = offset;
+ break;
- case SEEK_END:
- newpos = (off_t)bch->sectsize * bch->nsectors + offset;
- break;
+ case SEEK_END:
+ newpos = (off_t)bch->sectsize * bch->nsectors + offset;
+ break;
- default:
+ default:
- /* Return EINVAL if the whence argument is invalid */
+ /* Return EINVAL if the whence argument is invalid */
- nxmutex_unlock(&bch->lock);
- return -EINVAL;
+ nxmutex_unlock(&bch->lock);
+ return -EINVAL;
}
/* Opengroup.org:
(nuttx) 07/09: Documentation: codespell in os/scheduling/index.rst
Posted by ac...@apache.org.
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 36cb05ca2f64b5ae63626787a4c9aafa066ccc75
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Thu Oct 8 15:52:12 2026 +0400
Documentation: codespell in os/scheduling/index.rst
codespell flags pre-empted in this page, so any change to it fails the
check. Spell it preempted.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
Documentation/os/scheduling/index.rst | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/os/scheduling/index.rst b/Documentation/os/scheduling/index.rst
index 97bef15e4a3..334870776e7 100644
--- a/Documentation/os/scheduling/index.rst
+++ b/Documentation/os/scheduling/index.rst
@@ -48,7 +48,7 @@ they are not alike. ``ASSIGNED`` is ``READYTORUN`` with a CPU already
picked, and it is the conditional one -- it exists only under
``CONFIG_SMP``. ``PENDING`` is always compiled, and it is narrower than its
name suggests: a thread goes there only if it became ready while another
-thread held ``sched_lock()`` **and** would have pre-empted it.
+thread held ``sched_lock()`` **and** would have preempted it.
``nxsched_add_readytorun()`` tests both halves --
``nxsched_islocked_tcb(rtcb)`` and a new priority higher than the running
thread's -- so a thread that becomes ready at equal or lower priority under
@@ -84,7 +84,7 @@ lower-priority thread run ahead of a higher-priority one.
``SCHED_FIFO`` -- run to completion
-----------------------------------
-A thread runs until it blocks, exits, or is pre-empted by something of
+A thread runs until it blocks, exits, or is preempted by something of
higher priority. Two threads of the same priority do not share the CPU: the
first one to start keeps it until it gives it up.
@@ -154,7 +154,7 @@ worth reading twice. ``sched_sporadic.c`` asserts
Give a thread a 10 ms budget and a 100 ms period and it runs high for up to
10 ms, low for the other 90, and is promoted again 100 ms after the cycle
began -- not 100 ms after the budget ran out. ``sched_ss_max_repl`` bounds a
-second mechanism rather than this one: when the thread is pre-empted part-way
+second mechanism rather than this one: when the thread is preempted part-way
through its budget, each fragment is replenished one period after it was
consumed, and the field caps how many such replenishments may be outstanding
at once.
@@ -210,7 +210,7 @@ Two interfaces are specific to NuttX and worth naming here:
Hold off the scheduler without disabling interrupts. Interrupts still
run; what is suspended is the switch to another thread. A thread that
becomes ready while pre-emption is locked goes to ``PENDING``, provided it
- would have pre-empted the thread holding the lock. This is
+ would have preempted the thread holding the lock. This is
cheaper and far less disruptive than disabling interrupts, and it is
almost always the right tool when the goal is "do not switch away from
me" rather than "do not interrupt me". See
(nuttx) 04/09: sched, binfmt: spawning needs PR_CAP_SPAWN
Posted by ac...@apache.org.
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));
(nuttx) 01/09: sched: process capabilities
Posted by ac...@apache.org.
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 e70cd6bf455f496c2cd3ff754e8269c998d84a9e
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Fri Oct 2 06:56:34 2026 +0400
sched: process capabilities
A task group holds PR_CAP_RAWIO, PR_CAP_SPAWN and PR_CAP_ADMIN, inherits
them from its creator and can only drop them. Every build: the kernel and
init start with all three, so nothing changes until a task drops one.
CONFIG_SCHED_CAPABILITIES, off with DEFAULT_SMALL, lets a board short of
flash leave the checks out.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
include/nuttx/sched.h | 8 ++++++++
include/sys/prctl.h | 7 +++++++
sched/Kconfig | 11 +++++++++++
sched/group/group_create.c | 4 ++++
sched/init/nx_start.c | 1 +
sched/task/task_prctl.c | 16 ++++++++++------
6 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 09916b833d6..ddb650e2d9f 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -33,6 +33,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <sched.h>
+#include <sys/prctl.h>
#include <signal.h>
#include <pthread.h>
#include <time.h>
@@ -456,6 +457,7 @@ struct task_group_s
pid_t tg_pid; /* The ID of the task within the group */
pid_t tg_ppid; /* This is the ID of the parent thread */
uint8_t tg_flags; /* See GROUP_FLAG_* definitions */
+ uint8_t tg_caps; /* See PR_CAP_* definitions */
/* User identity (POSIX real, effective, and saved-set IDs) ***************/
@@ -924,6 +926,12 @@ static inline_function bool nxsched_has_gid(FAR struct tcb_s *tcb,
FAR struct tcb_s *nxsched_self(void);
+#ifdef CONFIG_SCHED_CAPABILITIES
+# define nxsched_capable(c) ((nxsched_self()->group->tg_caps & (c)) == (c))
+#else
+# define nxsched_capable(c) true
+#endif
+
/****************************************************************************
* Name: nxsched_foreach
*
diff --git a/include/sys/prctl.h b/include/sys/prctl.h
index aea419244f2..9315266b357 100644
--- a/include/sys/prctl.h
+++ b/include/sys/prctl.h
@@ -78,6 +78,13 @@
#define PR_SET_DUMPABLE 5
#define PR_GET_DUMPABLE 6
+#define PR_CAPS_DROP 7
+#define PR_CAPS_GET 8
+
+#define PR_CAP_RAWIO (1 << 0)
+#define PR_CAP_SPAWN (1 << 1)
+#define PR_CAP_ADMIN (1 << 2)
+#define PR_CAP_ALL (PR_CAP_RAWIO | PR_CAP_SPAWN | PR_CAP_ADMIN)
/****************************************************************************
* Public Type Definitions
diff --git a/sched/Kconfig b/sched/Kconfig
index ed0e8c512f4..b20c4be8584 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -817,6 +817,17 @@ config SCHED_NGROUPS
endif # SCHED_USER_IDENTITY
+config SCHED_CAPABILITIES
+ bool "Process capabilities"
+ default !DEFAULT_SMALL
+ ---help---
+ Task groups hold PR_CAP_RAWIO, PR_CAP_SPAWN and PR_CAP_ADMIN,
+ inherit them from their creator and can drop them with
+ prctl(PR_CAPS_DROP). Raw storage, mount, spawn, reset and
+ power-off then need the matching capability. Without this
+ option every check passes and prctl() refuses PR_CAPS_DROP and
+ PR_CAPS_GET.
+
config SCHED_THREAD_LOCAL
bool "Support __thread/thread_local keyword"
default n
diff --git a/sched/group/group_create.c b/sched/group/group_create.c
index 71e288c7bd8..5febd80e11b 100644
--- a/sched/group/group_create.c
+++ b/sched/group/group_create.c
@@ -196,6 +196,7 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
{
group = &g_kthread_group;
tcb->group = group;
+ group->tg_caps = PR_CAP_ALL;
if (group->tg_info)
{
return OK;
@@ -250,6 +251,9 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
goto errout_with_group;
}
+ group->tg_caps = this_task()->group != NULL ?
+ this_task()->group->tg_caps : PR_CAP_ALL;
+
/* Initialize file descriptors for the TCB */
fdlist_init(&group->tg_fdlist);
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index dd27cdf9f73..7953744a871 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -476,6 +476,7 @@ static void idle_group_initialize(void)
group_initialize(tcb);
tcb->group->tg_flags = GROUP_FLAG_NOCLDWAIT | GROUP_FLAG_PRIVILEGED;
+ tcb->group->tg_caps = PR_CAP_ALL;
}
}
diff --git a/sched/task/task_prctl.c b/sched/task/task_prctl.c
index b065eeae833..988613b11f0 100644
--- a/sched/task/task_prctl.c
+++ b/sched/task/task_prctl.c
@@ -187,20 +187,24 @@ int prctl(int option, ...)
goto errout;
#endif
+#ifdef CONFIG_SCHED_CAPABILITIES
+ case PR_CAPS_DROP:
+ this_task()->group->tg_caps &= ~va_arg(ap, int);
+ break;
+
+ case PR_CAPS_GET:
+ va_end(ap);
+ return this_task()->group->tg_caps;
+#endif
+
default:
serr("ERROR: Unrecognized option: %d\n", option);
errcode = EINVAL;
goto errout;
}
- /* Not reachable unless CONFIG_TASK_NAME_SIZE is > 0. NOTE: This might
- * change if additional commands are supported.
- */
-
-#if CONFIG_TASK_NAME_SIZE > 0
va_end(ap);
return OK;
-#endif
errout:
va_end(ap);
(nuttx) 05/09: boards: nxstyle in boardctl.c
Posted by ac...@apache.org.
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 ab63263b7f96940276567afed3776ee65fe3a9ca
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Thu Oct 1 15:05:34 2026 +0400
boards: nxstyle in boardctl.c
Indentation and comment fixes only, so the next change passes the style
check.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
boards/boardctl.c | 65 ++++++++++++++++++++++++++++---------------------------
1 file changed, 33 insertions(+), 32 deletions(-)
diff --git a/boards/boardctl.c b/boards/boardctl.c
index 3b63ca4d5ae..f78d0e77cc2 100644
--- a/boards/boardctl.c
+++ b/boards/boardctl.c
@@ -604,8 +604,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
FAR const struct boardioc_symtab_s *symdesc =
(FAR const struct boardioc_symtab_s *)arg;
- DEBUGASSERT(symdesc != NULL);
- exec_setsymtab(symdesc->symtab, symdesc->nsymbols);
+ DEBUGASSERT(symdesc != NULL);
+ exec_setsymtab(symdesc->symtab, symdesc->nsymbols);
}
break;
#endif
@@ -625,8 +625,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
FAR const struct boardioc_symtab_s *symdesc =
(FAR const struct boardioc_symtab_s *)arg;
- DEBUGASSERT(symdesc != NULL);
- libelf_setsymtab(symdesc->symtab, symdesc->nsymbols);
+ DEBUGASSERT(symdesc != NULL);
+ libelf_setsymtab(symdesc->symtab, symdesc->nsymbols);
}
break;
#endif
@@ -658,8 +658,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
FAR const struct boardioc_builtin_s *builtin =
(FAR const struct boardioc_builtin_s *)arg;
- DEBUGASSERT(builtin != NULL);
- builtin_setlist(builtin->builtins, builtin->count);
+ DEBUGASSERT(builtin != NULL);
+ builtin_setlist(builtin->builtins, builtin->count);
#endif
}
break;
@@ -843,19 +843,19 @@ int boardctl(unsigned int cmd, uintptr_t arg)
else if (spinlock->action == BOARDIOC_SPINLOCK_TRYLOCK)
{
if (lock != NULL)
- {
- if (flags != NULL)
- {
- if (!spin_trylock_irqsave(lock, *flags))
- {
- ret = -EBUSY;
- }
- }
- else if (!spin_trylock(lock))
- {
- ret = -EBUSY;
- }
- }
+ {
+ if (flags != NULL)
+ {
+ if (!spin_trylock_irqsave(lock, *flags))
+ {
+ ret = -EBUSY;
+ }
+ }
+ else if (!spin_trylock(lock))
+ {
+ ret = -EBUSY;
+ }
+ }
}
else if (spinlock->action == BOARDIOC_SPINLOCK_UNLOCK)
{
@@ -908,8 +908,8 @@ int boardctl(unsigned int cmd, uintptr_t arg)
/* CMD: BOARDIOC_IRQ_AFFINITY
* DESCRIPTION: Set an IRQ affinity by software.
* ARG: Integer array:
- member 0 is the interrupt number
- member 1 is the CPU index
+ * member 0 is the interrupt number
+ * member 1 is the CPU index
* CONFIGURATION: CONFIG_BOARDCTL_IRQ_AFFINITY
* DEPENDENCIES: Bound Multi-Processing (CONFIG_BMP)
*/
@@ -917,6 +917,7 @@ int boardctl(unsigned int cmd, uintptr_t arg)
case BOARDIOC_IRQ_AFFINITY:
{
FAR unsigned int *affinity = (FAR unsigned int *)arg;
+
up_affinity_irq(affinity[0], affinity[1]);
ret = OK;
}
@@ -958,21 +959,21 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break;
#endif
- default:
- {
+ default:
+ {
#ifdef CONFIG_BOARDCTL_IOCTL
- /* Boards may also select CONFIG_BOARDCTL_IOCTL=y to enable
- * board-specific commands. In this case, all commands not
- * recognized by boardctl() will be forwarded to the board-
- * provided board_ioctl() function.
- */
+ /* Boards may also select CONFIG_BOARDCTL_IOCTL=y to enable
+ * board-specific commands. In this case, all commands not
+ * recognized by boardctl() will be forwarded to the board-
+ * provided board_ioctl() function.
+ */
- ret = board_ioctl(cmd, arg);
+ ret = board_ioctl(cmd, arg);
#else
- ret = -ENOTTY;
+ ret = -ENOTTY;
#endif
- }
- break;
+ }
+ break;
}
/* Set the errno value on any errors */
(nuttx) 09/09: boards/stm32g4: leave capabilities out of the cansock configs
Posted by ac...@apache.org.
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 24368b8008e51949ff127535ccd3caf424219554
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Fri Oct 2 07:02:12 2026 +0400
boards/stm32g4: leave capabilities out of the cansock configs
nucleo-g431rb:cansock and b-g431b-esc1:cansock fill their 128 KB of
flash to the last few hundred bytes, and the capability checks overflow
them.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
boards/arm/stm32g4/b-g431b-esc1/configs/cansock/defconfig | 1 +
boards/arm/stm32g4/nucleo-g431rb/configs/cansock/defconfig | 1 +
2 files changed, 2 insertions(+)
diff --git a/boards/arm/stm32g4/b-g431b-esc1/configs/cansock/defconfig b/boards/arm/stm32g4/b-g431b-esc1/configs/cansock/defconfig
index 320b24936f0..a169b0a60b3 100644
--- a/boards/arm/stm32g4/b-g431b-esc1/configs/cansock/defconfig
+++ b/boards/arm/stm32g4/b-g431b-esc1/configs/cansock/defconfig
@@ -7,6 +7,7 @@
#
# CONFIG_NET_ETHERNET is not set
# CONFIG_NET_IPv4 is not set
+# CONFIG_SCHED_CAPABILITIES is not set
CONFIG_ALLOW_BSD_COMPONENTS=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="b-g431b-esc1"
diff --git a/boards/arm/stm32g4/nucleo-g431rb/configs/cansock/defconfig b/boards/arm/stm32g4/nucleo-g431rb/configs/cansock/defconfig
index c139bf6d9b5..999fb8117b8 100644
--- a/boards/arm/stm32g4/nucleo-g431rb/configs/cansock/defconfig
+++ b/boards/arm/stm32g4/nucleo-g431rb/configs/cansock/defconfig
@@ -7,6 +7,7 @@
#
# CONFIG_NET_ETHERNET is not set
# CONFIG_NET_IPv4 is not set
+# CONFIG_SCHED_CAPABILITIES is not set
CONFIG_ALLOW_BSD_COMPONENTS=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-g431rb"
(nuttx) 06/09: boards: reset and power-off need PR_CAP_ADMIN
Posted by ac...@apache.org.
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 66eac21f687ddf8eb0e19c73914358703bd444ef
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Fri Oct 2 06:56:45 2026 +0400
boards: reset and power-off need PR_CAP_ADMIN
boardctl(BOARDIOC_RESET) and boardctl(BOARDIOC_POWEROFF) refuse a task
group without it.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
boards/boardctl.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/boards/boardctl.c b/boards/boardctl.c
index f78d0e77cc2..df128042a14 100644
--- a/boards/boardctl.c
+++ b/boards/boardctl.c
@@ -41,6 +41,7 @@
#include <nuttx/binfmt/symtab.h>
#include <nuttx/drivers/ramdisk.h>
#include <nuttx/reboot_notifier.h>
+#include <nuttx/sched.h>
#include <nuttx/trace.h>
#ifdef CONFIG_NX
@@ -413,6 +414,12 @@ int boardctl(unsigned int cmd, uintptr_t arg)
case BOARDIOC_POWEROFF:
{
+ if (!nxsched_capable(PR_CAP_ADMIN))
+ {
+ ret = -EPERM;
+ break;
+ }
+
reboot_notifier_call_chain(SYS_POWER_OFF, (FAR void *)arg);
up_flush_dcache_all();
ret = board_power_off((int)arg);
@@ -430,6 +437,12 @@ int boardctl(unsigned int cmd, uintptr_t arg)
case BOARDIOC_RESET:
{
+ if (!nxsched_capable(PR_CAP_ADMIN))
+ {
+ ret = -EPERM;
+ break;
+ }
+
g_nx_initstate = OSINIT_RESET;
sched_trace_mark("RESET");
reboot_notifier_call_chain(SYS_RESTART, (FAR void *)arg);
(nuttx) 03/09: fs: raw storage needs PR_CAP_RAWIO
Posted by ac...@apache.org.
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 e55c073799774000a286c0aa1e796644f4012eb6
Author: Royyan Zahir <ro...@gmail.com>
AuthorDate: Fri Oct 2 06:56:44 2026 +0400
fs: raw storage needs PR_CAP_RAWIO
Opening a block or MTD node, mount() and umount2() need it, and so does
a BCH character node, which checks in its own open(): a node made by
bchdev_register() is a character driver, so the inode type cannot tell
it apart. The checks sit in file_vopen(), nx_mount() and nx_umount2(),
which every path reaches; kernel threads hold every capability.
Signed-off-by: Royyan Zahir <ro...@gmail.com>
---
drivers/bch/bchdev_driver.c | 6 ++++++
fs/mount/fs_mount.c | 6 ++++++
fs/mount/fs_umount2.c | 6 ++++++
fs/vfs/fs_open.c | 7 +++++++
4 files changed, 25 insertions(+)
diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c
index 0d4660264c8..5307565423f 100644
--- a/drivers/bch/bchdev_driver.c
+++ b/drivers/bch/bchdev_driver.c
@@ -39,6 +39,7 @@
#include <assert.h>
#include <nuttx/debug.h>
+#include <nuttx/sched.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/drivers/drivers.h>
@@ -122,6 +123,11 @@ static int bch_open(FAR struct file *filep)
FAR struct bchlib_s *bch;
int ret = OK;
+ if (!nxsched_capable(PR_CAP_RAWIO))
+ {
+ return -EPERM;
+ }
+
DEBUGASSERT(inode->i_private);
bch = inode->i_private;
diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c
index 75eeb3c6874..086b2745012 100644
--- a/fs/mount/fs_mount.c
+++ b/fs/mount/fs_mount.c
@@ -34,6 +34,7 @@
#include <nuttx/debug.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/sched.h>
#include "driver/driver.h"
#include "inode/inode.h"
@@ -304,6 +305,11 @@ int nx_mount(FAR const char *source, FAR const char *target,
FAR void *fshandle = NULL;
int ret;
+ if (!nxsched_capable(PR_CAP_RAWIO))
+ {
+ return -EPERM;
+ }
+
/* Verify required pointer arguments */
DEBUGASSERT(target && filesystemtype);
diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c
index 6ac21c7f405..bfa3b54ab00 100644
--- a/fs/mount/fs_umount2.c
+++ b/fs/mount/fs_umount2.c
@@ -32,6 +32,7 @@
#include <assert.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/sched.h>
#include "inode/inode.h"
#include "vfs/vfs.h"
@@ -62,6 +63,11 @@ int nx_umount2(FAR const char *target, unsigned int flags)
struct inode_search_s desc;
int ret;
+ if (!nxsched_capable(PR_CAP_RAWIO))
+ {
+ return -EPERM;
+ }
+
/* Verify required pointer arguments */
if (!target)
diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c
index d4b13b8d4de..9cfae266f7d 100644
--- a/fs/vfs/fs_open.c
+++ b/fs/vfs/fs_open.c
@@ -148,6 +148,13 @@ static int file_vopen(FAR struct file *filep, FAR const char *path,
}
#endif
+ if ((INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode)) &&
+ !nxsched_capable(PR_CAP_RAWIO))
+ {
+ ret = -EPERM;
+ goto errout_with_inode;
+ }
+
#if defined(CONFIG_BCH) && \
!defined(CONFIG_DISABLE_MOUNTPOINT) && \
!defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS)