[PATCH v8 11/14] applets: use bb_execXX functions instead of direct exec calls

2025-03-09 Thread Nadav Tasher
This replaces all invocations of functions from the exec family with the equivalent proxy functions. This change provides better control over executed programs and allows all applets to seamlessly execute other applets when FEATURE_PREFER_APPLETS is enabled. Signed-off-by: Nadav Tasher --- arch

[PATCH v8 03/14] libbb: implement close_cloexec_fds

2025-03-09 Thread Nadav Tasher
This commit implements the close_cloexec_fds() function, which manually closes all FDs that have the FD_CLOEXEC flag. Signed-off-by: Nadav Tasher --- include/libbb.h | 1 + libbb/xfuncs.c | 10 ++ 2 files changed, 11 insertions(+) diff --git a/include/libbb.h b/include/libbb.h index b

[PATCH v8 05/14] libbb: implement bb_execXX function family to handle applet executions

2025-03-09 Thread Nadav Tasher
This commit implements proxy functions for the exec family of functions. bb_execv, bb_execve, bb_execvp and bb_execvpe were implemented as proxy functions to their libc counterparts. applet_execve and applet_execvpe were implemented as internal utility functions and are used by bb_exec function f

[PATCH v8 06/14] libbb: make spawn and spawn_and_wait use bb_execvp

2025-03-09 Thread Nadav Tasher
This change allows moving NOEXEC support to bb_execvp. This reduces code duplication and broadens the support of NOEXEC applet execution in the codebase. Signed-off-by: Nadav Tasher --- libbb/vfork_daemon_rexec.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(

[PATCH v8 09/14] ash: use bb_execve to execute commands and applets in tryexec

2025-03-09 Thread Nadav Tasher
This commit makes the shell use the bb_execve proxy function. bb_execve calls applet_execve, which might execute applets directly. Signed-off-by: Nadav Tasher --- shell/ash.c | 72 +++-- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git

[PATCH v8 14/14] libbb: implement re_exec using bb_execv

2025-03-09 Thread Nadav Tasher
By using bb_execv, an applet can be executed with NOEXEC instead of actually re-executing the binary, which might not work in scenareos where busybox is embedded into another binary. Signed-off-by: Nadav Tasher --- libbb/vfork_daemon_rexec.c | 9 +++-- 1 file changed, 7 insertions(+), 2 dele

[PATCH v8 01/14] libbb: mask xvfork to xfork on MMU targets

2025-03-09 Thread Nadav Tasher
Using xfork() instead of xvfork() on MMU targets improves security and stability. Memory efficiency differences are negligable since most kernels implement fork() with CoW. Signed-off-by: Nadav Tasher --- include/libbb.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a

[PATCH v8 07/14] libbb: implement bb_system using spawn_and_wait

2025-03-09 Thread Nadav Tasher
Implemented bb_system using spawn_and_wait in conjuction with "sh", to allow bb_system to execute the internal shell when using the FEATURE_PREFER_APPLETS config option. When FEATURE_PREFER_APPLETS is disabled, libc "system()" is used. Signed-off-by: Nadav Tasher --- include/libbb.h

[PATCH v8 04/14] libbb: implement reset_all_signals

2025-03-09 Thread Nadav Tasher
This commit adds the reset_all_signals() function, which resets all custom signal handlers to the default signal handler (SIG_DFL). Signed-off-by: Nadav Tasher --- include/libbb.h | 2 ++ libbb/signals.c | 26 ++ 2 files changed, 28 insertions(+) diff --git a/include/li

[PATCH v8 10/14] tar: replace execlp call with bb_execvp, disable xz compression support when FEATURE_PREFER_APPLETS is enabled

2025-03-09 Thread Nadav Tasher
Using bb_execvp allows for more control over the compressor program executed, and might execute an applet instead of an external program. The xz compressor is disabled when FEATURE_PREFER_APPLETS is enabled, since the xz applet does not support compression. Signed-off-by: Nadav Tasher --- archi

[PATCH v8 13/14] libbb: allow forcing all applets to behave as NOEXEC applets

2025-03-09 Thread Nadav Tasher
This patch adds an experimental configuration option to allow the applet_execvpe function to treat all applets as if they were NOEXEC. This is experimental, as noted in the configuration description. Signed-off-by: Nadav Tasher --- Config.in | 12 libbb/executable.c | 2 +

[PATCH v8 08/14] applets: change system() calls to bb_system()

2025-03-09 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS configuration option is enabled.. Signed-off-by: Nadav Tasher --- archival/dpkg.c | 2 +- editors/awk.c | 2 +- editors/vi.c | 2 +- init/bootchartd.c | 2 +- miscutils/man.c | 2 +- netwo

[PATCH v8 12/14] httpd: replace execv call with bb_execv and disable FEATURE_HTTPD_CGI when FEATURE_FORCE_APPLETS is enabled

2025-03-09 Thread Nadav Tasher
Due to a limit imposed by FEATURE_FORCE_APPLETS, execv is not allowed. The execv call is required to execute CGI binaries, so it makes FEATURE_HTTPD_CGI depend on FEATURE_FORCE_APPLET being disabled. The execv call was changed to bb_execv, mostly for keeping the codebase consistent, as all applets