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

Eliminate problematic getxxnam() calls in bootloader #228

Merged
merged 7 commits into from
Aug 7, 2022

Conversation

JonathonReinhart
Copy link
Owner

@JonathonReinhart JonathonReinhart commented Aug 7, 2022

glibc warns us that we shouldn't call functions like getpwnam() from a statically-linked application:

decode.c:(.text+0x88): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

The reason is that it will actually dlopen() the libnss libraries, and then possibly explode.

This PR eliminates the getpwnam/getgrnam calls from libtar, and adds a linker flag to make sure it doesn't happen again.

Note that libtar keeps losing more and more fingers, but that's okay because we don't really need much of its functionality. See also #229 because this is annoying.

Fixes #227.

No need to convert for output purposes, just show it.

This is part of the mission to eliminate th_get_uid()/th_get_gid() which
call the problematic (and for staticx, unnecessary) getpwnam/getgrname.
Also remove the dead code that would fchown(uid,gid).
These remove the last problematic getxxnam() calls in libtar
This turns warnings like this into fatal errors, because as we've seen,
especially with staticx's goals in mind, these are real problems:

    libtar/decode.c:49: warning: Using 'getpwnam' in statically linked
    applications requires at runtime the shared libraries from the glibc
    version used for linking
@JonathonReinhart JonathonReinhart changed the title WIP fix #227 Eliminate problematic getxxnam() calls in bootloader Aug 7, 2022
@JonathonReinhart
Copy link
Owner Author

Confirmed that /proc/$(pidof cat.sx)/maps shows no dynamic libraries.

@JonathonReinhart JonathonReinhart marked this pull request as ready for review August 7, 2022 08:05
@JonathonReinhart JonathonReinhart merged commit 5ac0441 into master Aug 7, 2022
@JonathonReinhart JonathonReinhart deleted the 227-static-glibc-uses-nss branch August 7, 2022 08:06
@JonathonReinhart JonathonReinhart added nss Issues related to GLIBC NSS libtar Issues related to embedded libtar labels Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libtar Issues related to embedded libtar nss Issues related to GLIBC NSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bootloader linked with static glibc can crash due to use of host NSS
1 participant