]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
security: Round 5.5 posix_spawn PID fix (A13)
authorTulio A M Mendes <[email protected]>
Mon, 25 May 2026 19:16:48 +0000 (16:16 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 04:02:35 +0000 (01:02 -0300)
A13: Fix posix_spawn wrapper to preserve child PID
- Kernel copies child PID to *pid via copy_to_user
- Wrapper was overwriting *pid with return value (0 on success)
- Removed the line that overwrote *pid, kernel already filled it in

Tests: 119/119 PASS (smoke test, SMP=4)

user/ulibc/src/spawn.c

index a39a57afeb20098f1cb5ae329d2fd9aad9bf01ab..de0c4168e97c44efadaa6152a31afc95bb571082 100644 (file)
@@ -18,12 +18,13 @@ int posix_spawn(int* pid, const char* path,
                 char* const argv[], char* const envp[]) {
     (void)file_actions;
     (void)attrp;
+    /* A13: Kernel copies child PID to *pid via copy_to_user, return value is 0 on success */
     int ret = _syscall4(SYS_POSIX_SPAWN, (int)pid, (int)path, (int)argv, (int)envp);
     if (ret < 0) {
         errno = -ret;
         return -ret;
     }
-    if (pid) *pid = ret;
+    /* Don't overwrite *pid - kernel already filled it in */
     return 0;
 }