Skip to content

Commit 00678b0

Browse files
committed
fix: hooked_mmap should revalidate memory prot
Fix libnetty not loading with correct memory protections causing 1.21.11 to crash when querying server info. (iOS 18.x and below)
1 parent ed267f5 commit 00678b0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Natives/dyld_bypass_validation.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ bool searchAndPatch(char *name, char *base, char *signature, int length, void *t
159159
}
160160

161161
void *map = __mmap(addr, len, prot, flags, fd, offset);
162+
// Handle some cases where it will still map but without executable permission
163+
if (mprotect(map, len, prot) == -1) {
164+
munmap(map, len);
165+
map = MAP_FAILED;
166+
}
162167
if (map == MAP_FAILED && fd && (prot & PROT_EXEC)) {
163-
printf("[DyldLVBypass] mmap(prot=%d, flags=%d, fd=%d)\n", prot, flags, fd);
168+
//printf("[DyldLVBypass] mmap(prot=%d, flags=%d, fd=%d)\n", prot, flags, fd);
164169
map = __mmap(addr, len, prot, flags | MAP_PRIVATE | MAP_ANON, 0, 0);
165170
if (DeviceHasJITFlags(JIT_FLAG_FORCE_MIRRORED | JIT_FLAG_HAS_TXM)) {
166171
JIT26PrepareRegion(map, len);

0 commit comments

Comments
 (0)