[Bug 205871] install(1) in endless loop for orphaned symlinks

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Jan 4 12:28:25 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205871

            Bug ID: 205871
           Summary: install(1) in endless loop for orphaned symlinks
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: frank at pinky.sax.de

install(1) with option "-d" creates directories. If the final target or an
intermediate directory is a symbolic link, that points to a none existing
file/directory, then install will enter an endless loop.

I believe the behaviour was introduced with
base r272026 | mjg | 2014-09-23 13:41:09 +0200 (Tue, 23 Sep 2014).

It was observed when using mergemaster for a jail setup with ezjail. In that
case symlinks visited from host can point to not existing directories on host
system.

environment: 
FreeBSD 11.0-CURRENT #10 r292982M:

how to repeat:
% ln -s /notexists /tmp/
% install -d /tmp/notexists &
[1] 9843
% ps -v -p 9843
 PID STAT    TIME  SL RE PAGEIN  VSZ  RSS LIM TSIZ  %CPU %MEM COMMAND
9843 R    1:12.80 127 73      0 8356 2024   -   28 100.0  0.0 install -d
/tmp/notexists
% kill -ABRT 9843
% gdb /usr/bin/install install.core
(gdb) bt
#0  stat () at stat.S:3
#1  0x0000000000402e0b in main (argc=<value optimized out>, argv=<value
optimized out>) at /usr/src11/usr.bin/xinstall/xinstall.c:1269
(gdb) list 1269
1264            for (p = path;; ++p)
1265                    if (!*p || (p != path && *p  == '/')) {
1266                            ch = *p;
1267                            *p = '\0';
1268    again:
1269                            if (stat(path, &sb) < 0) {
1270                                    if (errno != ENOENT)
1271                                            err(EX_OSERR, "stat %s", path);
1272                                    if (mkdir(path, 0755) < 0) {
1273                                            if (errno == EEXIST)
(gdb) q

The stat call returns ENOENT and mkdir returns with EEXIST - that creates an
endless loop.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list