qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] util: Fix QEMU_LD_PREFIX endless loop


From: 陳威伯
Subject: Re: [Qemu-devel] [RFC] util: Fix QEMU_LD_PREFIX endless loop
Date: Thu, 7 Jan 2016 00:25:21 +0800

For further explaination of endless loop happen in util/path.c
For example, set the QEMU_LD_PREFIX="/home/apple/i386"
sudo debootstrap --arch=i386 trusty /home/apple/i386 http://archive.ubuntu.com/ubuntu/
magic is a normal dynamic-linkd 32-bit elf.
qemu-i386 -L /home/apple/i386 /home/apple/magic
This command will produce the endless loop.
Because /home/apple/i386/dev/fd will link to /proc/self/fd/
We could use strace to watch the progress
strace qemu-i386 -L /home/apple/i386 /home/apple/magic
openat(AT_FDCWD, "/home/apple/i386/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/3/dev/fd/5/15/usr/share/doc/libp11-kit0/examples", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 48
If one of the QEMU_LD_PREFIX directory entry is symbolic 
link, is_dir_maybe in the add_entry will return true.

# define is_dir_maybe(type) \
    ((type) == DT_DIR || (type) == DT_UNKNOWN || (type) == DT_LNK)
Then add the path name with add_dir_maybe function.
And then add the path name again and again.
Produce the infinite loop in the directory searching.
So the solution is not to deal with the symbolic link in the is_dir_maybe macro 
Modify the code as following:
# define is_dir_maybe(type) \
    ((type) == DT_DIR || (type) == DT_UNKNOWN)


On Wed, Jan 6, 2016 at 11:21 PM, Wei-Bo, Chen <address@hidden> wrote:
Detail bug report in the following url:
https://bugs.launchpad.net/qemu/+bug/1245703

Remove is_dir_maybe macro condition DT_LNK in util/path.c

Signed-off-by: Wei-Bo, Chen <address@hidden>
---
 util/path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/path.c b/util/path.c
index 4e4877e..b99e436 100644
--- a/util/path.c
+++ b/util/path.c
@@ -58,7 +58,7 @@ static struct pathelem *new_entry(const char *root,
 #if defined(DT_DIR) && defined(DT_UNKNOWN) && defined(DT_LNK)
 # define dirent_type(dirent) ((dirent)->d_type)
 # define is_dir_maybe(type) \
-    ((type) == DT_DIR || (type) == DT_UNKNOWN || (type) == DT_LNK)
+    ((type) == DT_DIR || (type) == DT_UNKNOWN)
 #else
 # define dirent_type(dirent) (1)
 # define is_dir_maybe(type)  (type)
--
2.5.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]