summary refs log tree commit diff stats
path: root/results/classifier/118/files/2825
blob: 7c0ad1535866e8a3d29cf16c3f35117bd6ae966f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
architecture: 0.974
x86: 0.968
files: 0.949
device: 0.945
performance: 0.929
graphic: 0.889
permissions: 0.887
kernel: 0.876
i386: 0.872
user-level: 0.866
assembly: 0.847
PID: 0.835
arm: 0.771
register: 0.764
TCG: 0.756
semantic: 0.746
network: 0.742
debug: 0.740
ppc: 0.732
hypervisor: 0.730
peripherals: 0.722
risc-v: 0.722
mistranslation: 0.705
VMM: 0.703
socket: 0.696
vnc: 0.668
boot: 0.659
KVM: 0.483
virtual: 0.278

execveat with file descriptor and empty filename returns ENOENT when cross architectures
Description of problem:
On my x86_64 debian host (with binfmt_misc configured), when calling execveat with a fd , and empty pathname "", and flag AT_EMPTY_PATH. Then only x86_64 and x86 can be called normally, while programs of other architectures (arm64, arm, riscv64, etc.) will return ENOENT errors.

I first encountered this problem when trying to run lxc-attach with qemu-aarch64. Its reference is [lxc/stable-6.0/src/include/fexecve.c#L30](https://github.com/lxc/lxc/blob/stable-6.0/src/include/fexecve.c#L30), which is the implementation of the fexecve function. So I wrote a simple test and compiled it with `x86_64/aarch64-linux-gnu-gcc -static test.c -o test`. execveat works fine when running natively or using qemu-x86_64/qemu-i386. When running versions for other architectures, using AT_EMPTY_PATH will result in ENOENT (No such file or directory); use /proc/self/fd/%d as the pathname and execve, it will work fine (like the rest part of the fexecve function). If binfmt_misc is turned off and run forign architectures ver, both calls will result in ENOEXEC (Exec format error).
Steps to reproduce:
1. Install qemu-user and binfmt_misc. Install gcc-aarch64-linux-gnu/gcc-riscv64-linux-gnu etc.
2. Compile test.c with host gcc, then compile forign architectures ver with gcc-aarch64-linux-gnu/gcc-riscv64-linux-gnu etc. like `gcc -static test.c -o test` and `aarch64-linux-gnu-gcc -static test.c -o test-aarch64`
3. Run different versions of test
4. To disable/enable binfmt, you can `echo 0 > /proc/sys/fs/binfmt_misc/qemu-aarch64` or `echo 1 > /proc/sys/fs/binfmt_misc/qemu-aarch64`
5. Sample outputs

```
rrex@debian:~/Downloads$ ./test
****Running to prepare execve
fd=3
File size: 772296 bytes

execveat with AT_EMPTY_PATH:
**Running in execve

execveat with fd path: /proc/self/fd/3
**Running in execve

rrex@debian:~/Downloads$ qemu-aarch64 ./test-aarch64 
****Running to prepare execve
fd=3
File size: 706104 bytes

execveat with AT_EMPTY_PATH:
!!execveat a fd failed with errno: No such file or directory

execveat with fd path: /proc/self/fd/3
**Running in execve
```
Additional information:
#