this repo has no description
1
fork

Configure Feed

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

Import `__darwin_check_fd_set_overflow` from Apple open-source

+47
+12
src/kernel/libsyscall/wrappers/_libc_funcptr.c
··· 87 87 } 88 88 } 89 89 90 + __attribute__((visibility("hidden"))) 91 + int 92 + pthread_current_stack_contains_np(const void *addr, size_t len) 93 + { 94 + if (_libkernel_functions->version >= 4 && 95 + _libkernel_functions->pthread_current_stack_contains_np) { 96 + return _libkernel_functions->pthread_current_stack_contains_np(addr, len); 97 + } 98 + 99 + return 0; 100 + } 101 + 90 102 /* 91 103 * Upcalls to optimized libplatform string functions 92 104 */
+3
src/kernel/libsyscall/wrappers/_libkernel_init.h
··· 64 64 /* The following functions are included in version 3 of this structure */ 65 65 void (*pthread_clear_qos_tsd)(mach_port_t); 66 66 67 + /* The following functions are included in version 4 of this structure */ 68 + int (*pthread_current_stack_contains_np)(const void *, size_t); 69 + 67 70 /* Subsequent versions must only add pointers! */ 68 71 void (*dyld_func_lookup)(const char*,void**); 69 72 } *_libkernel_functions_t;
+30
src/kernel/libsyscall/wrappers/terminate_with_reason.c
··· 24 24 #include <sys/types.h> 25 25 #include <stdint.h> 26 26 #include <signal.h> 27 + #include <os/reason_private.h> 27 28 #include <unistd.h> 29 + 30 + /* Crash simulation */ 31 + 32 + extern int pthread_current_stack_contains_np(const void *, unsigned long); 33 + int 34 + __darwin_check_fd_set_overflow(int n, const void *fd_set, int unlimited_select) 35 + { 36 + if (n < 0) { 37 + os_fault_with_payload(OS_REASON_LIBSYSTEM, OS_REASON_LIBSYSTEM_CODE_FAULT, 38 + &n, sizeof(n), "FD_SET underflow", 0); 39 + return 0; 40 + } 41 + 42 + if (n >= __DARWIN_FD_SETSIZE) { 43 + if (pthread_current_stack_contains_np((const void *) fd_set, sizeof(struct fd_set))) { 44 + if (!unlimited_select) { 45 + os_fault_with_payload(OS_REASON_LIBSYSTEM, OS_REASON_LIBSYSTEM_CODE_FAULT, 46 + &n, sizeof(n), "FD_SET overflow", 0); 47 + return 0; 48 + } else { 49 + return 1; 50 + } 51 + } else { 52 + return 1; 53 + } 54 + } 55 + 56 + return 1; 57 + } 28 58 29 59 /* System call entry points */ 30 60 int __terminate_with_payload(int pid, uint32_t reason_namespace, uint64_t reason_code,
+2
src/libsystem/init.c
··· 188 188 // V2 functions (removed) 189 189 // V3 functions 190 190 .pthread_clear_qos_tsd = _pthread_clear_qos_tsd, 191 + // V4 functions 192 + .pthread_current_stack_contains_np = pthread_current_stack_contains_np, 191 193 #ifdef DARLING 192 194 .dyld_func_lookup = _dyld_func_lookup, 193 195 #endif