nuttx/binfmt
Marco Casaroli c642e99b34 binfmt: Update the TLS pid when exec() swaps the pids.
exec() swaps the pids of the caller and the new task, so that the new
program keeps the pid of the caller.  exec_swap() changes tcb->pid and
group->tg_pid.  But getpid() and gettid() read the copies in TLS,
tg_info->ta_pid and tl_tid, and exec_swap() does not change them.  So
getpid() in the new program returns the pid that the caller has now, and
kill(getpid(), sig) sends the signal to the caller.

Make exec_swap() update both copies for both tasks.  The address
environment of the new task is current in exec_swap().  The TLS of the
caller is in the address environment of the caller, so exec_swap()
selects that environment for the update of the caller.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-10-07 21:55:25 +08:00
..
libnxflat libs/libc: Define the NXFLAT ABI marker in libc. 2026-09-28 16:45:48 -03:00
binfmt.h fs/binfmt: Enforce POSIX execute permissions prior to binary load 2026-06-13 21:07:01 +08:00
binfmt_checkexec.c sched: add supplementary group IDs (setgroups/getgroups/initgroups) 2026-08-12 16:06:03 -03:00
binfmt_copyactions.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_copyargv.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_dumpmodule.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_exec.c fs/binfmt: Enforce POSIX execute permissions prior to binary load 2026-06-13 21:07:01 +08:00
binfmt_execmodule.c binfmt: Update the TLS pid when exec() swaps the pids. 2026-10-07 21:55:25 +08:00
binfmt_execsymtab.c sched: binfmt remove csection 2026-01-11 20:44:35 +08:00
binfmt_exit.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_globals.c binfmt: migrate to SPDX identifier 2024-09-10 11:34:18 +08:00
binfmt_initialize.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_loadmodule.c fs/binfmt: Enforce POSIX execute permissions prior to binary load 2026-06-13 21:07:01 +08:00
binfmt_register.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_unloadmodule.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
binfmt_unregister.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
builtin.c fs/binfmt: Enforce POSIX execute permissions prior to binary load 2026-06-13 21:07:01 +08:00
CMakeLists.txt cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
elf.c binfmt/elf: Load FDPIC modules through the ELF loader. 2026-09-26 11:13:30 -03:00
Kconfig binfmt, arch/arm: Add the CONFIG_FDPIC option and the ABI header. 2026-09-08 16:31:16 -03:00
Makefile tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
nxflat.c fs/binfmt: Enforce POSIX execute permissions prior to binary load 2026-06-13 21:07:01 +08:00