3737#include "runtime/futex.h"
3838
3939#include "syscall/abi.h"
40+ #include "syscall/chown-overlay.h"
4041#include "syscall/internal.h"
4142#include "syscall/mem.h"
4243#include "syscall/net.h" /* absock namespace IPC state */
@@ -101,8 +102,8 @@ int fork_child_main(int ipc_fd,
101102 proc_init ();
102103 fork_child_vfork_notify_fd = vfork_notify_fd ;
103104
104- /* The header fixes the IPC protocol version and the guest identity before
105- * any variable-length state is trusted.
105+ /* The header magic identifies the fork IPC protocol before any
106+ * variable-length state is trusted.
106107 */
107108 ipc_header_t hdr ;
108109 if (fork_ipc_read_all (ipc_fd , & hdr , sizeof (hdr )) < 0 ) {
@@ -113,14 +114,6 @@ int fork_child_main(int ipc_fd,
113114 log_error ("fork-child: bad magic 0x%x" , hdr .magic );
114115 return 1 ;
115116 }
116- if (hdr .version != IPC_VERSION ) {
117- log_error (
118- "fork-child: IPC version mismatch "
119- "(got %u, expected %u)" ,
120- hdr .version , IPC_VERSION );
121- return 1 ;
122- }
123-
124117 log_debug ("fork-child: pid=%lld ppid=%lld" , (long long ) hdr .child_pid ,
125118 (long long ) hdr .parent_pid );
126119
@@ -241,7 +234,7 @@ int fork_child_main(int ipc_fd,
241234 * primary buffer and is copied by the region transfer below, so the child
242235 * can reuse it without rebuilding the tree.
243236 */
244- g .is_rosetta = ( hdr .is_rosetta != 0 ) ;
237+ g .is_rosetta = hdr .is_rosetta ;
245238 proc_set_rosetta_active (g .is_rosetta );
246239 g .rosetta_guest_base = hdr .rosetta_guest_base ;
247240 g .rosetta_va_base = hdr .rosetta_va_base ;
@@ -288,6 +281,12 @@ int fork_child_main(int ipc_fd,
288281 return 1 ;
289282 }
290283
284+ if (chown_overlay_recv (ipc_fd ) < 0 ) {
285+ log_error ("fork-child: failed to receive chown overlay" );
286+ guest_destroy (& g );
287+ return 1 ;
288+ }
289+
291290 /* POSIX: "Signals pending to the parent shall not be pending to the child."
292291 * Clear pending bitmask and RT queue before applying state.
293292 * signal_set_state() is deferred until after thread_register_main() so that
@@ -1521,9 +1520,8 @@ int64_t sys_clone(hv_vcpu_t vcpu,
15211520 /* Header */
15221521 ipc_header_t hdr = {
15231522 .magic = IPC_MAGIC_HEADER ,
1524- .version = IPC_VERSION ,
15251523 .ipa_bits = g -> ipa_bits ,
1526- .has_shm = ( uint32_t ) use_shm ,
1524+ .has_shm = use_shm ,
15271525 .child_pid = child_guest_pid ,
15281526 .parent_pid = proc_get_pid (),
15291527 .guest_size = g -> guest_size ,
@@ -1548,7 +1546,7 @@ int64_t sys_clone(hv_vcpu_t vcpu,
15481546 .absock_namespace_id = absock_get_namespace_id (),
15491547 .sid = proc_get_sid (),
15501548 .pgid = proc_get_pgid (),
1551- .is_rosetta = g -> is_rosetta ? 1 : 0 ,
1549+ .is_rosetta = g -> is_rosetta ,
15521550 .rosetta_guest_base = g -> rosetta_guest_base ,
15531551 .rosetta_va_base = g -> rosetta_va_base ,
15541552 .rosetta_size = g -> rosetta_size ,
@@ -1652,6 +1650,11 @@ int64_t sys_clone(hv_vcpu_t vcpu,
16521650 goto fail_snapshot ;
16531651 }
16541652
1653+ if (chown_overlay_send (ipc_sock ) < 0 ) {
1654+ log_error ("clone: failed to send chown overlay" );
1655+ goto fail_snapshot ;
1656+ }
1657+
16551658 /* The process-state payload includes the SCM_RIGHTS handoff for region
16561659 * backing fds. Keep siblings quiesced until that send completes so a
16571660 * concurrent munmap/remap cannot close or recycle the captured fd numbers.
0 commit comments