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

feat: add libz.so.1 to whitelisted libraries #334

Merged
merged 4 commits into from
Sep 15, 2021
Merged

Conversation

mayeut
Copy link
Member

@mayeut mayeut commented Aug 29, 2021

This also requires to blacklist some symbols from libz.so.1.
There was some breakage in ABI compatibility for this library.
It's seems unlikely that those symbols are used in the wild.

Fix #152
Fix #161

@mayeut mayeut requested a review from lkollar August 29, 2021 18:18
@mayeut mayeut mentioned this pull request Aug 29, 2021
@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #334 (8a03a19) into master (b2d597c) will increase coverage by 0.18%.
The diff coverage is 93.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   89.35%   89.54%   +0.18%     
==========================================
  Files          23       23              
  Lines        1203     1244      +41     
  Branches      255      270      +15     
==========================================
+ Hits         1075     1114      +39     
- Misses         78       79       +1     
- Partials       50       51       +1     
Impacted Files Coverage Δ
auditwheel/wheel_abi.py 96.99% <75.00%> (-1.43%) ⬇️
auditwheel/elfutils.py 94.05% <95.23%> (+0.23%) ⬆️
auditwheel/main_repair.py 90.47% <100.00%> (+0.47%) ⬆️
auditwheel/main_show.py 75.86% <100.00%> (+5.27%) ⬆️
auditwheel/policy/external_references.py 97.82% <100.00%> (+0.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2d597c...8a03a19. Read the comment docs.

This also requires to blacklist some symbols from `libz.so.1`.
There was some breakage in ABI compatibility for this library.
It's seems unlikely that those symbols are used in the wild.
Copy link
Contributor

@lkollar lkollar left a comment

Choose a reason for hiding this comment

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

Where is the list of blacklisted symbols coming from? This is something we should definitely document to make sure we can keep the list up to date.

Comment on lines +150 to +155
section = elf.get_section_by_name(".dynsym")
if section is not None:
# look for all undef symbols
for sym in section.iter_symbols():
if sym["st_shndx"] == "SHN_UNDEF":
undef_symbols.add(sym.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This could be made into a utility function to find undefined symbols. That would make this function more readable as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

will do.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

auditwheel/elfutils.py Outdated Show resolved Hide resolved
@@ -285,12 +293,19 @@ def analyze_wheel_abi(wheel_fn: str) -> WheelAbIInfo:
sym_tag,
ucs_tag,
pyfpe_tag,
blacklist_tag,
)


def update(d, u):
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but we should refactor this function.

@mayeut
Copy link
Member Author

mayeut commented Sep 9, 2021

Where is the list of blacklisted symbols coming from? This is something we should definitely document to make sure we can keep the list up to date.

Everything comes from mayeut/pep600_compliance#88 (The same repo was used to define policies for manylinux_2_24 & manylinux_2_27).
I crossed referenced this information with https://abi-laboratory.pro/index.php?view=timeline&l=zlib as well.

@vgod-dbx
Copy link

vgod-dbx commented Mar 8, 2022

Hi,

According to the manylinux policies, libz.so.1 should not be whitelisted. Can we revert this change or at least make it as an opt-in argument so all libraries that use auditwheel can still comply with the manylinux policies by default?

A bit more context on why this is causing problems. Our company runs a minimal Linux runtime to ensure the portability of our code across Linux versions/distros. We have been replying on the manylinux policies to ensure that all pip libraries run on our runtime without missing dependencies. However, this change introduced an external dependency on libz.so.1 (which does not exist in our runtime) into some libraries (huggingface/tokenizers#946, for one example) and prevented us to upgrade to newer versions.

@mayeut
Copy link
Member Author

mayeut commented Mar 12, 2022

@vgod-dbx,

According to the manylinux policies, libz.so.1 should not be whitelisted.

You're probably talking about the previous PEP 513, PEP 571 & PEP 599. Those 3 PEP have been superseded by the much more generic PEP 600 which does not list allowed / disallowed libraries & which states:

manylinux_${GLIBCMAJOR}_${GLIBCMINOR}_${ARCH}
This tag is a promise: the wheel’s creator promises that the wheel will work on any mainstream Linux distro that uses glibc version ${GLIBCMAJOR}.${GLIBCMINOR} or later, and where the ${ARCH} matches the return value from distutils.util.get_platform(). (For more detail about architecture tags, see PEP 425.)

libz.so.1 is available on all mainstream Linux distros & not whitelisting it caused some issues (ranging from "not working" to "security issue" on unmaintained grafted library).
libz.so.1 is also part of the LSB Core specification which more or less means it should also be available on all Linux distros (i.e. not just the mainstream ones).

CPython itself relies on zlib for multiple modules (although, if you're using CPython and linking zlib statically, it does not depend on libz.so.1).

Your company should probably update its minimal runtime package with libz.so.1.

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