chroot segmentation fault
Opened this issue · 2 comments
Deleted user commented
Problem description
Getting "segmentation fault" when trying to chroot into alpine rootfs.
$ tsu
# cd /data/alpine
# which chroot
/data/data/com.termux/files/usr/bin/chroot
# chroot . /bin/su
Segmentation fault
System binary works fine:
# /system/bin/chroot . /bin/su
/ #
Steps to reproduce
Just do chroot /path/to/fs /bin/sh
. I used Alpine Linux rootfs.
It also easily crashes with chroot /
.
Expected behavior
Chroot should execute specified command inside rootfs without any problem.
Additional information
Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/xeffyr/x11-packages-24 x11/main
https://dl.bintray.com/grimler/science-packages-24 science/stable
https://dl.bintray.com/grimler/termux-root-packages-24 root/stable
https://dl.bintray.com/grimler/game-packages-24 games/stable
https://dl.bintray.com/termux/termux-packages-24 stable/main
System information:
Linux localhost 3.18.140-g674a3b7ff94 #1 SMP PREEMPT Sun Jun 9 17:46:45 UTC 2019 aarch64 Android
Termux-packages arch:
aarch64
Android version:
9
Device manufacturer:
samsung
Device model:
SM-G930F
Grimler91 commented
Seems that the canonicalize_filename_mode
returns null on aarch64 (test on arm works).
Commenting out the canonicalization makes it succeed:
--- ../chroot.c.orig 2019-07-08 21:49:48.036241547 +0200
+++ ./src/chroot.c 2019-07-08 21:48:58.030861309 +0200
@@ -170,10 +170,10 @@
static bool
is_root (const char* dir)
{
- char *resolved = canonicalize_file_name (dir);
- bool is_res_root = resolved && STREQ ("/", resolved);
- free (resolved);
- return is_res_root;
+ //char *resolved = canonicalize_file_name (dir);
+ //bool is_res_root = resolved && STREQ ("/", resolved);
+ //free (resolved);
+ return true;
}
void
I'll look into the failing function and see if I can understand the error.
Deleted user commented
Closing since chroot built with coreutils works properly. The separate one should be removed.