- vn_path = (char *)kalloc(MAXPATHLEN);
- if (vn_path != NULL) {
- if (vn_getpath(vp, vn_path, (int*)&vn_pathlen) == 0) {
- path = vn_path;
- } else {
- path = "(get vnode path failed)";
- }
- } else {
- path = "(path alloc failed)";
- }
-
- if (error == 0) {
- panic("mac_vnode_check_signature: MAC hook returned no error, "
- "but status is claimed to be fatal? "
- "path: '%s', fatal_failure_desc_len: %ld, fatal_failure_desc:\n%s\n",
- path, fatal_failure_desc_len, fatal_failure_desc);
- }
-
- printf("mac_vnode_check_signature: %s: code signature validation failed fatally: %s",
- path, fatal_failure_desc);
-
- if (imgp == NULL) {
- goto out;
- }
-
- os_reason_t reason = os_reason_create(OS_REASON_CODESIGNING,
- CODESIGNING_EXIT_REASON_TASKGATED_INVALID_SIG);
-
- if (reason == OS_REASON_NULL) {
- printf("mac_vnode_check_signature: %s: failure to allocate exit reason for validation failure: %s\n",
- path, fatal_failure_desc);
- goto out;
- }
-
- imgp->ip_cs_error = reason;
- reason->osr_flags = (OS_REASON_FLAG_GENERATE_CRASH_REPORT |
- OS_REASON_FLAG_CONSISTENT_FAILURE);
-
- if (fatal_failure_desc == NULL) {
- // This may happen if allocation for the buffer failed.
- printf("mac_vnode_check_signature: %s: fatal failure is missing its description.\n", path);
- } else {
- mach_vm_address_t data_addr = 0;
-
- int reason_error = 0;
- int kcdata_error = 0;
-
- if ((reason_error = os_reason_alloc_buffer(reason, kcdata_estimate_required_buffer_size
- (1, fatal_failure_desc_len))) == 0 &&
- (kcdata_error = kcdata_get_memory_addr(&reason->osr_kcd_descriptor,
- EXIT_REASON_USER_DESC, fatal_failure_desc_len,
- &data_addr)) == KERN_SUCCESS) {
- kern_return_t mc_error = kcdata_memcpy(&reason->osr_kcd_descriptor, (mach_vm_address_t)data_addr,
- fatal_failure_desc, fatal_failure_desc_len);
-
- if (mc_error != KERN_SUCCESS) {
- printf("mac_vnode_check_signature: %s: failed to copy reason string "
- "(kcdata_memcpy error: %d, length: %ld)\n",
- path, mc_error, fatal_failure_desc_len);
- }
- } else {
- printf("mac_vnode_check_signature: %s: failed to allocate space for reason string "
- "(os_reason_alloc_buffer error: %d, kcdata error: %d, length: %ld)\n",
- path, reason_error, kcdata_error, fatal_failure_desc_len);
- }
+ vn_path = zalloc(ZV_NAMEI);
+ if (vn_getpath(vp, vn_path, (int*)&vn_pathlen) == 0) {
+ path = vn_path;
+ } else {
+ path = "(get vnode path failed)";
+ }
+
+ if (error == 0) {
+ panic("mac_vnode_check_signature: MAC hook returned no error, "
+ "but status is claimed to be fatal? "
+ "path: '%s', fatal_failure_desc_len: %ld, fatal_failure_desc:\n%s\n",
+ path, fatal_failure_desc_len, fatal_failure_desc);
+ }
+
+ printf("mac_vnode_check_signature: %s: code signature validation failed fatally: %s",
+ path, fatal_failure_desc);
+
+ if (imgp == NULL) {
+ goto out;
+ }
+
+ os_reason_t reason = os_reason_create(OS_REASON_CODESIGNING,
+ CODESIGNING_EXIT_REASON_TASKGATED_INVALID_SIG);
+
+ if (reason == OS_REASON_NULL) {
+ printf("mac_vnode_check_signature: %s: failure to allocate exit reason for validation failure: %s\n",
+ path, fatal_failure_desc);
+ goto out;
+ }