github-actions[bot] commented on code in PR #67312:
URL: https://github.com/apache/doris/pull/67312#discussion_r3887284319
##########
be/CMakeLists.txt:
##########
@@ -771,8 +771,15 @@ endif()
# NOTE(amos): This should come before -lc -lm to interpose symbols correctly.
if (GLIBC_COMPATIBILITY)
- add_subdirectory(${SRC_DIR}/glibc-compatibility)
- set(DORIS_LINK_LIBS ${DORIS_LINK_LIBS} glibc-compatibility-explicit
glibc-compatibility)
+ add_subdirectory(${SRC_DIR}/glibc-compatibility).
Review Comment:
[P1] Remove the trailing dot so CMake can parse this listfile. CMake treats
the `.` after `add_subdirectory(...)` as a standalone unquoted argument and
fails before evaluating any configuration branch, so both compatibility-enabled
builds and configurations where this `if` would be false stop during configure.
```suggestion
add_subdirectory(${SRC_DIR}/glibc-compatibility)
```
##########
be/src/glibc-compatibility/musl/posix_spawnp.c:
##########
@@ -0,0 +1,16 @@
+#include <spawn.h>
+
+int __execvpe(const char* file, char* const argv[], char* const envp[]);
+
+int __posix_spawnx(pid_t* restrict result, const char* restrict path,
+ int (*exec)(const char*, char* const*, char* const*),
+ const posix_spawn_file_actions_t* file_actions,
+ const posix_spawnattr_t* restrict attr, char* const
argv[restrict],
+ char* const envp[restrict]);
+
+int posix_spawnp(pid_t* restrict result, const char* restrict file,
+ const posix_spawn_file_actions_t* file_actions,
+ const posix_spawnattr_t* restrict attr, char* const
argv[restrict],
+ char* const envp[restrict]) {
+ return __posix_spawnx(result, file, __execvpe, file_actions, attr, argv,
envp);
Review Comment:
[P1] Do not expose this through the reduced clang-only `__posix_spawnx`
backend. That child stores `file_actions` but never executes them, restores an
uninitialized `oldmask` when `SETSIGMASK` is absent, and ignores
`SIGDEF`/process-group/session attributes. It also assumes a raw negative clone
errno even though glibc `clone()` returns `-1` and sets `errno`, so every clone
failure becomes `EPERM`. Rust 1.91 `Command` uses dup2/chdir actions and these
default attributes before calling `posix_spawnp`; this path can therefore
return success with wrong pipes, cwd, and signal state. Please restore the
complete adapted spawn child/action/attribute/error path before
force-interposing it.
##########
be/src/glibc-compatibility/musl/execvpe.c:
##########
@@ -0,0 +1,55 @@
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static char* strchrnul_compat(const char* str, int ch) {
+ const char* found = strchr(str, ch);
+ return (char*)(found ? found : str + strlen(str));
+}
+
+int __execvpe(const char* file, char* const argv[], char* const envp[]) {
+ const char* path = getenv("PATH");
+ int seen_eacces = 0;
+
+ errno = ENOENT;
+ if (!*file) return -1;
+ if (strchr(file, '/')) return execve(file, argv, envp);
+ if (!path) path = "/usr/local/bin:/bin:/usr/bin";
+
+ size_t file_len = strnlen(file, NAME_MAX + 1);
+ if (file_len > NAME_MAX) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ size_t path_len = strnlen(path, PATH_MAX - 1) + 1;
+
+ const char* cursor;
+ const char* end;
+ for (cursor = path;; cursor = end) {
+ char candidate[path_len + file_len + 1];
Review Comment:
[P1] Size the clone stack for this allocation. `posix_spawnp` now calls
`__execvpe` inside the existing `CLONE_VM|CLONE_VFORK` child, but that backend
supplies only a 1 KiB stack. Here `candidate` can be `PATH_MAX + NAME_MAX + 1`
bytes (4352 bytes on Linux), so a long valid `PATH` writes below the supplied
child stack and can corrupt the suspended parent's live stack before `execve`.
The full spawn path needs a stack sized for the worst-case PATH search (and a
regression with a PATH over 1 KiB).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]