Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't read payload data into memory #21

Open
cg-cri-gl opened this issue Jan 3, 2023 · 1 comment
Open

Don't read payload data into memory #21

cg-cri-gl opened this issue Jan 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@cg-cri-gl
Copy link

cg-cri-gl commented Jan 3, 2023

Hi,

can you please take a look into following crash (it's _sigkill_ed according to strace ) of command:
python3 -m pyimg4 im4p create -i work/ramdisk.dmg -o work/ramdisk.im4p -f rdsk
?

The details:

  1. strace message
    ........
    write(1, "Reading work/ramdisk.dmg...\n", 28Reading work/ramdisk.dmg... ) = 28 lseek(3, 0, SEEK_CUR) = 0 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=300000000, ...}, AT_EMPTY_PATH) = 0 mmap(NULL, 300003328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60b7de5000 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 300000001) = 300000000 read(3, "", 1) = 0 openat(AT_FDCWD, "work/ramdisk.im4p", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 4 newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=0, ...}, AT_EMPTY_PATH) = 0 ioctl(4, TCGETS, 0x7fffb69102a0) = -1 ENOTTY (Inappropraiate ioctl for device) lseek(4, 0, SEEK_CUR) = 0 mmap(NULL, 300003328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60a5fca000 mmap(NULL, 300003328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60941af000 +++ killed by SIGKILL +++ Killed

  2. The ramdisk image is crafted from few items (not familiar with this whole process), but obtaining this one seems relevant to me:
    pzb -g 078-34285-078.dmg https://updates.cdn-apple.com/2022SummerFCS/fullrestores/012-41753/03DF14B7-8351-497E-B02E-188251541117/iPhone_4.0_64bit_15.6_19G71_Restore.ipsw; however to get to this point following script was used : (which is itself called by palera1n.sh )

  3. pip list | grep pyimg pyimg4 0.7
    Shout out if more info needed, Thanks !

@m1stadev m1stadev self-assigned this Feb 2, 2023
@m1stadev m1stadev added the bug Something isn't working label Feb 2, 2023
@m1stadev
Copy link
Owner

From what I know about this issue, it's due to Python being killed because of too much memory being used. I'm assuming this is due to the fact that PyIMG4 reads the payload data into memory, and given that the ramdisk is like 100+ mbs, could cause a crash on resource-limited systems. I'll have to update PyIMG4 to not do that.

@m1stadev m1stadev changed the title "pyimg4 im4p create..." failing Don't read payload data into memory Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants