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

bootloader: implement full back-to-front scan for embedded archive #5511

Merged
merged 1 commit into from Feb 27, 2021

Conversation

rokm
Copy link
Member

@rokm rokm commented Jan 28, 2021

Implement full back-to-front file scan for finding the embedded archive's cookie. This saves us from having to make assumptions
about the cookie's positon, which both simplifies the search and makes it more robust.

Currently, we are searching within fixed-sized search window either from the end of file or from end of file's digital signature (if
present; on Windows and macOS only).

This breaks when a 3rd party tool appends extra data at the end of executable; for example, with PIE bootloader executable,
staticx tool on linux will append extra sections at the end of file, which is perfectly valid behavior, but it breaks our fixed-size
search window assumptions. Therefore, full back-to-front search fixes #5330 and JonathonReinhart/staticx#71.

Another motivation for brute-force search is macOS 11, as we will sooner or later want to support universal2 fat binary bootloaders in addition to single-arch thin ones. Full-file search allows us to do so without having to search for digital signature and in turn parsing the headers of each binary format.

@rokm
Copy link
Member Author

rokm commented Jan 28, 2021

Depends on cleanup from #5457.

@rokm rokm added the area:bootloader Caused be or effecting the bootloader label Jan 28, 2021
@rokm rokm force-pushed the bootloader-cookie-search branch 2 times, most recently from c464076 to b387868 Compare February 13, 2021 10:38
@rokm rokm marked this pull request as ready for review February 14, 2021 10:51
…okie

Implement full back-to-front file scan for finding the embedded
archive's cookie. This saves us from having to make assumptions
about the cookie's positon, which both simplifies the search and
makes it more robust.

Currently, we are searching within fixed-sized search window either
from the end of file or from end of file's digital signature (if
present; on Windows and macOS only).

This breaks when a 3rd party tool appends extra data at the end
of executable; for example, with PIE bootloader executable,
staticx tool on linux will append extra sections at the end of file,
which is perfectly valid behavior, but it breaks our fixed-size
search window assumptions. Therefore, full back-to-front search
fixes pyinstaller#5330.

Another motivation for brute-force search is macOS 11, as we will
sooner or later want to support universal2 fat binary bootloaders
in addition to single-arch thin ones. Full-file search allows
us to do so without having to search for digital signature and
in turn parsing the headers of each binary format.
Copy link
Member

@Legorooj Legorooj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this.

@pvanderlinden
Copy link

@Legorooj Any chance this is going to be released soonish?

@Legorooj
Copy link
Member

Legorooj commented Apr 3, 2021

@pvanderlinden maybe? I can't give you a date as I don't have release credentials myself. Currently talking to someone who does so I can obtain them.

@pvanderlinden
Copy link

Thanks @Legorooj . Just asking because I didn't see a release for months and this issue is blocking a contribution to a different project

@rokm rokm deleted the bootloader-cookie-search branch May 5, 2021 09:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:bootloader Caused be or effecting the bootloader
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyinstaller 4.1 executables have incorrect references to non-extant archives
4 participants