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

BrokenPipeError: [Errno 32] Broken pipe #3

Open
Kojuda opened this issue Jul 12, 2021 · 8 comments
Open

BrokenPipeError: [Errno 32] Broken pipe #3

Kojuda opened this issue Jul 12, 2021 · 8 comments

Comments

@Kojuda
Copy link

Kojuda commented Jul 12, 2021

Hello,

I have tried your program on Ubuntu 20.04 with Python 3.9.5 then 3.7.5. There is a broken pipe error that pops out when the ramdisk is unpacking to tmp.

image

Have you any idea to circumvent the problem ? (Already tried to add signal(SIGPIPE, SIG_DFL) but as you may know, this doesn't really fix the error)

EDIT : boot.img frop Fairphone 3, Android 10, A/B device.

@Kojuda
Copy link
Author

Kojuda commented Jul 12, 2021

(Forgotten vbmeta.img in the previous post)

image

@Kojuda
Copy link
Author

Kojuda commented Jul 13, 2021

It seems the Windows version hasn't the pipe problem, but cannot read a file that must be created by the script :

image

@bkerler
Copy link
Owner

bkerler commented Jul 13, 2021

Can you share the boot.img ? Might have a look then

@Kojuda
Copy link
Author

Kojuda commented Jul 13, 2021

images.zip

Thank you !

If the problem really originates from unpacking initfs, the broken pipe might be linked since it's exactly at the same place ( p.stdin.write(rdcpio) ) :
image

@Kojuda
Copy link
Author

Kojuda commented Jul 16, 2021

Maybe it's because the Android phone is A/B device. (Fairphone 3)

Inside makeramdisk.py :

The script is writing hdrsize if the header version is superior than 0 :
image

But this variable is read from the image only if a header version of 2 is detected :
image

According to the bootimg.h, hdrsize is part of header version 1 too : (https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/master/include/bootimg/bootimg.h)

image

I should signal another thing, the init file is extracted from rd.gz as init@0755 under /system/bin and not under / as init@0750 :

image

@Kojuda
Copy link
Author

Kojuda commented Jul 16, 2021

I have managed to modifiy the program in order to complete the process.

First, according to bootimg.h, I have modified this part of makeramdisk.py :

image

I have changed the path to the folder /keys. The program was searching it under android_universal\root\scripts\Library\utils\keys (that doesn't exist) while this folder already existed under /root/keys

image

I have set up the arg use_persistent_digest to True for the function add_hash_footer (avbtool3.py) :
2021-07-16 17_53_25-Window

and convert the salt :
image

Because this one was created from reading /dev/urandom that doesn't exist on Windows.

So now the program terminates and creates a boot.img.signed. But when I flash it, I cannot retrieve any thing linked to the patch. (None of the .sh's are under /sbin, init.rc doesn't have the "on eary-init" that will import init.shell.rc... etc through TWRP) So nothing seems to work, any idea ?
Note : I failed to correct the error concerning init @0750.

@Kojuda
Copy link
Author

Kojuda commented Jul 17, 2021

image

I presume the difference between the two mods (0750 vs 0755) is normal. I will adapt the script to patch this init@0755 because it seems the A/B devices have normally their init under /system/bin :
image

Modification :

image

Now the patching is working, but once patched, I don't have any open ports for netcat. If I browse through the filesystem with TWRP, I cannot find any traces of the modification.

@Kojuda
Copy link
Author

Kojuda commented Jul 19, 2021

In fact, it seems the kernel doesn't load the ramdisk at all. (I have tried boot_a and boot_b)

image

I think it is linked to the boot method in some ways since the init is clearly under /system/bin but the device was not originally under Android 10. What would explain this behavior ? @bkerler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants