[XFS] Fix oops in xfs_file_readdir()
authorDavid Chinner <dgc@sgi.com>
Wed, 6 Feb 2008 02:37:40 +0000 (13:37 +1100)
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>
Thu, 7 Feb 2008 07:24:13 +0000 (18:24 +1100)
When xfs_file_readdir() exactly fills a buffer, it can move it's index
past the end of the buffer and dereference it even though the result of
the dereference is never used. On some platforms this causes an oops.

SGI-PV: 976923
SGI-Modid: xfs-linux-melb:xfs-kern:30458a

Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
fs/xfs/linux-2.6/xfs_file.c

index 21a1c2b1c5fcf716b779fb973ef31fa5acb6114c..edab1ffbb163ef8bc53335645aee1faa334e364d 100644 (file)
@@ -350,8 +350,8 @@ xfs_file_readdir(
 
                size = buf.used;
                de = (struct hack_dirent *)buf.dirent;
-               curr_offset = de->offset /* & 0x7fffffff */;
                while (size > 0) {
+                       curr_offset = de->offset /* & 0x7fffffff */;
                        if (filldir(dirent, de->name, de->namlen,
                                        curr_offset & 0x7fffffff,
                                        de->ino, de->d_type)) {
@@ -362,7 +362,6 @@ xfs_file_readdir(
                                       sizeof(u64));
                        size -= reclen;
                        de = (struct hack_dirent *)((char *)de + reclen);
-                       curr_offset = de->offset /* & 0x7fffffff */;
                }
        }