• Christoph Hellwig's avatar
    [XFS] truncate readdir offsets to signed 32 bit values · 15440319
    Christoph Hellwig authored
    John Stanley reported EOVERFLOW errors in readdir from his self-build
    glibc.  I traced this down to glibc enabling d_off overflow checks
    in one of the about five million different getdents implementations.
    
    In 2.6.28 Dave Woodhouse moved our readdir double buffering required
    for NFS4 readdirplus into nfsd and at that point we lost the capping
    of the directory offsets to 32 bit signed values.  Johns glibc used
    getdents64 to even implement readdir for normal 32 bit offset dirents,
    and failed with EOVERFLOW only if this happens on the first dirent in
    a getdents call.  I managed to come up with a testcase that uses
    raw getdents and does the EOVERFLOW check manually.  We always hit
    it with our last entry due to the special end of directory marker.
    
    The patch below is a dumb version of just putting back the masking,
    to make sure we have the same behavior as in 2.6.27 and earlier.
    
    I will work on a better and cleaner fix for 2.6.30.
    Reported-by: default avatarJohn Stanley <jpsinthemix@verizon.net>
    Tested-by: default avatarJohn Stanley <jpsinthemix@verizon.net>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
    Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
    15440319
xfs_dir2_sf.c 36.9 KB