this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hook up signal reprocessing with darlingserver

Also, dserver RPC error codes should be negative; make them so.

+50 -50
-3
src/kernel/emulation/linux/bsdthread/bsdthread_terminate.c
··· 3 3 #include "../base.h" 4 4 #include "../errno.h" 5 5 #include <sys/errno.h> 6 - #include "../../../../external/lkm/api.h" 7 6 #include <linux-syscalls/linux.h> 8 7 #include <stddef.h> 9 8 #include <stdint.h> ··· 24 23 // Implemented in libdyld 25 24 extern int __darling_thread_terminate(void* stackaddr, 26 25 unsigned long freesize, unsigned long pthobj_size); 27 - extern int lkm_call(int, void*); 28 26 29 27 semaphore_signal_trap_impl(join_sem); 30 - lkm_call(NR_thread_death_announce, 0); 31 28 32 29 return __darling_thread_terminate(stackaddr, freesize, pthread_obj_size); 33 30 #else
+14 -3
src/kernel/emulation/linux/resources/dserver-rpc-defs.h
··· 34 34 35 35 #define dserver_rpc_hooks_get_tid() ((pid_t)LINUX_SYSCALL(__NR_gettid)) 36 36 37 + #if __x86_64__ 38 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_x86_64 39 + #elif __i386__ 40 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_i386 41 + #elif __aarch64__ 42 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_arm64 43 + #elif __arm__ 44 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_arm32 45 + #else 46 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_invalid 47 + #endif 37 48 38 49 #define dserver_rpc_hooks_get_server_address() ((void*)__dserver_socket_address()) 39 50 ··· 57 68 #endif 58 69 }; 59 70 60 - #define dserver_rpc_hooks_get_bad_message_status() LINUX_EBADMSG 71 + #define dserver_rpc_hooks_get_bad_message_status() (-LINUX_EBADMSG) 61 72 62 - #define dserver_rpc_hooks_get_communication_error_status() LINUX_ECOMM 73 + #define dserver_rpc_hooks_get_communication_error_status() (-LINUX_ECOMM) 63 74 64 - #define dserver_rpc_hooks_get_broken_pipe_status() LINUX_EPIPE 75 + #define dserver_rpc_hooks_get_broken_pipe_status() (-LINUX_EPIPE) 65 76 66 77 #define dserver_rpc_hooks_close_fd(fd) ((int)LINUX_SYSCALL1(__NR_close, fd)) 67 78
+14 -13
src/kernel/emulation/linux/signal/sigexc.c
··· 235 235 return; 236 236 } 237 237 238 - struct sigprocess_args sigprocess; 239 - sigprocess.signum = bsd_signum; 240 - 241 - memcpy(&sigprocess.linux_siginfo, info, sizeof(*info)); 242 - 243 238 #ifdef __x86_64__ 244 239 kern_printf("sigexc: have RIP 0x%llx\n", ctxt->uc_mcontext.gregs.rip); 245 240 #endif ··· 254 249 x86_float_state32_t fstate; 255 250 #endif 256 251 257 - sigprocess.state.tstate = &tstate; 258 - sigprocess.state.fstate = &fstate; 252 + struct thread_state state = { 253 + .tstate = &tstate, 254 + .fstate = &fstate, 255 + }; 259 256 260 - state_to_kernel(ctxt, &sigprocess.state); 261 - lkm_call(NR_sigprocess, &sigprocess); 262 - state_from_kernel(ctxt, &sigprocess.state); 257 + state_to_kernel(ctxt, &state); 258 + int ret = dserver_rpc_sigprocess(bsd_signum, linux_signum, info->si_pid, info->si_code, info->si_addr, &tstate, &fstate, &bsd_signum); 259 + if (ret < 0) { 260 + __simple_printf("sigprocess failed internally: %d", ret); 261 + __simple_abort(); 262 + } 263 + state_from_kernel(ctxt, &state); 263 264 264 - if (!sigprocess.signum) 265 + if (!bsd_signum) 265 266 { 266 267 kern_printf("sigexc: drop signal\n"); 267 268 return; 268 269 } 269 270 270 - linux_signum = signum_bsd_to_linux(sigprocess.signum); 271 + linux_signum = signum_bsd_to_linux(bsd_signum); 271 272 272 273 if (sig_handlers[linux_signum] != SIG_IGN) 273 274 { ··· 289 290 } 290 291 else 291 292 { 292 - if (sigprocess.signum == SIGTSTP || sigprocess.signum == SIGSTOP) 293 + if (bsd_signum == SIGTSTP || bsd_signum == SIGSTOP) 293 294 { 294 295 kern_printf("sigexc: emulating SIGTSTP/SIGSTOP\n"); 295 296 LINUX_SYSCALL(__NR_kill, 0, LINUX_SIGSTOP);
-19
src/kernel/emulation/linux/vchroot_expand.c
··· 1 - #include "vchroot_expand.h" 2 - #include <mach/lkm.h> 3 - 4 - int vchroot_expand(struct vchroot_expand_args* args) 5 - { 6 - if (strncmp(args->path, "/Volumes/SystemRoot", 19) == 0) 7 - { 8 - memmove(args->path, args->path + 19, strlen(args->path + 19) + 1); 9 - if (args->path[0] == 0) 10 - { 11 - args->path[0] = '/'; 12 - args->path[1] = '\0'; 13 - } 14 - 15 - return 0; 16 - } 17 - 18 - return lkm_call(NR_vchroot_expand, args); 19 - }
+7 -9
src/startup/mldr/elfcalls/threads.c
··· 305 305 int __darling_thread_terminate(void* stackaddr, 306 306 unsigned long freesize, unsigned long pthobj_size) 307 307 { 308 + if (dserver_rpc_checkout(-1, false) < 0) { 309 + // failing to checkout is not fatal. 310 + // it's not ideal, but it's not fatal. 311 + #define CHECKOUT_FAILURE_MESSAGE "Failed to checkout" 312 + dserver_rpc_kprintf(CHECKOUT_FAILURE_MESSAGE, sizeof(CHECKOUT_FAILURE_MESSAGE) - 1); 313 + } 314 + 308 315 if (getpid() == syscall(SYS_gettid)) 309 316 { 310 317 // dispatch_main() calls pthread_exit(NULL) on the main thread, ··· 315 322 316 323 while (1) 317 324 sigsuspend(&mask); 318 - } 319 - 320 - // only threads that aren't the main thread should checkout 321 - // the main thread will automatically checkout when the process dies 322 - if (dserver_rpc_checkout(-1, false) < 0) { 323 - // failing to checkout is not fatal. 324 - // it's not ideal, but it's not fatal. 325 - #define CHECKOUT_FAILURE_MESSAGE "Failed to checkout" 326 - dserver_rpc_kprintf(CHECKOUT_FAILURE_MESSAGE, sizeof(CHECKOUT_FAILURE_MESSAGE) - 1); 327 325 } 328 326 329 327 t_freeaddr = stackaddr;
+15 -3
src/startup/mldr/resources/dserver-rpc-defs.h
··· 21 21 22 22 #define dserver_rpc_hooks_get_tid() ((pid_t)syscall(SYS_gettid)) 23 23 24 + #if __x86_64__ 25 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_x86_64 26 + #elif __i386__ 27 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_i386 28 + #elif __aarch64__ 29 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_arm64 30 + #elif __arm__ 31 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_arm32 32 + #else 33 + #define dserver_rpc_hooks_get_architecture() dserver_rpc_architecture_invalid 34 + #endif 35 + 24 36 extern struct sockaddr_un __dserver_socket_address_data; 25 37 26 38 #define dserver_rpc_hooks_get_server_address() ((void*)&__dserver_socket_address_data) ··· 45 57 return ret; 46 58 }; 47 59 48 - #define dserver_rpc_hooks_get_bad_message_status() EBADMSG 60 + #define dserver_rpc_hooks_get_bad_message_status() (-EBADMSG) 49 61 50 - #define dserver_rpc_hooks_get_communication_error_status() ECOMM 62 + #define dserver_rpc_hooks_get_communication_error_status() (-ECOMM) 51 63 52 - #define dserver_rpc_hooks_get_broken_pipe_status() EPIPE 64 + #define dserver_rpc_hooks_get_broken_pipe_status() (-EPIPE) 53 65 54 66 #define dserver_rpc_hooks_close_fd close 55 67