-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Problem - allocated 256MB of memory for the payload,
Location: patch_kernel()
Current code:
const max_size = 0x10000000; // 256MB - WAY too big
Bad Code Section:
const max_size = 0x10000000;
if (map_size > max_size) {
die(`patch file too large (>${max_size}): ${map_size}`);
}
if (map_size === 0) {
die('patch file size is zero');
}
map_size = map_size+page_size & -page_size;
Fix: Calculate exact size needed instead of fixed 256MB
let map_size = patches.size;
const max_size = 0x200000; // 2MB max (adjust if your payload is larger)
if (map_size > max_size) {
die(`patch file too large (>${max_size}): ${map_size}`);
}
if (map_size === 0) {
die("patch file size is zero");
}
log(`kpatch size: ${map_size} bytes`);
// Round up to page size
map_size = (map_size + page_size - 1) & ~(page_size - 1);
// Ensure minimum viable size for shellcode
if (map_size < 0x1000) map_size = 0x1000;
Result - reduced out of memory issues.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels