linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext2: fix unbalanced kmap()/kunmap()
@ 2009-09-05  4:25 Nicolas Pitre
  2009-09-05 12:59 ` Theodore Tso
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Pitre @ 2009-09-05  4:25 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-ext4, lkml

In ext2_rename(), dir_page is acquired through ext2_dotdot().  It is 
then released through ext2_set_link() but only if old_dir != new_dir. 
Failing that, the pkmap reference count is never decremented and the 
page remains pinned forever.  Repeat that a couple times with highmem 
pages and all pkmap slots get exhausted, and every further kmap() calls 
end up stalling on the pkmap_map_wait queue at which point the whole 
system comes to a halt.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
---

I ran into this issue while testing highmem on ARM by running the git 
test suite in a loop with 3 parallel instances.  Using the right mv 
sequence in a script would constitute a pretty simple recipe for a 
local DoS on systems running ext2 and highmem.  No idea if ext3 or ext4 
have the same issue.

diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index e1dedb0..78d9b92 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -362,6 +362,10 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
 	if (dir_de) {
 		if (old_dir != new_dir)
 			ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
+		else {
+			kunmap(dir_page);
+			page_cache_release(dir_page);
+		}
 		inode_dec_link_count(old_dir);
 	}
 	return 0;

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

* Re: [PATCH] ext2: fix unbalanced kmap()/kunmap()
  2009-09-05  4:25 [PATCH] ext2: fix unbalanced kmap()/kunmap() Nicolas Pitre
@ 2009-09-05 12:59 ` Theodore Tso
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Tso @ 2009-09-05 12:59 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: Linus Torvalds, linux-ext4, lkml

On Sat, Sep 05, 2009 at 12:25:37AM -0400, Nicolas Pitre wrote:
> In ext2_rename(), dir_page is acquired through ext2_dotdot().  It is 
> then released through ext2_set_link() but only if old_dir != new_dir. 
> Failing that, the pkmap reference count is never decremented and the 
> page remains pinned forever.  Repeat that a couple times with highmem 
> pages and all pkmap slots get exhausted, and every further kmap() calls 
> end up stalling on the pkmap_map_wait queue at which point the whole 
> system comes to a halt.
> 
> Signed-off-by: Nicolas Pitre <nico@marvell.com>

Acked-by: "Theodore Ts'o" <tytso@mit.edu>

> I ran into this issue while testing highmem on ARM by running the git 
> test suite in a loop with 3 parallel instances.  Using the right mv 
> sequence in a script would constitute a pretty simple recipe for a 
> local DoS on systems running ext2 and highmem.  No idea if ext3 or ext4 
> have the same issue.

This is an ext2-only issue; for journalling reasons ext3 and ext4 read
and write the directory via buffer heads.  So this issue won't apply
for ext3 or ext4.

						- Ted

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

end of thread, other threads:[~2009-09-05 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-05  4:25 [PATCH] ext2: fix unbalanced kmap()/kunmap() Nicolas Pitre
2009-09-05 12:59 ` Theodore Tso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).