Skip to content

sched: process capabilities in a kernel build - #20417

Open
royzah wants to merge 9 commits into
apache:masterfrom
royzah:caps
Open

royzah wants to merge 9 commits into
apache:masterfrom
royzah:caps

Conversation

@royzah

@royzah royzah commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

Any process could open raw storage, spawn programs, mount file systems and reset the board, and had no way to give that up.

Commit Does
nxstyle nx_start.c passes the check; whitespace only
sched a task group holds PR_CAP_RAWIO, PR_CAP_SPAWN, PR_CAP_ADMIN, inherited from its creator; prctl(PR_CAPS_DROP) only removes, PR_CAPS_GET reads; CONFIG_SCHED_CAPABILITIES, off with DEFAULT_SMALL
nxstyle bchdev_driver.c passes the check; whitespace only
fs RAWIO: opening a block or MTD node, a BCH node in its own open(), nx_mount(), nx_umount2()
sched, binfmt SPAWN: exec_internal(), nxtask_spawn_create(), nxtask_create()
nxstyle boardctl.c passes the check; whitespace only
boards ADMIN: boardctl reset and power-off
Documentation implementation/capabilities.rst
boards/stm32g4 nucleo-g431rb:cansock and b-g431b-esc1:cansock leave the option out: each had a few hundred bytes of its 128 KB flash left

The checks sit in the internal functions every path reaches, not in the syscall layer, so they hold in flat, protected and kernel builds, and kernel code acting for a process is held to that process's set. Kernel threads hold all three.

Impact

Every build with CONFIG_SCHED_CAPABILITIES, on unless DEFAULT_SMALL. Nothing changes until a process drops a capability: the kernel and init start with all three. Off, every check compiles away: with the cross-process checks too, nucleo-g431rb:cansock builds at 129532 B of text and b-g431b-esc1:cansock at 129524 B.

Testing

Host: Ubuntu 24.04, x86_64. Builds and QEMU runs in ghcr.io/apache/nuttx/apache-nuttx-ci-linux (QEMU 6.2, Arm GNU GCC 13.2, xPack RISC-V GCC 14.3). Hardware: i.MX93 (Cortex-A55), PX4 kernel build.

Where Result
qemu-armv8a:nsh, flat, with the new ostest case caps_test: PASSED; ostest passes
qemu-armv8a:knsh ostest passes; hello
rv-virt:knsh64 hello; ostest stops after Started user_main at PID=6, as master does
i.MX93, PX4 kernel build, an earlier revision (same checks, in the syscall layer) a process that dropped all three: raw open, spawn, launch and mount refused, PR_CAPS_GET reads 0

The ostest case drops each capability in a child task and checks EPERM; it goes to nuttx-apps once this lands.

qemu-armv8a:nsh, flat, with the new ostest case: the caps part and the end
- Ready to Boot Primary CPU
- Boot from EL2
- Boot from EL1
- Boot to C runtime for OS Initialize
nsh> ostest
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
...
user_main: caps test
caps_test: Starting test
caps_test: PASSED
...
Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        7
mxordblk  7c07c10  7bf0e30
uordblks     cbf0     cde8
fordblks  7c08410  7c08218
user_main: Exiting
ostest_main: Exiting with status 0
qemu-armv8a:knsh: hello, then ostest
- Ready to Boot Primary CPU
- Boot from EL2
- Boot from EL1
- Boot to C runtime for OS Initialize

NuttShell (NSH)
nsh> /system/bin/hello
Hello, World!!
nsh> ostest
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
stdio_test: Standard I/O Check: fprintf to stderr
ostest_main: putenv(Variable1=BadValue3)
ostest_main: setenv(Variable1, GoodValue1, TRUE)
ostest_main: setenv(Variable2, BadValue1, FALSE)
ostest_main: setenv(Variable2, GoodValue2, TRUE)
ostest_main: setenv(Variable3, GoodValue3, FALSE)
ostest_main: setenv(Variable3, BadValue2, FALSE)
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
ostest_main: Started user_main at PID=7

user_main: vfork() test
vfork_test: Started
vfork_test: Child 8 ran and exited before the parent resumed

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        a000     c000
ordblks         2        3
mxordblk     5ff8     3ff8
uordblks     27d8     47e0
fordblks     7828     7820

user_main: Begin argument test
user_main: Started with argc=5
user_main: argv[0]="user_main"
user_main: argv[1]="Arg1"
user_main: argv[2]="Arg2"
user_main: argv[3]="Arg3"
user_main: argv[4]="Arg4"

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        3
mxordblk     3ff8     3ff8
uordblks     47e0     47e0
fordblks     7820     7820

user_main: getopt() test
getopt():  Simple test
getopt():  Invalid argument
getopt():  Missing optional argument
getopt_long():  Simple test
getopt_long():  No short options
getopt_long():  Argument for --option=argument
getopt_long():  Invalid long option
getopt_long():  Mixed long and short options
getopt_long():  Invalid short option
getopt_long():  Missing optional arguments
getopt_long_only():  Mixed long and short options
getopt_long_only():  Single hyphen long options

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        3
mxordblk     3ff8     3ff8
uordblks     47e0     47e0
fordblks     7820     7820

user_main: libc tests

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        3
mxordblk     3ff8     3ff8
uordblks     47e0     47e0
fordblks     7820     7820
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
show_variable: Variable=Variable1 has no value
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        4
mxordblk     3ff8     3ff8
uordblks     47e0     47c0
fordblks     7820     7840
show_variable: Variable=Variable1 has no value
show_variable: Variable=Variable2 has no value
show_variable: Variable=Variable3 has no value

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         4        3
mxordblk     3ff8     3ff8
uordblks     47c0     46e8
fordblks     7840     7918

user_main: setvbuf test
setvbuf_test: Test NO buffering
setvbuf_test: Using NO buffering
setvbuf_test: Test default FULL buffering
setvbuf_test: Using default FULL buffering
setvbuf_test: Test FULL buffering, buffer size 64
setvbuf_test: Using FULL buffering, buffer size 64
setvbuf_test: Test FULL buffering, pre-allocated buffer
setvbuf_test: Using FULL buffering, pre-allocated buffer
setvbuf_test: Test LINE buffering, buffer size 64
setvbuf_test: Using LINE buffering, buffer size 64
setvbuf_test: Test FULL buffering, pre-allocated buffer
setvbuf_test: Using FULL buffering, pre-allocated buffer

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        3
mxordblk     3ff8     3ff8
uordblks     46e8     46e8
fordblks     7918     7918

user_main: /dev/null test
dev_null: Read 0 bytes from /dev/null
dev_null: Wrote 1024 bytes to /dev/null

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000     c000
ordblks         3        3
mxordblk     3ff8     3ff8
uordblks     46e8     46e8
fordblks     7918     7918

user_main: mutex test
Initializing mutex
Starting thread 1
Starting thread 2
Thread1Thread2
Loops3232
Errors00

Testing moved mutex
Starting moved mutex thread 1
Starting moved mutex thread 2
Thread1Thread2
Moved Loops3232
Moved Errors00

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        c000    10000
ordblks         3        4
mxordblk     3ff8     3ff8
uordblks     46e8     66f0
fordblks     7918     9910

user_main: timed mutex test
mutex_test: Initializing mutex
mutex_test: Starting thread
pthread:  Started
pthread:  Waiting for lock or timeout
mutex_test: Unlocking
pthread:  Got the lock
pthread:  Waiting for lock or timeout
pthread:  Got the timeout.  Terminating
mutex_test: PASSED
timedmutex regression test: PASSED

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       10000    10000
ordblks         4        4
mxordblk     3ff8     3ff8
uordblks     66f0     66f0
fordblks     9910     9910

user_main: cancel test
cancel_test: Test 1a: Normal Cancellation
cancel_test: Starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
cancel_test: Canceling thread
cancel_test: Joining
cancel_test: waiter exited with result=0xffffffffffffffff
cancel_test: PASS thread terminated with PTHREAD_CANCELED
cancel_test: Test 2: Asynchronous Cancellation
... Skipped
cancel_test: Test 3: Cancellation of detached thread
cancel_test: Re-starting thread
restart_thread: Destroying cond
restart_thread: Destroying mutex
restart_thread: Re-starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
cancel_test: Canceling thread
cancel_test: Joining
cancel_test: PASS pthread_join failed with status=ESRCH
cancel_test: Test 5: Non-cancelable threads
cancel_test: Re-starting thread (non-cancelable)
restart_thread: Destroying cond
restart_thread: Destroying mutex
restart_thread: Re-starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
sem_waiter: Setting non-cancelable
cancel_test: Canceling thread
cancel_test: Joining
sem_waiter: Releasing mutex
sem_waiter: Setting cancelable
cancel_test: waiter exited with result=0xffffffffffffffff
cancel_test: PASS thread terminated with PTHREAD_CANCELED
cancel_test: Test 6: Cancel message queue wait
cancel_test: Starting thread (cancelable)
Skipped
cancel_test: Test 7: Cancel signal wait
cancel_test: Starting thread (cancelable)
Skipped

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       10000    10000
ordblks         4        3
mxordblk     3ff8     7ff8
uordblks     66f0     46e8
fordblks     9910     b918

user_main: robust test
robust_test: Initializing mutex
robust_test: Starting thread
robust_waiter: Taking mutex
robust_waiter: Exiting with mutex
robust_test: Take the lock again
robust_test: Make the mutex consistent again.
robust_test: Take the lock again
robust_test: Joining
robust_test: waiter exited with result=0
robust_test: Test complete with nerrors=0

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       10000    10000
ordblks         3        3
mxordblk     7ff8     7ff8
uordblks     46e8     46e8
fordblks     b918     b918

user_main: semaphore test
sem_test: Initializing semaphore to 0
sem_test: Starting waiter thread 1
sem_test: Set thread 1 priority to 191
waiter_func: Thread 1 Started
waiter_func: Thread 1 initial semaphore value = 0
waiter_func: Thread 1 waiting on semaphore
sem_test: Starting waiter thread 2
sem_test: Set thread 2 priority to 128
waiter_func: Thread 2 Started
waiter_func: Thread 2 initial semaphore value = -1
waiter_func: Thread 2 waiting on semaphore
sem_test: Starting poster thread 3
sem_test: Set thread 3 priority to 64
poster_func: Thread 3 started
poster_func: Thread 3 semaphore value = -2
poster_func: Thread 3 posting semaphore
waiter_func: Thread 1 awakened
waiter_func: Thread 1 new semaphore value = -1
waiter_func: Thread 1 done
poster_func: Thread 3 new semaphore value = -1
poster_func: Thread 3 semaphore value = -1
poster_func: Thread 3 posting semaphore
waiter_func: Thread 2 awakened
waiter_func: Thread 2 new semaphore value = 0
waiter_func: Thread 2 done
poster_func: Thread 3 new semaphore value = 0
poster_func: Thread 3 done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       10000    14000
ordblks         3        5
mxordblk     7ff8     3ff8
uordblks     46e8     86f8
fordblks     b918     b908

user_main: timed semaphore test
semtimed_test: Initializing semaphore to 0
semtimed_test: Waiting for two second timeout
semtimed_test: PASS: first test returned timeout
BEFORE: (1646092835 sec, 461092864 nsec)
AFTER:  (1646092837 sec, 461869584 nsec)
semtimed_test: Starting poster thread
semtimed_test: Set thread 1 priority to 191
semtimed_test: Starting poster thread 3
semtimed_test: Set thread 3 priority to 64
semtimed_test: Waiting for two second timeout
poster_func: Waiting for 1 second
poster_func: Posting
semtimed_test: PASS: sem_timedwait succeeded
BEFORE: (1646092837 sec, 462164272 nsec)
AFTER:  (1646092838 sec, 462887088 nsec)

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       14000    14000
ordblks         5        3
mxordblk     3ff8     bff8
uordblks     86f8     46e8
fordblks     b908     f918

user_main: condition variable test
cond_test: Initializing mutex
cond_test: Initializing cond
cond_test: Starting waiter
cond_test: Set thread 1 priority to 128
waiter_thread: Started
cond_test: Starting signaler
cond_test: Set thread 2 priority to 64
thread_signaler: Started
thread_signaler: Terminating
cond_test: signaler terminated, now cancel the waiter
cond_test: WaiterSignaler
cond_test: Loops3232
cond_test: Errors00
cond_test:
cond_test: 0 times, waiter did not have to wait for data
cond_test: 0 times, data was already available when the signaler run
cond_test: 0 times, the waiter was in an unexpected state when the signaler ran

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       14000    14000
ordblks         3        3
mxordblk     bff8     7ff8
uordblks     46e8     46e8
fordblks     f918     f918

user_main: pthread_exit() test
pthread_exit_test: Started pthread_exit_main at PID=37
pthread_exit_main 37: Starting pthread_exit_thread
pthread_exit_main 37: Sleeping for 5 seconds
pthread_exit_thread 40: Sleeping for 10 second
pthread_exit_main 37: Calling pthread_exit()
pthread_exit_thread 40: Still running...

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       14000    14000
ordblks         3        4
mxordblk     7ff8     7ff8
uordblks     46e8     66f0
fordblks     f918     d910

user_main: pthread_rwlock test
pthread_rwlock: Initializing rwlock
pthread_exit_thread 40: Exiting

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       14000    18000
ordblks         4        5
mxordblk     7ff8     5ff8
uordblks     66f0     86f8
fordblks     d910     f908

user_main: pthread_rwlock_cancel test
pthread_rwlock_cancel: Starting test

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         5        2
mxordblk     5ff8    13ff8
uordblks     86f8     26e0
fordblks     f908    15920

user_main: timed wait test
thread_waiter: Initializing mutex
timedwait_test: Initializing cond
timedwait_test: Starting waiter
timedwait_test: Set thread 2 priority to 177
thread_waiter: Taking mutex
thread_waiter: Starting 5 second wait for condition
timedwait_test: Joining
thread_waiter: pthread_cond_timedwait timed out
thread_waiter: Releasing mutex
thread_waiter: Exit with status 0x12345678
timedwait_test: waiter exited with result=0x12345678

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         2        3
mxordblk    13ff8     fff8
uordblks     26e0     46e8
fordblks    15920    13918

user_main: timed message queue test
timedmqueue_test: Starting sender
timedmqueue_test: Waiting for sender to complete
sender_thread: Starting
sender_thread: mq_timedsend succeeded on msg 0
sender_thread: mq_timedsend succeeded on msg 1
sender_thread: mq_timedsend succeeded on msg 2
sender_thread: mq_timedsend succeeded on msg 3
sender_thread: mq_timedsend succeeded on msg 4
sender_thread: mq_timedsend succeeded on msg 5
sender_thread: mq_timedsend succeeded on msg 6
sender_thread: mq_timedsend succeeded on msg 7
sender_thread: mq_timedsend succeeded on msg 8
sender_thread: mq_timedsend 9 timed out as expected
sender_thread: returning nerrors=0
timedmqueue_test: Starting receiver
timedmqueue_test: Waiting for receiver to complete
receiver_thread: Starting
receiver_thread: mq_timedreceive succeed on msg 0
receiver_thread: mq_timedreceive succeed on msg 1
receiver_thread: mq_timedreceive succeed on msg 2
receiver_thread: mq_timedreceive succeed on msg 3
receiver_thread: mq_timedreceive succeed on msg 4
receiver_thread: mq_timedreceive succeed on msg 5
receiver_thread: mq_timedreceive succeed on msg 6
receiver_thread: mq_timedreceive succeed on msg 7
receiver_thread: mq_timedreceive succeed on msg 8
receiver_thread: Receive 9 timed out as expected
receiver_thread: returning nerrors=0
timedmqueue_test: Test complete

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         3        3
mxordblk     fff8     fff8
uordblks     46e8     46e8
fordblks    13918    13918

user_main: sigprocmask test
sigprocmask_test: SUCCESS

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         3        3
mxordblk     fff8     fff8
uordblks     46e8     46e8
fordblks    13918    13918

user_main: message queue test
mqueue_test: Starting receiver
mqueue_test: Set receiver priority to 128
receiver_thread: Starting
mqueue_test: Starting sender
mqueue_test: Set sender thread priority to 64
mqueue_test: Waiting for sender to complete
sender_thread: Starting
receiver_thread: mq_receive succeeded on msg 0
sender_thread: mq_send succeeded on msg 0
receiver_thread: mq_receive succeeded on msg 1
sender_thread: mq_send succeeded on msg 1
receiver_thread: mq_receive succeeded on msg 2
sender_thread: mq_send succeeded on msg 2
receiver_thread: mq_receive succeeded on msg 3
sender_thread: mq_send succeeded on msg 3
receiver_thread: mq_receive succeeded on msg 4
sender_thread: mq_send succeeded on msg 4
receiver_thread: mq_receive succeeded on msg 5
sender_thread: mq_send succeeded on msg 5
receiver_thread: mq_receive succeeded on msg 6
sender_thread: mq_send succeeded on msg 6
receiver_thread: mq_receive succeeded on msg 7
sender_thread: mq_send succeeded on msg 7
receiver_thread: mq_receive succeeded on msg 8
sender_thread: mq_send succeeded on msg 8
receiver_thread: mq_receive succeeded on msg 9
sender_thread: mq_send succeeded on msg 9
sender_thread: returning nerrors=0
mqueue_test: Killing receiver
receiver_thread: mq_receive interrupted!
receiver_thread: returning nerrors=0
mqueue_test: Canceling receiver
mqueue_test: receiver has already terminated

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         3        4
mxordblk     fff8     bff8
uordblks     46e8     66f0
fordblks    13918    11910

user_main: signal handler test
sighand_test: Initializing semaphore to 0
sighand_test: Unmasking SIGCHLD
sighand_test: Registering SIGCHLD handler
sighand_test: Starting waiter task
sighand_test: Started waiter_main pid=58
waiter_main: Waiter started
waiter_main: Unmasking signal 32
waiter_main: Registering signal handler
waiter_main: oact.sigaction=0 oact.sa_flags=0 oact.sa_mask=0000000000000000
waiter_main: Waiting on semaphore
sighand_test: Signaling pid=58 with signo=32 sigvalue=42
waiter_main: sem_wait() successfully interrupted by signal
waiter_main: done
sighand_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         4        3
mxordblk     bff8     fff8
uordblks     66f0     46e8
fordblks    11910    13918

user_main: nested signal handler test
signest_test: Starting signal waiter task at priority 101
waiter_main: Waiter started
waiter_main: Setting signal mask
waiter_main: Registering signal handler
waiter_main: Waiting on semaphore
signest_test: Started waiter_main pid=59
signest_test: Starting interfering task at priority 102
interfere_main: Waiting on semaphore
signest_test: Started interfere_main pid=60
signest_test: Simple case:
  Total signalled 1180  Odd=580 Even=600
  Total handled   1180  Odd=580 Even=600
  Total nested    0    Odd=0   Even=0  
signest_test: With task locking
  Total signalled 2360  Odd=1160 Even=1200
  Total handled   2360  Odd=1160 Even=1200
  Total nested    0    Odd=0   Even=0  
signest_test: With interfering thread
  Total signalled 3540  Odd=1740 Even=1800
  Total handled   3540  Odd=1740 Even=1800
  Total nested    0    Odd=0   Even=0  
signest_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         3        4
mxordblk     fff8     bff8
uordblks     46e8     66f0
fordblks    13918    11910

user_main: POSIX timer test
timer_test: Masking signal 32
timer_test: Creating timer
timer_test: Starting timer
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=1
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=2
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=3
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=4
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=5
timer_test: Deleting timer
timer_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         4        4
mxordblk     bff8     bff8
uordblks     66f0     66f0
fordblks    11910    11910

user_main: round-robin scheduler test
rr_test: Set thread priority to 1
rr_test: Set thread policy to SCHED_RR
rr_test: Starting first get_primes_thread
         First get_primes_thread: 61
rr_test: Starting second get_primes_thread
         Second get_primes_thread: 62
rr_test: Waiting for threads to complete -- this should take awhile
         If RR scheduling is working, they should start and complete at
         about the same time
get_primes_thread id=1 started, looking for primes < 30000, doing 10 run(s)
get_primes_thread id=2 started, looking for primes < 30000, doing 10 run(s)
get_primes_thread id=1 finished, found 3246 primes, last one was 29989
get_primes_thread id=2 finished, found 3246 primes, last one was 29989
rr_test: Done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    18000
ordblks         4        4
mxordblk     bff8     bff8
uordblks     66f0     66f0
fordblks    11910    11910

user_main: barrier test
barrier_test: Initializing barrier
barrier_test: Thread 0 created
barrier_test: Thread 1 created
barrier_test: Thread 2 created
barrier_test: Thread 3 created
barrier_test: Thread 4 created
barrier_test: Thread 5 created
barrier_test: Thread 6 created
barrier_test: Thread 7 created
barrier_func: Thread 0 started
barrier_func: Thread 1 started
barrier_func: Thread 2 started
barrier_func: Thread 3 started
barrier_func: Thread 4 started
barrier_func: Thread 5 started
barrier_func: Thread 6 started
barrier_func: Thread 7 started
barrier_func: Thread 0 calling pthread_barrier_wait()
barrier_func: Thread 1 calling pthread_barrier_wait()
barrier_func: Thread 2 calling pthread_barrier_wait()
barrier_func: Thread 3 calling pthread_barrier_wait()
barrier_func: Thread 4 calling pthread_barrier_wait()
barrier_func: Thread 5 calling pthread_barrier_wait()
barrier_func: Thread 6 calling pthread_barrier_wait()
barrier_func: Thread 7 calling pthread_barrier_wait()
barrier_func: Thread 7, back with status=PTHREAD_BARRIER_SERIAL_THREAD (I AM SPECIAL)
barrier_func: Thread 0, back with status=0 (I am not special)
barrier_func: Thread 1, back with status=0 (I am not special)
barrier_func: Thread 2, back with status=0 (I am not special)
barrier_func: Thread 3, back with status=0 (I am not special)
barrier_func: Thread 4, back with status=0 (I am not special)
barrier_func: Thread 5, back with status=0 (I am not special)
barrier_func: Thread 6, back with status=0 (I am not special)
barrier_func: Thread 7 done
barrier_func: Thread 0 done
barrier_func: Thread 1 done
barrier_func: Thread 2 done
barrier_func: Thread 3 done
barrier_func: Thread 4 done
barrier_func: Thread 5 done
barrier_func: Thread 6 done
barrier_test: Thread 0 completed with result=0
barrier_test: Thread 1 completed with result=0
barrier_test: Thread 2 completed with result=0
barrier_test: Thread 3 completed with result=0
barrier_test: Thread 4 completed with result=0
barrier_test: Thread 5 completed with result=0
barrier_test: Thread 6 completed with result=0
barrier_test: Thread 7 completed with result=0

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       18000    28000
ordblks         4       10
mxordblk     bff8     3ff8
uordblks     66f0    12720
fordblks    11910    158e0

user_main: scheduler lock test
sched_lock: Starting lowpri_thread at 97
sched_lock: Set lowpri_thread priority to 97
sched_lock: Starting highpri_thread at 98
sched_lock: Set highpri_thread priority to 98
sched_lock: Waiting...
sched_lock: PASSED No pre-emption occurred while scheduler was locked.
sched_lock: Starting lowpri_thread at 97
sched_lock: Set lowpri_thread priority to 97
sched_lock: Starting highpri_thread at 98
sched_lock: Set highpri_thread priority to 98
sched_lock: Waiting...
sched_lock: PASSED No pre-emption occurred while scheduler was locked.
sched_lock: Finished

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       28000    28000
ordblks        10        4
mxordblk     3ff8    1bff8
uordblks    12720     66f0
fordblks    158e0    21910

Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena        a000    28000
ordblks         2        4
mxordblk     5ff8    1bff8
uordblks     27d8     66f0
fordblks     7828    21910
user_main: Exiting
ostest_main: Exiting with status 0
nsh> qemu-system-aarch64: terminating on signal 15 from pid 1 (timeout)
rv-virt:knsh64: hello, then ostest; identical to master's
OpenSBI v0.9
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : riscv-virtio,qemu
Platform Features         : timer,mfdeleg
Platform HART Count       : 1
Firmware Base             : 0x80000000
Firmware Size             : 100 KB
Runtime SBI Version       : 0.2

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000087000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART ISA             : rv64imafdcsu
Boot HART Features        : scounteren,mcounteren,time
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
ABC
NuttShell (NSH)
nsh> /system/bin/hello
Hello, World!!
nsh> ostest
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
stdio_test: Standard I/O Check: fprintf to stderr
ostest_main: putenv(Variable1=BadValue3)
ostest_main: setenv(Variable1, GoodValue1, TRUE)
ostest_main: setenv(Variable2, BadValue1, FALSE)
ostest_main: setenv(Variable2, GoodValue2, TRUE)
ostest_main: setenv(Variable3, GoodValue3, FALSE)
ostest_main: setenv(Variable3, BadValue2, FALSE)
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
ostest_main: Started user_main at PID=6
qemu-system-riscv64: terminating on signal 15 from pid 1 (timeout)
i.MX93, PX4 kernel build, an earlier revision of this series: tests isolation
INFO  [tests] RUNNING TEST: test_capabilities_enforced
INFO  [tests] isolation PASSED
INFO  [tests] without capabilities, got through: 0x0
INFO  [tests] TEST PASSED: test_capabilities_enforced
INFO  [tests]   Tests passed :      15
INFO  [tests]   Tests failed :      0

tools/checkpatch.sh -c -u -m -g clean.

@linguini1 linguini1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split into smaller patches and include test logs.

@github-actions github-actions Bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: x86_64 Issues related to the x86_64 architecture Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Sep 30, 2026
acassis
acassis previously approved these changes Sep 30, 2026
@acassis

acassis commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Strange, membrowse didn't show the memory change for this PR

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

arduino-mega2560

  • flash: .text +46 B (+0.1%, 65,380 B / 262,144 B, total: 25% used)

esp32-devkitc

  • ROM: .flash.text +128 B (+0.1%, 125,092 B / 4,194,272 B, total: 3% used)
  • irom0_0_seg: .flash.text +128 B (+0.1%, 89,296 B / 3,342,304 B, total: 3% used)

mirtoo

  • kseg0_progmem: .text +44 B (+0.1%, 67,928 B / 131,072 B, total: 52% used)

qemu-armv8a

  • Code: .text.exec_internal +24 B, .text.file_vopen +48 B, .text.group_allocate +52 B, .text.nx_mount +24 B, .text.nx_start +12 B, .text.nx_umount2 +24 B, .text.nxtask_create +24 B, .text.task_spawn +24 B (+0.1%, 347,128 B)

qemu-intel64

  • Code: .text +229 B (+0.0%, 8,662,168 B)

rx65n-rsk2mb

  • ROM: .text +128 B (+0.1%, 87,008 B / 2,097,152 B, total: 4% used)

s698pm-dkit

  • Code: .text +368 B (+0.1%, 369,296 B)

stm32-nucleo-f103rb

  • flash: .text +32 B (+0.1%, 34,660 B / 131,072 B, total: 26% used)
    No memory changes detected for:
  • hifive1-revb

@royzah

royzah commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Kept to the capability commits; signals and scheduling across processes are #20425 and the sigevent fix is #20424. Full ostest logs in the description.

Comment thread include/nuttx/sched.h Outdated
Comment thread include/nuttx/fs/fs.h Outdated
Comment thread include/nuttx/sched.h
The memory manager block was indented one level too deep. No code
changes.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
@royzah
royzah requested a review from raiden00pl as a code owner October 1, 2026 15:21
@royzah

royzah commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Reworked as asked: on master by itself, no BUILD_KERNEL guard, the checks moved into the functions, plus a docs page and an ostest case. Fresh logs in the body.

@github-actions github-actions Bot added Size: M The size of the change in this PR is medium Area: BINFMT and removed Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: x86_64 Issues related to the x86_64 architecture Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Oct 1, 2026
@royzah
royzah requested a review from Ouss4 as a code owner October 1, 2026 23:54
@royzah

royzah commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Pushed the rework from the review on #20425: checks moved into the internal functions, the RAWIO flag and register_rawdriver() are gone, BCH checks in bch_open(). Fresh logs in the body.

@royzah

royzah commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Full log of the flat run, qemu-armv8a:nsh with the new ostest case:

qemu-armv8a:nsh, flat: ostest, complete
- Ready to Boot Primary CPU
- Boot from EL2
- Boot from EL1
- Boot to C runtime for OS Initialize
nsh> ostest
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
stdio_test: Standard I/O Check: fprintf to stderr
ostest_main: putenv(Variable1=BadValue3)
ostest_main: setenv(Variable1, GoodValue1, TRUE)
ostest_main: setenv(Variable2, BadValue1, FALSE)
ostest_main: setenv(Variable2, GoodValue2, TRUE)
ostest_main: setenv(Variable3, GoodValue3, FALSE)
ostest_main: setenv(Variable3, BadValue2, FALSE)
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
ostest_main: Started user_main at PID=6

user_main: vfork() test
vfork_test: Started
vfork_test: Child 7 ran and exited before the parent resumed

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cbf0     cbf0
fordblks  7c08410  7c08410

user_main: Begin argument test
user_main: Started with argc=5
user_main: argv[0]="ostest"
user_main: argv[1]="Arg1"
user_main: argv[2]="Arg2"
user_main: argv[3]="Arg3"
user_main: argv[4]="Arg4"

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cbf0     cbf0
fordblks  7c08410  7c08410

user_main: getopt() test
getopt():  Simple test
getopt():  Invalid argument
getopt():  Missing optional argument
getopt_long():  Simple test
getopt_long():  No short options
getopt_long():  Argument for --option=argument
getopt_long():  Invalid long option
getopt_long():  Mixed long and short options
getopt_long():  Invalid short option
getopt_long():  Missing optional arguments
getopt_long_only():  Mixed long and short options
getopt_long_only():  Single hyphen long options

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cbf0     cbf0
fordblks  7c08410  7c08410

user_main: libc tests

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cbf0     cbf0
fordblks  7c08410  7c08410
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
show_variable: Variable=Variable1 has no value
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        4
mxordblk  7c07c10  7c07c10
uordblks     cbf0     cbd0
fordblks  7c08410  7c08430
show_variable: Variable=Variable1 has no value
show_variable: Variable=Variable2 has no value
show_variable: Variable=Variable3 has no value

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        3
mxordblk  7c07c10  7c07c10
uordblks     cbd0     cb20
fordblks  7c08430  7c084e0

user_main: setvbuf test
setvbuf_test: Test NO buffering
setvbuf_test: Using NO buffering
setvbuf_test: Test default FULL buffering
setvbuf_test: Using default FULL buffering
setvbuf_test: Test FULL buffering, buffer size 64
setvbuf_test: Using FULL buffering, buffer size 64
setvbuf_test: Test FULL buffering, pre-allocated buffer
setvbuf_test: Using FULL buffering, pre-allocated buffer
setvbuf_test: Test LINE buffering, buffer size 64
setvbuf_test: Using LINE buffering, buffer size 64
setvbuf_test: Test FULL buffering, pre-allocated buffer
setvbuf_test: Using FULL buffering, pre-allocated buffer

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cb20     cb20
fordblks  7c084e0  7c084e0

user_main: /dev/null test
dev_null: Read 0 bytes from /dev/null
dev_null: Wrote 1024 bytes to /dev/null

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cb20     cb20
fordblks  7c084e0  7c084e0

user_main: FPU test
Starting task FPU#1
fpu_test: Started task FPU#1 at PID=8
FPU#1: pass 1
Starting task FPU#2
fpu_test: Started task FPU#2 at PID=9
FPU#2: pass 1
FPU#1: pass 2
FPU#2: pass 2
FPU#1: pass 3
FPU#2: pass 3
FPU#1: pass 4
FPU#2: pass 4
FPU#1: pass 5
FPU#2: pass 5
FPU#1: pass 6
FPU#2: pass 6
FPU#1: pass 7
FPU#2: pass 7
FPU#1: pass 8
FPU#2: pass 8
FPU#1: pass 9
FPU#2: pass 9
FPU#1: pass 10
FPU#2: pass 10
FPU#1: pass 11
FPU#2: pass 11
FPU#1: pass 12
FPU#2: pass 12
FPU#1: pass 13
FPU#2: pass 13
FPU#1: pass 14
FPU#2: pass 14
FPU#1: pass 15
FPU#2: pass 15
FPU#1: pass 16
FPU#2: pass 16
FPU#1: Succeeded
FPU#2: Succeeded
fpu_test: Returning

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        3
mxordblk  7c07c10  7c07c10
uordblks     cb20     cb20
fordblks  7c084e0  7c084e0

user_main: task_restart test

Test task_restart()
restart_main: setenv(VarName, VarValue, TRUE)
restart_main: Started restart_main at PID=10
restart_main: Started with argc=4
restart_main: argv[0]="ostest"
restart_main: argv[1]="This is argument 1"
restart_main: argv[2]="Argument 2 here"
restart_main: argv[3]="Lastly, the 3rd argument"
restart_main: Variable=VarName has value=VarValue
restart_main: I am still here
restart_main: I am still here
restart_main: Started restart_main at PID=10
restart_main: Started with argc=4
restart_main: argv[0]="ostest"
restart_main: argv[1]="This is argument 1"
restart_main: argv[2]="Argument 2 here"
restart_main: argv[3]="Lastly, the 3rd argument"
restart_main: Variable=VarName has value=VarValue
restart_main: Started with argc=4
restart_main: argv[0]="ostest"
restart_main: argv[1]="This is argument 1"
restart_main: argv[2]="Argument 2 here"
restart_main: argv[3]="Lastly, the 3rd argument"
restart_main: Variable=VarName has value=VarValue
restart_main: Exiting

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        2
mxordblk  7c07c10  7c07c10
uordblks     cb20     cb90
fordblks  7c084e0  7c08470

user_main: waitpid test

Test waitpid()
waitpid_start_child: Started waitpid_main at PID=11
waitpid_start_child: Started waitpid_main at PID=12
waitpid_start_child: Started waitpid_main at PID=13
waitpid_test: Waiting for PID=11 with waitpid()
waitpid_main: PID 11 Started
waitpid_main: PID 12 Started
waitpid_main: PID 13 Started
waitpid_main: PID 11 exitting with result=14
waitpid_main: PID 12 exitting with result=14
waitpid_main: PID 13 exitting with result=14
waitpid_test: PID 11 waitpid succeeded with stat_loc=0e00
waitpid_last: Waiting for PID=13 with waitpid()
waitpid_last: PASS: PID 13 waitpid failed with ECHILD.  That may be
              acceptable because child status is disabled on this thread.

Test waitid(P_PID)
waitpid_start_child: Started waitpid_main at PID=14
waitpid_start_child: Started waitpid_main at PID=15
waitpid_start_child: Started waitpid_main at PID=18
waitpid_test: Waiting for PID=14 with waitid()
waitpid_main: PID 14 Started
waitpid_main: PID 15 Started
waitpid_main: PID 18 Started
waitpid_main: PID 14 exitting with result=14
waitpid_main: PID 15 exitting with result=14
waitpid_main: PID 18 exitting with result=14
waitpid_test: waitid PID 14 succeeded with si_status=14
waitpid_last: Waiting for PID=18 with waitpid()
waitpid_last: PASS: PID 18 waitpid failed with ECHILD.  That may be
              acceptable because child status is disabled on this thread.

Test waitid(P_ALL)
waitpid_start_child: Started waitpid_main at PID=23
waitpid_start_child: Started waitpid_main at PID=24
waitpid_start_child: Started waitpid_main at PID=25
waitpid_test: Waiting for any child with waitid()
waitpid_main: PID 23 Started
waitpid_main: PID 24 Started
waitpid_main: PID 25 Started
waitpid_main: PID 23 exitting with result=14
waitpid_main: PID 24 exitting with result=14
waitpid_main: PID 25 exitting with result=14
waitpid_test: PID 23 waitid succeeded with si_status=14
waitpid_last: Waiting for PID=25 with waitpid()
waitpid_last: PASS: PID 25 waitpid failed with ECHILD.  That may be
              acceptable because child status is disabled on this thread.

Test wait()
waitpid_start_child: Started waitpid_main at PID=26
waitpid_start_child: Started waitpid_main at PID=27
waitpid_start_child: Started waitpid_main at PID=28
waitpid_test: Waiting for any child with wait()
waitpid_main: PID 26 Started
waitpid_main: PID 27 Started
waitpid_main: PID 28 Started
waitpid_main: PID 26 exitting with result=14
waitpid_main: PID 27 exitting with result=14
waitpid_main: PID 28 exitting with result=14
waitpid_test: PID 26 wait succeeded with stat_loc=0e00
waitpid_last: Waiting for PID=28 with waitpid()
waitpid_last: PASS: PID 28 waitpid failed with ECHILD.  That may be
              acceptable because child status is disabled on this thread.

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         2        2
mxordblk  7c07c10  7c07c10
uordblks     cb90     cb90
fordblks  7c08470  7c08470

user_main: caps test
caps_test: Starting test
caps_test: PASSED

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         2        2
mxordblk  7c07c10  7c07c10
uordblks     cb90     cb90
fordblks  7c08470  7c08470

user_main: wqueue test
wqueue_test: backend = flat
wqueue_test: HPWORK
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: HPWORK done
wqueue_test: custom queue, threads = 1
wqueue_test: priority = 100, expect = 100
wqueue_test: API validation
wqueue_test: API validation done
wqueue_test: periodic requeue
wqueue_test: periodic calls = 3, expect = 3
wqueue_test: pending replacement
wqueue_test: replacement total = 2, expect = 2
wqueue_test: sync cancel finished = 1, expect = 1
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: custom queue, threads = 1 done
wqueue_test: custom queue, threads = 2
wqueue_test: priority = 100, expect = 100
wqueue_test: sync cancel finished = 1, expect = 1
wqueue_test: parallel sync cancel
wqueue_test: parallel callbacks = 2, expect = 2
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: call = 100, expect = 100
wqueue_test: custom queue, threads = 2 done
wqueue_test: multiple custom queues
wqueue_test: multiple queues loop 1/4 done
wqueue_test: multiple queues loop 2/4 done
wqueue_test: multiple queues loop 3/4 done
wqueue_test: multiple queues loop 4/4 done
wqueue_test: multiple custom queues done
wqueue_test: self free
wqueue_test: self free result = -35, expect = -35
wqueue_test: teardown
wqueue_test: pending callback = 0, expect = 0
wqueue_test: running callback = 1, expect = 1
wqueue_test: teardown requeue rejected
wqueue_test: teardown done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         2        4
mxordblk  7c07c10  7bf0e30
uordblks     cb90     cc10
fordblks  7c08470  7c083f0

user_main: mutex test
Initializing mutex
Starting thread 1
Starting thread 2
Thread1Thread2
Loops3232
Errors00

Testing moved mutex
Starting moved mutex thread 1
Starting moved mutex thread 2
Thread1Thread2
Moved Loops3232
Moved Errors00

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: timed mutex test
mutex_test: Initializing mutex
mutex_test: Starting thread
pthread:  Started
pthread:  Waiting for lock or timeout
mutex_test: Unlocking
pthread:  Got the lock
pthread:  Waiting for lock or timeout
pthread:  Got the timeout.  Terminating
mutex_test: PASSED
timedmutex regression test: PASSED

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: cancel test
cancel_test: Test 1a: Normal Cancellation
cancel_test: Starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
cancel_test: Canceling thread
cancel_test: Joining
cancel_test: waiter exited with result=0xffffffffffffffff
cancel_test: PASS thread terminated with PTHREAD_CANCELED
cancel_test: Test 2: Asynchronous Cancellation
... Skipped
cancel_test: Test 3: Cancellation of detached thread
cancel_test: Re-starting thread
restart_thread: Destroying cond
restart_thread: Destroying mutex
restart_thread: Re-starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
cancel_test: Canceling thread
cancel_test: Joining
cancel_test: PASS pthread_join failed with status=ESRCH
cancel_test: Test 5: Non-cancelable threads
cancel_test: Re-starting thread (non-cancelable)
restart_thread: Destroying cond
restart_thread: Destroying mutex
restart_thread: Re-starting thread
start_thread: Initializing mutex
start_thread: Initializing cond
start_thread: Starting thread
start_thread: Yielding
sem_waiter: Taking mutex
sem_waiter: Starting wait for condition
sem_waiter: Setting non-cancelable
cancel_test: Canceling thread
cancel_test: Joining
sem_waiter: Releasing mutex
sem_waiter: Setting cancelable
cancel_test: waiter exited with result=0xffffffffffffffff
cancel_test: PASS thread terminated with PTHREAD_CANCELED
cancel_test: Test 6: Cancel message queue wait
cancel_test: Starting thread (cancelable)
Skipped
cancel_test: Test 7: Cancel signal wait
cancel_test: Starting thread (cancelable)
Skipped

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: robust test
robust_test: Initializing mutex
robust_test: Starting thread
robust_waiter: Taking mutex
robust_waiter: Exiting with mutex
robust_test: Take the lock again
robust_test: Make the mutex consistent again.
robust_test: Take the lock again
robust_test: Joining
robust_test: waiter exited with result=0
robust_test: Test complete with nerrors=0

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: semaphore test
sem_test: Initializing semaphore to 0
sem_test: Starting waiter thread 1
sem_test: Set thread 1 priority to 191
waiter_func: Thread 1 Started
waiter_func: Thread 1 initial semaphore value = 0
waiter_func: Thread 1 waiting on semaphore
sem_test: Starting waiter thread 2
sem_test: Set thread 2 priority to 128
waiter_func: Thread 2 Started
waiter_func: Thread 2 initial semaphore value = -1
waiter_func: Thread 2 waiting on semaphore
sem_test: Starting poster thread 3
sem_test: Set thread 3 priority to 64
poster_func: Thread 3 started
poster_func: Thread 3 semaphore value = -2
poster_func: Thread 3 posting semaphore
waiter_func: Thread 1 awakened
waiter_func: Thread 1 new semaphore value = -1
waiter_func: Thread 1 done
poster_func: Thread 3 new semaphore value = -1
poster_func: Thread 3 semaphore value = -1
poster_func: Thread 3 posting semaphore
waiter_func: Thread 2 awakened
waiter_func: Thread 2 new semaphore value = 0
waiter_func: Thread 2 done
poster_func: Thread 3 new semaphore value = 0
poster_func: Thread 3 done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: timed semaphore test
semtimed_test: Initializing semaphore to 0
semtimed_test: Waiting for two second timeout
semtimed_test: PASS: first test returned timeout
BEFORE: (1646092888 sec, 868303856 nsec)
AFTER:  (1646092890 sec, 868827008 nsec)
semtimed_test: Starting poster thread
semtimed_test: Set thread 1 priority to 191
semtimed_test: Starting poster thread 3
semtimed_test: Set thread 3 priority to 64
semtimed_test: Waiting for two second timeout
poster_func: Waiting for 1 second
poster_func: Posting
semtimed_test: PASS: sem_timedwait succeeded
BEFORE: (1646092890 sec, 869338592 nsec)
AFTER:  (1646092891 sec, 869875824 nsec)

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: condition variable test
cond_test: Initializing mutex
cond_test: Initializing cond
cond_test: Starting waiter
cond_test: Set thread 1 priority to 128
waiter_thread: Started
cond_test: Starting signaler
cond_test: Set thread 2 priority to 64
thread_signaler: Started
thread_signaler: Terminating
cond_test: signaler terminated, now cancel the waiter
cond_test: WaiterSignaler
cond_test: Loops3232
cond_test: Errors00
cond_test:
cond_test: 0 times, waiter did not have to wait for data
cond_test: 0 times, data was already available when the signaler run
cond_test: 0 times, the waiter was in an unexpected state when the signaler ran

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     cc10
fordblks  7c083f0  7c083f0

user_main: pthread_exit() test
pthread_exit_test: Started pthread_exit_main at PID=337
pthread_exit_main 337: Starting pthread_exit_thread
pthread_exit_main 337: Sleeping for 5 seconds
pthread_exit_thread 338: Sleeping for 10 second
pthread_exit_main 337: Calling pthread_exit()
pthread_exit_thread 338: Still running...

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        6
mxordblk  7bf0e30  7bf0e30
uordblks     cc10     ed88
fordblks  7c083f0  7c06278

user_main: pthread_rwlock test
pthread_rwlock: Initializing rwlock
pthread_exit_thread 338: Exiting

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         6        4
mxordblk  7bf0e30  7bf0e30
uordblks     ed88     cc30
fordblks  7c06278  7c083d0

user_main: pthread_rwlock_cancel test
pthread_rwlock_cancel: Starting test

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc30     cc30
fordblks  7c083d0  7c083d0

user_main: timed wait test
thread_waiter: Initializing mutex
timedwait_test: Initializing cond
timedwait_test: Starting waiter
timedwait_test: Set thread 2 priority to 177
thread_waiter: Taking mutex
thread_waiter: Starting 5 second wait for condition
timedwait_test: Joining
thread_waiter: pthread_cond_timedwait timed out
thread_waiter: Releasing mutex
thread_waiter: Exit with status 0x12345678
timedwait_test: waiter exited with result=0x12345678

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc30     cc30
fordblks  7c083d0  7c083d0

user_main: timed message queue test
timedmqueue_test: Starting sender
timedmqueue_test: Waiting for sender to complete
sender_thread: Starting
sender_thread: mq_timedsend succeeded on msg 0
sender_thread: mq_timedsend succeeded on msg 1
sender_thread: mq_timedsend succeeded on msg 2
sender_thread: mq_timedsend succeeded on msg 3
sender_thread: mq_timedsend succeeded on msg 4
sender_thread: mq_timedsend succeeded on msg 5
sender_thread: mq_timedsend succeeded on msg 6
sender_thread: mq_timedsend succeeded on msg 7
sender_thread: mq_timedsend succeeded on msg 8
sender_thread: mq_timedsend 9 timed out as expected
sender_thread: returning nerrors=0
timedmqueue_test: Starting receiver
timedmqueue_test: Waiting for receiver to complete
receiver_thread: Starting
receiver_thread: mq_timedreceive succeed on msg 0
receiver_thread: mq_timedreceive succeed on msg 1
receiver_thread: mq_timedreceive succeed on msg 2
receiver_thread: mq_timedreceive succeed on msg 3
receiver_thread: mq_timedreceive succeed on msg 4
receiver_thread: mq_timedreceive succeed on msg 5
receiver_thread: mq_timedreceive succeed on msg 6
receiver_thread: mq_timedreceive succeed on msg 7
receiver_thread: mq_timedreceive succeed on msg 8
receiver_thread: Receive 9 timed out as expected
receiver_thread: returning nerrors=0
timedmqueue_test: Test complete

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     cc30     ccf0
fordblks  7c083d0  7c08310

user_main: sigprocmask test
sigprocmask_test: SUCCESS

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     ccf0     ccf0
fordblks  7c08310  7c08310

user_main: message queue test
mqueue_test: Starting receiver
mqueue_test: Set receiver priority to 128
receiver_thread: Starting
mqueue_test: Starting sender
mqueue_test: Set sender thread priority to 64
mqueue_test: Waiting for sender to complete
sender_thread: Starting
receiver_thread: mq_receive succeeded on msg 0
sender_thread: mq_send succeeded on msg 0
receiver_thread: mq_receive succeeded on msg 1
sender_thread: mq_send succeeded on msg 1
receiver_thread: mq_receive succeeded on msg 2
sender_thread: mq_send succeeded on msg 2
receiver_thread: mq_receive succeeded on msg 3
sender_thread: mq_send succeeded on msg 3
receiver_thread: mq_receive succeeded on msg 4
sender_thread: mq_send succeeded on msg 4
receiver_thread: mq_receive succeeded on msg 5
sender_thread: mq_send succeeded on msg 5
receiver_thread: mq_receive succeeded on msg 6
sender_thread: mq_send succeeded on msg 6
receiver_thread: mq_receive succeeded on msg 7
sender_thread: mq_send succeeded on msg 7
receiver_thread: mq_receive succeeded on msg 8
sender_thread: mq_send succeeded on msg 8
receiver_thread: mq_receive succeeded on msg 9
sender_thread: mq_send succeeded on msg 9
sender_thread: returning nerrors=0
mqueue_test: Killing receiver
receiver_thread: mq_receive interrupted!
receiver_thread: returning nerrors=0
mqueue_test: Canceling receiver
mqueue_test: receiver has already terminated

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     ccf0     ccf0
fordblks  7c08310  7c08310

user_main: signal handler test
sighand_test: Initializing semaphore to 0
sighand_test: Unmasking SIGCHLD
sighand_test: Registering SIGCHLD handler
sighand_test: Starting waiter task
sighand_test: Started waiter_main pid=350
waiter_main: Waiter started
waiter_main: Unmasking signal 32
waiter_main: Registering signal handler
waiter_main: oact.sigaction=0 oact.sa_flags=0 oact.sa_mask=0000000000000000
waiter_main: Waiting on semaphore
sighand_test: Signaling pid=350 with signo=32 sigvalue=42
waiter_main: sem_wait() successfully interrupted by signal
waiter_main: done
sighand_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        4
mxordblk  7bf0e30  7bf0e30
uordblks     ccf0     cd20
fordblks  7c08310  7c082e0

user_main: nested signal handler test
signest_test: Starting signal waiter task at priority 101
waiter_main: Waiter started
waiter_main: Setting signal mask
waiter_main: Registering signal handler
waiter_main: Waiting on semaphore
signest_test: Started waiter_main pid=351
signest_test: Starting interfering task at priority 102
interfere_main: Waiting on semaphore
signest_test: Started interfere_main pid=354
signest_test: Simple case:
  Total signalled 1240  Odd=620 Even=620
  Total handled   1240  Odd=620 Even=620
  Total nested    0    Odd=0   Even=0  
signest_test: With task locking
  Total signalled 2480  Odd=1240 Even=1240
  Total handled   2480  Odd=1240 Even=1240
  Total nested    0    Odd=0   Even=0  
signest_test: With interfering thread
  Total signalled 3720  Odd=1860 Even=1860
  Total handled   3720  Odd=1860 Even=1860
  Total nested    0    Odd=0   Even=0  
signest_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         4        7
mxordblk  7bf0e30  7bf0e30
uordblks     cd20     cde8
fordblks  7c082e0  7c08218

user_main: POSIX timer test
timer_test: Masking signal 32
timer_test: Creating timer
timer_test: Starting timer
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=1
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=2
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=3
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=4
timer_test: Waiting on sigwaitinfo
timer_test: sigwaitinfo() returned signo=32
timer_expiration: sival_int=42
timer_expiration: si_code=2 (SI_TIMER)
timer_expiration: g_nsigreceived=5
timer_test: Deleting timer
timer_test: done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

user_main: spinlock test
Start Lock test:
Thread num: 1, Loop times: 10000000

Test type: spinlock
spinlock: Test Results:
spinlock: Final counter: 10000000
spinlock: Average throughput : 29944169 op/s
spinlock: Total execution time: 334118592 ns
 
Test type: rspinlock
rspinlock: Test Results:
rspinlock: Final counter: 10000000
rspinlock: Average throughput : 24929799 op/s
rspinlock: Total execution time: 401188576 ns
 
Test type: seqcount
seqcount: Test Results:
seqcount: Final counter: 10000000
seqcount: Average throughput : 42023327 op/s
seqcount: Total execution time: 238034544 ns
 

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

user_main: wdog test
wdog_test start...
wdtest_once 0 ns
wdtest_once 0 ns
wdtest_once 0 ns
wdtest_once 0 ns
wdtest_once 1 ns
wdtest_once 1 ns
wdtest_once 1 ns
wdtest_once 1 ns
wdtest_once 10 ns
wdtest_once 10 ns
wdtest_once 10 ns
wdtest_once 10 ns
wdtest_once 100 ns
wdtest_once 100 ns
wdtest_once 100 ns
wdtest_once 100 ns
wdtest_once 1000 ns
wdtest_once 1000 ns
wdtest_once 1000 ns
wdtest_once 1000 ns
wdtest_once 10000 ns
wdtest_once 10000 ns
wdtest_once 10000 ns
wdtest_once 10000 ns
wdtest_once 100000 ns
wdtest_once 100000 ns
wdtest_once 100000 ns
wdtest_once 100000 ns
wdtest_once 1000000 ns
wdtest_once 1000000 ns
wdtest_once 1000000 ns
wdtest_once 1000000 ns
wd_start with maximum delay, cancel OK, rest 2305843009213693948
wdtest_recursive 1000000ns
wd_start with maximum delay, cancel OK, rest 2305843009213693948
wdtest_recursive 1000000ns
wd_start with maximum delay, cancel OK, rest 2305843009213693948
wdtest_recursive 1000000ns
wd_start with maximum delay, cancel OK, rest 2305843009213693948
wdtest_recursive 1000000ns
recursive wdog triggered 51 times, elapsed tick 102
wdtest_recursive 10000000ns
recursive wdog triggered 51 times, elapsed tick 102
wdtest_recursive 10000000ns
recursive wdog triggered 51 times, elapsed tick 102
wdtest_recursive 10000000ns
recursive wdog triggered 51 times, elapsed tick 102
wdtest_recursive 10000000ns
recursive wdog triggered 9 times, elapsed tick 99
recursive wdog triggered 9 times, elapsed tick 99
recursive wdog triggered 9 times, elapsed tick 99
recursive wdog triggered 9 times, elapsed tick 99
wdog_test end...

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

user_main: round-robin scheduler test
rr_test: Set thread priority to 1
rr_test: Set thread policy to SCHED_RR
rr_test: Starting first get_primes_thread
         First get_primes_thread: 366
rr_test: Starting second get_primes_thread
         Second get_primes_thread: 367
rr_test: Waiting for threads to complete -- this should take awhile
         If RR scheduling is working, they should start and complete at
         about the same time
get_primes_thread id=1 started, looking for primes < 30000, doing 10 run(s)
get_primes_thread id=2 started, looking for primes < 30000, doing 10 run(s)
get_primes_thread id=1 finished, found 3246 primes, last one was 29989
get_primes_thread id=2 finished, found 3246 primes, last one was 29989
rr_test: Done

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

user_main: barrier test
barrier_test: Initializing barrier
barrier_test: Thread 0 created
barrier_test: Thread 1 created
barrier_test: Thread 2 created
barrier_test: Thread 3 created
barrier_test: Thread 4 created
barrier_test: Thread 5 created
barrier_test: Thread 6 created
barrier_test: Thread 7 created
barrier_func: Thread 0 started
barrier_func: Thread 1 started
barrier_func: Thread 2 started
barrier_func: Thread 3 started
barrier_func: Thread 4 started
barrier_func: Thread 5 started
barrier_func: Thread 6 started
barrier_func: Thread 7 started
barrier_func: Thread 0 calling pthread_barrier_wait()
barrier_func: Thread 1 calling pthread_barrier_wait()
barrier_func: Thread 2 calling pthread_barrier_wait()
barrier_func: Thread 3 calling pthread_barrier_wait()
barrier_func: Thread 4 calling pthread_barrier_wait()
barrier_func: Thread 5 calling pthread_barrier_wait()
barrier_func: Thread 6 calling pthread_barrier_wait()
barrier_func: Thread 7 calling pthread_barrier_wait()
barrier_func: Thread 7, back with status=PTHREAD_BARRIER_SERIAL_THREAD (I AM SPECIAL)
barrier_func: Thread 0, back with status=0 (I am not special)
barrier_func: Thread 1, back with status=0 (I am not special)
barrier_func: Thread 2, back with status=0 (I am not special)
barrier_func: Thread 3, back with status=0 (I am not special)
barrier_func: Thread 4, back with status=0 (I am not special)
barrier_func: Thread 5, back with status=0 (I am not special)
barrier_func: Thread 6, back with status=0 (I am not special)
barrier_func: Thread 7 done
barrier_func: Thread 0 done
barrier_func: Thread 1 done
barrier_func: Thread 2 done
barrier_func: Thread 3 done
barrier_test: Thread 0 completed with result=0
barrier_test: Thread 1 completed with result=0
barrier_test: Thread 2 completed with result=0
barrier_test: Thread 3 completed with result=0
barrier_func: Thread 4 done
barrier_func: Thread 5 done
barrier_func: Thread 6 done
barrier_test: Thread 4 completed with result=0
barrier_test: Thread 5 completed with result=0
barrier_test: Thread 6 completed with result=0
barrier_test: Thread 7 completed with result=0

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

user_main: scheduler lock test
sched_lock: Starting lowpri_thread at 97
sched_lock: Set lowpri_thread priority to 97
sched_lock: Starting highpri_thread at 98
sched_lock: Set highpri_thread priority to 98
sched_lock: Waiting...
sched_lock: PASSED No pre-emption occurred while scheduler was locked.
sched_lock: Starting lowpri_thread at 97
sched_lock: Set lowpri_thread priority to 97
sched_lock: Starting highpri_thread at 98
sched_lock: Set highpri_thread priority to 98
sched_lock: Waiting...
sched_lock: PASSED No pre-emption occurred while scheduler was locked.
sched_lock: Finished

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         7        7
mxordblk  7bf0e30  7bf0e30
uordblks     cde8     cde8
fordblks  7c08218  7c08218

Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7c15000  7c15000
ordblks         3        7
mxordblk  7c07c10  7bf0e30
uordblks     cbf0     cde8
fordblks  7c08410  7c08218
user_main: Exiting
ostest_main: Exiting with status 0
nsh> qemu-system-aarch64: terminating on signal 15 from pid 1 (timeout)

FAR struct bchlib_s *bch;
int ret = OK;

if (!nxsched_capable(PR_CAP_RAWIO))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm that one only catches BLOCK/MTD. a node from bchdev_register() is a plain char driver, so file_vopen can't tell its raw storage. so bch_open() covers that case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but bch_register is only called inside file_open?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only tho. block_proxy makes /dev/tmpcXXXXXX (just a counter, easy to guess) and unlinks it only after the open, so another task can grab it in that gap. and apps can call bchdev_register directly too, eg examples/mtdrwb makes /dev/mtd0 and it stays. bch_open is the one spot both go thru. ok to keep it?

Comment thread fs/mount/fs_umount2.c
Comment thread fs/mount/fs_mount.c
Comment thread binfmt/binfmt_exec.c
royzah added 7 commits October 2, 2026 07:02
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 <royzah@gmail.com>
Indent the bch_seek() switch cases so the file passes nxstyle.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
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 <royzah@gmail.com>
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 <royzah@gmail.com>
Indentation and comment fixes only, so the next change passes the style
check.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
boardctl(BOARDIOC_RESET) and boardctl(BOARDIOC_POWEROFF) refuse a task
group without it.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
What each capability guards, the prctl() interface, inheritance through
the task group, and where the checks sit.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
@royzah

royzah commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

pushed. CI red was nucleo-g431rb:cansock out of flash, it only had ~250 B left. so added CONFIG_SCHED_CAPABILITIES (off with DEFAULT_SMALL) and turned it off there, now it builds 32 B over master. also regrouped commits per cap like u asked. fresh logs in the body

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 <royzah@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: BINFMT Board: arm Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants