• R/O
  • HTTP
  • SSH
  • HTTPS

linux-2.4.36: Commit

2.4.36-stable kernel tree


Commit MetaInfo

Revision8be8243c968d85e464ba017877575355539b7965 (tree)
Time2008-02-04 00:37:45
Authordann frazier <dannf@debi...>
CommiterWilly Tarreau

Log Message

avoid semi-infinite loop when mounting bad ext2

This is a 2.4 backport of a linux-2.6 change by Andries Brouwer
(old-2.6-bkcvs commit c279c5343b1796bf1db4c0b4af2c99479a6575fe)

Commit log from 2.6 follows.

The routine ext2_readdir() will, when reading a directory page
returns an error, try the next page, without reporting the
error to user space. That is bad, and the patch below changes that.
In my case the filesystem was damaged, and ext2_readdir wanted
to read 60000+ pages and wrote as many error messages to syslog
("attempt to access beyond end"), not what one wants.
[no doubt a similar patch is appropriate for ext3]

Signed-off-by: dann frazier <dannf@hp.com>

Change Summary

Incremental Difference

--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -246,6 +246,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
246246 unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
247247 unsigned char *types = NULL;
248248 int need_revalidate = (filp->f_version != inode->i_version);
249+ int ret = 0;
249250
250251 if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
251252 goto done;
@@ -263,7 +264,8 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
263264 "bad page in #%lu",
264265 inode->i_ino);
265266 filp->f_pos += PAGE_CACHE_SIZE - offset;
266- continue;
267+ ret = -EIO;
268+ goto done;
267269 }
268270 kaddr = page_address(page);
269271 if (need_revalidate) {
@@ -296,7 +298,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
296298 done:
297299 filp->f_version = inode->i_version;
298300 UPDATE_ATIME(inode);
299- return 0;
301+ return ret;
300302 }
301303
302304 /*
Show on old repository browser