mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] avoid semi-infinite loop when mounting bad ext2
@ 2004-11-03 23:27 Andries Brouwer
  2004-11-04  0:10 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Andries Brouwer @ 2004-11-03 23:27 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel

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.

Andries

[no doubt a similar patch is appropriate for ext3]


diff -uprN -X /linux/dontdiff a/fs/ext2/dir.c b/fs/ext2/dir.c
--- a/fs/ext2/dir.c	2004-10-30 21:44:02.000000000 +0200
+++ b/fs/ext2/dir.c	2004-11-04 00:14:14.000000000 +0100
@@ -275,7 +275,8 @@ ext2_readdir (struct file * filp, void *
 				   "bad page in #%lu",
 				   inode->i_ino);
 			filp->f_pos += PAGE_CACHE_SIZE - offset;
-			continue;
+			ret = -EIO;
+			goto done;
 		}
 		kaddr = page_address(page);
 		if (need_revalidate) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-04  0:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-03 23:27 [PATCH] avoid semi-infinite loop when mounting bad ext2 Andries Brouwer
2004-11-04  0:10 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®