[Bug libc/23501] New: nftw() doesn't return dangling symlink's inode

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] New: nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

            Bug ID: 23501
           Summary: nftw() doesn't return dangling symlink's inode
           Product: glibc
           Version: 2.30
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: eblake at redhat dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The Austin Group ruled in:
http://austingroupbugs.net/view.php?id=1121

that the use of d_type shortcuts during nftw() has resulted in an unintentional
regression in glibc:

"Until glibc 2.3.6, in the io/ftw.c process_entry() code, we find:

  if (((data->flags & FTW_PHYS)
       ? LXSTAT (_STAT_VER, name, &st)
       : XSTAT (_STAT_VER, name, &st)) < 0)
    {
      if (errno != EACCES && errno != ENOENT)
        result = -1;
      else if (!(data->flags & FTW_PHYS)
               && LXSTAT (_STAT_VER, name, &st) == 0
               && S_ISLNK (st.st_mode))
        flag = FTW_SLN;
      else
        flag = FTW_NS;
    }

So, if FTW_PHYS was not set, use stat() on the path. If that fails (because of
a dangling symlink, for example), then try lstat() on the path and check if the
result is symlink; if so, emit FTW_SLN.

In glibc 2.4 (~2006) things changed to the situation we currently have. The
change *appears* to be an unintended regression, since the associated changelog
message make no mention of modifying the behavior of FTW_SLN.

So, I do think this is a glibc bug, not a fault in the standard, per se (though
the standard could be a little clearer).
"

As this regression is not standards compliant, glibc needs to perform an lstat
(perhaps only when POSIXLY_CORRECT is set?) even when using d_type to shortcut
the knowledge that a dangling symlink has been found.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1422736

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

Tulio Magno Quites Machado Filho <tuliom at linux dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tuliom at linux dot ibm.com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
           See Also|                            |http://austingroupbugs.net/
                   |                            |view.php?id=1121

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://bugzilla.redhat.com
                   |                            |/show_bug.cgi?id=1422736

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by DJ Delorie <[hidden email]>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6ba205b2c35e3e024c8c12d2ee1b73363e84da87

commit 6ba205b2c35e3e024c8c12d2ee1b73363e84da87
Author: DJ Delorie <[hidden email]>
Date:   Wed Jun 19 17:07:41 2019 -0400

    nftw: fill in stat buf for dangling links [BZ #23501]

    As per Austin Group interpretation, "the object" wrt a
    dangling symlink is the symlink itself, despite FTW_PHYS.

    Reviewed-by: Tulio Magno Quites Machado Filho <[hidden email]>

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

dj at redhat dot com <dj at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dj at redhat dot com
         Resolution|---                         |FIXED
           Assignee|unassigned at sourceware dot org   |dj at redhat dot com

--- Comment #2 from dj at redhat dot com <dj at redhat dot com> ---
Committed.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Please set the target milestone appropriately for the first mainline
release in which this is fixed.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/23501] nftw() doesn't return dangling symlink's inode

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23501

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.30

--
You are receiving this mail because:
You are on the CC list for the bug.