nuttx/arch/arm/src
Marco Casaroli 112b2414ac arch/arm: carry CONTROL over to the fork child on Cortex-M
In a protected build arm_svcall.c treats the caller's CONTROL as part of
the saved system call state: it stores it in xcp.syscall[].ctrlreturn on
entry and restores it from there on SYS_syscall_return.  All three
Cortex-M profiles do this -- armv6-m, armv7-m and armv8-m each define the
field in arch/arm/include/<arch>/irq.h and use it symmetrically.

arm_fork_direct() copied sysreturn and excreturn to the child but not
ctrlreturn.  The child's TCB comes from kmm_zalloc(), so the field was
zero, and CONTROL == 0 is nPRIV clear: the child returned to user space
privileged while its parent returned unprivileged.  The child ran out its
life with the MPU restrictions its parent is under silently lifted, which
is the isolation BUILD_PROTECTED exists to provide.

Nothing faults, and that is why this survived.  CONTROL == 0 also selects
MSP, which sounds like it should crash immediately, but NuttX already
runs Cortex-M threads on MSP -- the parent's saved value is 0x1, nPRIV
set and SPSEL clear -- so the two differ only in the privilege bit and
there is no stack change to trip over.  Privileged code then passes every
test unprivileged code passes, so ostest cannot see it either.

Measured on an RP2350 (Cortex-M33) in BUILD_PROTECTED, breaking at the
nxtask_start_fork() call in arm_fork_direct() during task_fork_test:
parent ctrlreturn 0x00000001, child ctrlreturn 0x00000000.  With this
change both read 0x00000001.

BUILD_FLAT is unaffected: without CONFIG_LIB_SYSCALL, nsyscalls is 0 and
the whole block is skipped.  armv7-a and armv7-r are unaffected too; they
carry cpsr instead, and that is already copied.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-04 00:35:32 +08:00
..
a1x include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
am67 boards/arm/am67: Add support for t3-gem-o1 board. 2026-05-28 14:16:03 +02:00
am335x style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
arm arch/arm: fix infinite loop in test and clean cache operations 2026-05-19 19:49:55 +08:00
armv6-m arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-17 17:11:26 +08:00
armv7-a arch/arm/armv7-a: Fix L1 page table entry double-offset in addrenv create region 2026-06-23 10:45:03 +08:00
armv7-m armv7-m/armv8-m: honor SP modifications on signal return 2026-07-03 10:16:25 -04:00
armv7-r arch/armv7-r: fix duplicate arm_perf.o build rule in flat build 2026-05-28 14:16:03 +02:00
armv8-m arch/arm: set PSPLIM to top of TLS region to protect it from overflow 2026-08-03 21:28:55 +08:00
armv8-r arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-17 17:11:26 +08:00
at32 drivers: Fix comment typos — 'Pubic' → 'Public' across drivers and headers. 2026-07-04 02:00:24 +08:00
c5471 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
cmake cmake/elf: Fix ELF entry point from __start to _start 2026-06-11 03:23:04 +08:00
common arch/arm: carry CONTROL over to the fork child on Cortex-M 2026-08-04 00:35:32 +08:00
csk6 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
cxd32xx include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
cxd56xx drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
dm320 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
efm32 arch: remove PULSECOUNT references from PWM drivers 2026-05-25 14:33:11 +02:00
eoss3 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
fvp-v8r-aarch32 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
gd32f4 arch/arm/gd32f4: fix missing CTL selector bits in up_disableusartint. 2026-06-24 12:19:17 +08:00
goldfish include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
ht32f491x3 !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
imx1 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
imx6 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
imx9 arch/arm/imx9: Add SAR ADC support 2026-05-21 23:13:11 -04:00
imxrt !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
kinetis !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
kl !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
lc823450 libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
lpc17xx_40xx !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
lpc31xx !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
lpc43xx !sched/clock: remove CONFIG_SYSTEM_TIME64 and always use 64-bit time 2026-05-19 16:21:28 +08:00
lpc54xx !sched/clock: remove CONFIG_SYSTEM_TIME64 and always use 64-bit time 2026-05-19 16:21:28 +08:00
lpc214x style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
lpc2378 arch/arm: Fix LPC2378 to work again 2026-07-02 11:29:02 -03:00
max326xx !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
mcx-nxxx include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
moxart ghs: fix the UsageFault:INVSTATE error triggered by exception_common 2026-01-16 09:41:13 +08:00
mps include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
mx8mp include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
nrf52 arch/arm/nrf52,nrf53: don't pass HCI messages under the lock 2026-08-03 23:17:25 +08:00
nrf53 arch/arm/nrf52,nrf53: don't pass HCI messages under the lock 2026-08-03 23:17:25 +08:00
nrf91 arch/arm: nrf91: bound modem version parsing 2026-07-06 16:35:28 +08:00
nuc1xx style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
phy62xx drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
qemu include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
ra4 !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
rp23xx arch/rp23xx: Fix six register/bit macro name clashes. 2026-08-03 23:17:05 +08:00
rp2040 drivers/audio/i2s: Fix unsigned integers in function signatures 2026-07-06 19:57:13 +08:00
rtl8720c drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
s32k1xx libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
s32k3xx !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
sam34 !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
sama5 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
samd2l2 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
samd5e5 !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
samv7 drivers/audio/i2s: Fix unsigned integers in function signatures 2026-07-06 19:57:13 +08:00
stm32c0 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f0 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f1 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f2 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f3 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f4 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32f7 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32g0 stm32g0: Fix FLASHIF typo 2026-08-03 22:21:26 +08:00
stm32g4 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32h5 arch/arm/src/stm32: fix H5 I2C kernel-clock register names 2026-08-03 17:16:42 +08:00
stm32h7 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32l0 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32l1 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-05 01:13:16 +08:00
stm32l4 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32l5 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32n6 !arch/stm32n6: use common STM32 Kconfig symbols 2026-06-24 23:14:35 +08:00
stm32u5 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32wb Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
stm32wl5 Review: Address @raiden00pl comments 2026-08-03 23:16:27 +08:00
str71x style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
tiva arch/arm/src/at32/at32_can: Division by Zero in CAN Bit Timing Commands 2026-07-04 01:56:16 +08:00
tlsr82 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
tms570 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
xmc4 arch/arm: xmc4: fix VADC index bounds checks 2026-07-06 16:35:18 +08:00
.gitignore
CMakeLists.txt arch/qemu-armv7a: kernel mode cmake support 2025-01-02 23:13:07 +08:00
Makefile arch/*/src/Makefile: Avoid uncessary relinking of the nuttx binary. 2026-05-18 09:33:58 +02:00