[FS#909] runas wrapper executes programs using wrong interpreter

LEDE Bugs lede-bugs at lists.infradead.org
Sat Jul 15 20:24:22 PDT 2017


A new Flyspray task has been opened.  Details are below. 

User who did this - Kirill Elagin (kirelagin) 

Attached to Project - LEDE Project
Summary - runas wrapper executes programs using wrong interpreter
Task Type - Bug Report
Category - Base system
Status - Unconfirmed
Assigned To - 
Operating System - All
Severity - Low
Priority - Very Low
Reported Version - Trunk
Due in Version - Undecided
Due Date - Undecided
Details - I happen to run a system having no easily accessible binary interpreter (that is, there is no `/lib64`).

Some time ago a wrapper for binaries [[https://git.lede-project.org/?p=source.git;a=commitdiff;h=72d751cba9cda9ce3ae46d5e6ab962d2f675e970|was introduced]]. The issue with this wrapper is that instead of using bundled `ld-linux-x86-64.so.2`, it executes the program by calling `execve`, which will try to use the system interpreter (and fail, in my case). In other words, all the bundled dynamic loader business is now out of work; the same result could be achieved by executing the binary directly.

This works:
[staging_dir/host]$ ./lib/ld-linux-x86-64.so.2 --library-path ./lib/ ./bin/.uuidgen.bin
fb85483b-e891-4dbd-badb-43361fc954f3

This does not:
[staging_dir/host]$ ./lib/ld-linux-x86-64.so.2 --library-path ./lib/ ./lib/runas ./bin/.uuidgen.bin uuidgen
[staging_dir/host]$ echo $?
255

[staging_dir/host]$ strace ./lib/ld-linux-x86-64.so.2 --library-path ./lib/ ./lib/runas ./bin/.uuidgen.bin uuidgen
execve("./lib/ld-linux-x86-64.so.2", ["./lib/ld-linux-x86-64.so.2", "--library-path", "./lib/", "./lib/runas", "./bin/.uuidgen.bin", "uuidgen"], 0x7ffe055921b8 /* 69 vars */) = 0
brk(NULL)                               = 0x55c6f060e000
open("./lib/runas", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0\240\4@\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=7048, ...}) = 0
getcwd("/home/kirelagin/openwrt/lede-imagebuilder-17.01.2-ar71xx-generic.Linux-x86_64/staging_dir/host", 128) = 95
mmap(0x400000, 4096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x400000
mmap(0x600000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x600000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f157c858000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("./lib/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./lib/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("./lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1738176, ...}) = 0
getcwd("/home/kirelagin/openwrt/lede-imagebuilder-17.01.2-ar71xx-generic.Linux-x86_64/staging_dir/host", 128) = 95
mmap(NULL, 3844640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f157c4ad000
mprotect(0x7f157c64e000, 2097152, PROT_NONE) = 0
mmap(0x7f157c84e000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a1000) = 0x7f157c84e000
mmap(0x7f157c854000, 14880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f157c854000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f157c4ac000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f157c4ab000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f157c4aa000
arch_prctl(ARCH_SET_FS, 0x7f157c4ab700) = 0
mprotect(0x7f157c84e000, 16384, PROT_READ) = 0
mprotect(0x55c6f00e8000, 4096, PROT_READ) = 0
execve("./bin/.uuidgen.bin", ["uuidgen"], 0x7ffd9e14e360 /* 69 vars */) = -1 ENOENT (No such file or directory)
exit_group(-1)                          = ?
+++ exited with 255 +++

More information can be found at the following URL:
https://bugs.lede-project.org/index.php?do=details&task_id=909



More information about the lede-bugs mailing list