From 570be395dcde3f3b276ebfeb106f5fbf0818b829 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 1 May 2020 18:18:21 +0000 Subject: [PATCH] system_cmds-854.100.3.tar.gz --- iosim.tproj/iosim.c | 27 ++++++++++++++++++++++--- login.tproj/login.entitlements | 10 +++++++++ lsmp.tproj/common.h | 9 +++++++-- lsmp.tproj/port_details.c | 29 ++++++++++++++++++++++++--- passwd.tproj/passwd.entitlements | 2 ++ system_cmds.xcodeproj/project.pbxproj | 4 ++++ 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 login.tproj/login.entitlements diff --git a/iosim.tproj/iosim.c b/iosim.tproj/iosim.c index 3fde5d1..cc37ad0 100644 --- a/iosim.tproj/iosim.c +++ b/iosim.tproj/iosim.c @@ -17,6 +17,7 @@ #include #include "panic.h" #include +#include #define IO_MODE_SEQ 0 #define IO_MODE_RANDOM 1 @@ -92,6 +93,7 @@ void print_test_setup(int value, char *option, char *units, char *comment); void setup_process_io_policy(int io_tier); void setup_qos_device(void); void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size, double io_count); +int system_cmd(char *command); void print_usage(void) @@ -254,7 +256,7 @@ void assertASP(CFRunLoopTimerRef timer, void *info ) // Assert ASP printf("Command : %s\n", command); - system(command); + system_cmd(command); // Panic the system as well panic("IO time > QoS timeout"); @@ -583,12 +585,12 @@ int main(int argc, char *argv[]) snprintf(fname, MAX_FILENAME, "iosim-%d-%d", (int)getpid(), i); snprintf(dd_command, MAX_CMD_SIZE, "dd if=/dev/urandom of=%s bs=4096 count=%d", fname, file_size); printf("Creating file %s of size %lld...\n", fname, ((int64_t)file_size * 4096)); - system(dd_command); + system_cmd(dd_command); } } else { printf("Using user specified file %s for all threads...\n", user_fname); } - system("purge"); + system_cmd("purge"); setup_process_io_policy(io_tier); setup_qos_device(); @@ -637,3 +639,22 @@ int main(int argc, char *argv[]) pthread_exit(0); } + +extern char **environ; + +int system_cmd(char *command) +{ + // workaround for rdar://problem/53281655 + pid_t pid; + char *argv[] = {"sh", "-c", command, NULL}; + int status; + status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ); + if (status == 0) { + if (waitpid(pid, &status, 0) != -1) { + return status; + } else { + perror("waitpid"); + } + } + return -1; +} diff --git a/login.tproj/login.entitlements b/login.tproj/login.entitlements new file mode 100644 index 0000000..6e47a16 --- /dev/null +++ b/login.tproj/login.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.private.opendirectoryd.identity + + com.apple.private.security.clear-library-validation + + + diff --git a/lsmp.tproj/common.h b/lsmp.tproj/common.h index 35014c1..8ab5eab 100644 --- a/lsmp.tproj/common.h +++ b/lsmp.tproj/common.h @@ -123,7 +123,7 @@ typedef struct my_per_task_info { #define IKOT_LOCK_SET 24 #define IKOT_CLOCK 25 #define IKOT_CLOCK_CTRL 26 -#define IKOT_IOKIT_SPARE 27 +#define IKOT_IOKIT_IDENT 27 #define IKOT_NAMED_ENTRY 28 #define IKOT_IOKIT_CONNECT 29 #define IKOT_IOKIT_OBJECT 30 @@ -135,7 +135,12 @@ typedef struct my_per_task_info { #define IKOT_TASK_RESUME 36 #define IKOT_VOUCHER 37 #define IKOT_VOUCHER_ATTR_CONTROL 38 -#define IKOT_UNKNOWN 39 /* magic catchall */ +#define IKOT_WORK_INTERVAL 39 +#define IKOT_UX_HANDLER 40 +#define IKOT_UEXT_OBJECT 41 +#define IKOT_ARCADE_REG 42 + +#define IKOT_UNKNOWN 43 /* magic catchall */ #define IKOT_MAX_TYPE (IKOT_UNKNOWN+1) /* # of IKOT_ types */ diff --git a/lsmp.tproj/port_details.c b/lsmp.tproj/port_details.c index 619bf02..de85246 100644 --- a/lsmp.tproj/port_details.c +++ b/lsmp.tproj/port_details.c @@ -26,6 +26,7 @@ #include #include #include +//#include #include #include "common.h" #include "json.h" @@ -60,7 +61,7 @@ const char * kobject_name(natural_t kotype) case IKOT_LOCK_SET: return "LOCK-SET"; case IKOT_CLOCK: return "CLOCK"; case IKOT_CLOCK_CTRL: return "CLOCK-CONTROL"; - case IKOT_IOKIT_SPARE: return "IOKIT-SPARE"; + case IKOT_IOKIT_IDENT: return "IOKIT-IDENT"; case IKOT_NAMED_ENTRY: return "NAMED-MEMORY"; case IKOT_IOKIT_CONNECT: return "IOKIT-CONNECT"; case IKOT_IOKIT_OBJECT: return "IOKIT-OBJECT"; @@ -72,6 +73,10 @@ const char * kobject_name(natural_t kotype) case IKOT_TASK_RESUME: return "TASK_RESUME"; case IKOT_VOUCHER: return "VOUCHER"; case IKOT_VOUCHER_ATTR_CONTROL: return "VOUCHER_ATTR_CONTROL"; + case IKOT_WORK_INTERVAL: return "WORK_INTERVAL"; + case IKOT_UX_HANDLER: return "UX_HANDLER"; + case IKOT_UEXT_OBJECT: return "UEXT_OBJECT"; + case IKOT_ARCADE_REG: return "ARCADE_REG"; case IKOT_UNKNOWN: default: return "UNKNOWN"; } @@ -307,6 +312,8 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta int sendrights = 0; unsigned int kotype = 0; vm_offset_t kobject = (vm_offset_t)0; + kobject_description_t desc; + mach_vm_address_t kaddr; /* skip empty slots in the table */ if ((entry->iin_type & MACH_PORT_TYPE_ALL_RIGHTS) == 0) { @@ -598,13 +605,29 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta (send) ? sendrights : 0); /* converting to kobjects is not always supported */ - ret = mach_port_kernel_object(taskinfo->task, + + desc[0] = '\0'; + ret = mach_port_kobject_description(taskinfo->task, + entry->iin_name, + &kotype, &kaddr, + desc); + if (KERN_SUCCESS == ret) { + kobject = (unsigned) kaddr; + } else { + ret = mach_port_kernel_object(taskinfo->task, entry->iin_name, &kotype, (unsigned *)&kobject); + } + if (ret == KERN_SUCCESS && kotype != 0) { JSON_OBJECT_SET(json, identifier, "0x%08x", (natural_t)kobject); JSON_OBJECT_SET(json, type, "%s", kobject_name(kotype)); - printf(" 0x%08x %s", (natural_t)kobject, kobject_name(kotype)); + if (desc[0]) { + JSON_OBJECT_SET(json, description, "%s", desc); + printf(" 0x%08x %s %s", (natural_t)kobject, kobject_name(kotype), desc); + } else { + printf(" 0x%08x %s", (natural_t)kobject, kobject_name(kotype)); + } if ((kotype == IKOT_TASK_RESUME) || (kotype == IKOT_TASK) || (kotype == IKOT_TASK_NAME)) { if (taskinfo->task_kobject == kobject) { /* neat little optimization since in most cases tasks have themselves in their ipc space */ diff --git a/passwd.tproj/passwd.entitlements b/passwd.tproj/passwd.entitlements index 71bd7ea..6e47a16 100644 --- a/passwd.tproj/passwd.entitlements +++ b/passwd.tproj/passwd.entitlements @@ -4,5 +4,7 @@ com.apple.private.opendirectoryd.identity + com.apple.private.security.clear-library-validation + diff --git a/system_cmds.xcodeproj/project.pbxproj b/system_cmds.xcodeproj/project.pbxproj index f52edfb..400fcee 100644 --- a/system_cmds.xcodeproj/project.pbxproj +++ b/system_cmds.xcodeproj/project.pbxproj @@ -2370,6 +2370,7 @@ 3521C8562245AB52001B3201 /* cpuctl.tproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = cpuctl.tproj; sourceTree = ""; }; 358407CD2245AC09006A0D8E /* cpuctl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = cpuctl.c; path = cpuctl.tproj/cpuctl.c; sourceTree = ""; }; 358407CF2245AC32006A0D8E /* cpuctl.8 */ = {isa = PBXFileReference; lastKnownFileType = text; name = cpuctl.8; path = cpuctl.tproj/cpuctl.8; sourceTree = ""; }; + 43A96C7223D2DAAE0033235B /* login.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = login.entitlements; sourceTree = ""; }; 550C19E01804C55E001DA380 /* iosim.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = iosim.1; sourceTree = ""; }; 550C19E11804C55E001DA380 /* iosim.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iosim.c; sourceTree = ""; }; 550C19EB1804D226001DA380 /* iosim */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = iosim; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -3504,6 +3505,7 @@ BA4FD2591372FAFA0025925C /* login.tproj */ = { isa = PBXGroup; children = ( + 43A96C7223D2DAAE0033235B /* login.entitlements */, BA4FD25B1372FAFA0025925C /* klogin.c */, BA4FD25C1372FAFA0025925C /* login.1 */, BA4FD25D1372FAFA0025925C /* login.c */, @@ -7249,6 +7251,7 @@ 18732FFB18CBD4A700275344 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = login.tproj/login.entitlements; "GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*][arch=*]" = ( "$(inherited)", USE_PAM, @@ -7905,6 +7908,7 @@ BA473DB21377B2230005CC19 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = login.tproj/login.entitlements; "GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*][arch=*]" = ( "$(inherited)", USE_PAM, -- 2.45.2