termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
774 stars 160 forks source link

`WARNING: linker: Warning: failed to find generated linker configuration from "/linkerconfig/ld.config.txt"` on Android 12+ #254

Closed TheBrokenRail closed 1 year ago

TheBrokenRail commented 1 year ago

Problem description When starting anything with PRoot, the linker gives the warning:

WARNING: linker: Warning: failed to find generated linker configuration from "/linkerconfig/ld.config.txt"

Here's running it with debug logging.

Steps to reproduce

  1. Use a device with Android 12+
  2. Run proot true

Expected behavior No warning appears.

Additional information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main/ stable main
Updatable packages:
All packages up to date
termux-tools version:
1.36.1
Android version:
13
Kernel build information:
Linux localhost 5.4.147-qgki-25323472-abG991USQS5DVL1 #1 SMP PREEMPT Mon Dec 5 18:27:06 KST 2022 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-G991U

The error is also referenced here.

After some investigation, it appears to orrignate from here. It seems to be trying to check whether /linkerconfig is a directory, but lstat fails with EACCES.

I created a patch to temporaily workaround this, but a proper solution would probably be preferable:

--- proot/src/path/canon.c
+++ proot/src/path/canon.c
@@ -155,6 +155,9 @@ static inline int substitute_binding_stat(Tracee *tracee, Finality finality, uns
    statl.st_mode = 0;
    if (should_skip_file_access_due_to_f2fs_bug(tracee, host_path)) {
        status = -ENOENT;
+   } else if (strcmp(host_path, "/linkerconfig") == 0) {
+       status = 0;
+       statl.st_mode = S_IFDIR;
    } else {
        status = lstat(host_path, &statl);
    }
michalbednarski commented 1 year ago

Thanks for figuring out issue and providing patch

Integrated in 0fdcda1d302dd05c175f250f2dd06c90c4e255cb with difference to always perform lstat() and only use hardcoded value if access was denied

I guess there's no better way of handling that

michalbednarski commented 1 year ago

Updated version is now available in Termux apt repo

Thanks for finding the issue and providing fix