• Linus Torvalds's avatar
    vfs: Fix /proc/<tid>/fdinfo/<fd> file handling · 0640113b
    Linus Torvalds authored
    Cyrill Gorcunov reports that I broke the fdinfo files with commit
    30a08bf2 ("proc: move fd symlink i_mode calculations into
    tid_fd_revalidate()"), and he's quite right.
    
    The tid_fd_revalidate() function is not just used for the <tid>/fd
    symlinks, it's also used for the <tid>/fdinfo/<fd> files, and the
    permission model for those are different.
    
    So do the dynamic symlink permission handling just for symlinks, making
    the fdinfo files once more appear as the proper regular files they are.
    
    Of course, Al Viro argued (probably correctly) that we shouldn't do the
    symlink permission games at all, and make the symlinks always just be
    the normal 'lrwxrwxrwx'.  That would have avoided this issue too, but
    since somebody noticed that the permissions had changed (which was the
    reason for that original commit 30a08bf2 in the first place), people
    do apparently use this feature.
    
    [ Basically, you can use the symlink permission data as a cheap "fdinfo"
      replacement, since you see whether the file is open for reading and/or
      writing by just looking at st_mode of the symlink.  So the feature
      does make sense, even if the pain it has caused means we probably
      shouldn't have done it to begin with. ]
    Reported-and-tested-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    0640113b
base.c 87.4 KB