summary refs log tree commit diff stats
path: root/linux-user/fd-trans.h
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2022-12-05 12:38:25 +0100
committerLaurent Vivier <laurent@vivier.eu>2023-03-10 20:41:30 +0100
commit258bec39f3e58fcdb006028e5c5a1801136ef04a (patch)
tree9e7c2243752bd484a30868dacb22c5cebb892f4c /linux-user/fd-trans.h
parent817fd33836e73812df2f1907612b57750fcb9491 (diff)
downloadfocaccia-qemu-258bec39f3e58fcdb006028e5c5a1801136ef04a.tar.gz
focaccia-qemu-258bec39f3e58fcdb006028e5c5a1801136ef04a.zip
linux-user: Fix access to /proc/self/exe
When accsssing /proc/self/exe from a userspace program, linux-user tries
to resolve the name via realpath(), which may fail if the process
changed the working directory in the meantime.

An example:
- a userspace program ist started with ./testprogram
- the program runs chdir("/tmp")
- then the program calls readlink("/proc/self/exe")
- linux-user tries to run realpath("./testprogram") which fails
  because ./testprogram isn't in /tmp
- readlink() will return -ENOENT back to the program

Avoid this issue by resolving the full path name of the started process
at startup of linux-user and store it in real_exec_path[]. This then
simplifies the emulation of readlink() and readlinkat() as well, because
they can simply copy the path string to userspace.

I noticed this bug because the testsuite of the debian package "pandoc"
failed on linux-user while it succeeded on real hardware.  The full log
is here:
https://buildd.debian.org/status/fetch.php?pkg=pandoc&arch=hppa&ver=2.17.1.1-1.1%2Bb1&stamp=1670153210&raw=0

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221205113825.20615-1-deller@gmx.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/fd-trans.h')
0 files changed, 0 insertions, 0 deletions