From 94c61bbd8ad3d5aa3ac641f7aff4b3fb3bcd221c Mon Sep 17 00:00:00 2001 From: Ignacio <62676603+ignaciojuarez@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:52:58 -0700 Subject: [PATCH] fix: write full addresses when preparing JIT pages makeBlessCommands wrote 9 hex digits per page address, so a region above 0xFFFFFFFFF (64 GB) lost its top digit. Apps with extended virtual addressing can get JIT regions there; the wrong pages were prepared and the first JIT instruction failed with KERN_CODESIGN_ERROR. Write all 16 digits (command length 19 -> 26). Co-Authored-By: Claude Opus 5.5 --- Sources/ScriptRunner.swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Sources/ScriptRunner.swift b/Sources/ScriptRunner.swift index e01b8e5c6e..4982124e5e 100644 --- a/Sources/ScriptRunner.swift +++ b/Sources/ScriptRunner.swift @@ -5,7 +5,7 @@ import JavaScriptCore final class ScriptRunner { private static let jitPageSize: UInt64 = 16384 - private static let jitPageCommandLength = 19 + private static let jitPageCommandLength = 26 private static let commandsPerBatch = 128 private let targetPID: Int32 @@ -124,21 +124,22 @@ final class ScriptRunner { buffer[start + 0] = UInt8(ascii: "$") buffer[start + 1] = UInt8(ascii: "M") writeHexAddress(pageAddress, into: &buffer, at: start + 2) - buffer[start + 11] = UInt8(ascii: ",") - buffer[start + 12] = UInt8(ascii: "1") - buffer[start + 13] = UInt8(ascii: ":") - buffer[start + 14] = UInt8(ascii: "6") - buffer[start + 15] = UInt8(ascii: "9") - buffer[start + 16] = UInt8(ascii: "#") - writeChecksum(into: &buffer, bodyStart: start + 1, hashIndex: start + 16) + buffer[start + 18] = UInt8(ascii: ",") + buffer[start + 19] = UInt8(ascii: "1") + buffer[start + 20] = UInt8(ascii: ":") + buffer[start + 21] = UInt8(ascii: "6") + buffer[start + 22] = UInt8(ascii: "9") + buffer[start + 23] = UInt8(ascii: "#") + writeChecksum(into: &buffer, bodyStart: start + 1, hashIndex: start + 23) } return buffer } + // All 16 digits: with extended virtual addressing, JIT regions can sit above 64 GB (0xFFFFFFFFF). private static func writeHexAddress(_ address: UInt64, into buffer: inout [UInt8], at index: Int) { - for nibble in 0..<9 { - let shift = UInt64((8 - nibble) * 4) + for nibble in 0..<16 { + let shift = UInt64((15 - nibble) * 4) buffer[index + nibble] = hexDigit(UInt8((address >> shift) & 0xf)) } }