mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] fix race in __block_prepare_write (again)
@ 2005-04-21  6:14 Nick Piggin
  2005-04-21  7:01 ` Anton Altaparmakov
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Piggin @ 2005-04-21  6:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml, Andrea Arcangeli

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

... I somehow didn't send it to Andrew last time.

-- 
SUSE Labs, Novell Inc.


[-- Attachment #2: __block_prepare_write-bug.patch --]
[-- Type: text/x-patch, Size: 1151 bytes --]

Fix a race where __block_prepare_write can leak out an in-flight
read against a bh if get_block returns an error. This can lead to
the page becoming unlocked while the buffer is locked and the read
still in flight. __mpage_writepage BUGs on this condition.

BUG sighted on a 2-way Itanium2 system with 16K PAGE_SIZE running

	fsstress -v -d $DIR/tmp -n 1000 -p 1000 -l 2
	
where $DIR is a new ext2 filesystem with 4K blocks that is quite
small (causing get_block to fail often with -ENOSPC).

Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>

Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c	2005-04-21 11:55:17.549614278 +1000
+++ linux-2.6/fs/buffer.c	2005-04-21 15:55:41.483826075 +1000
@@ -1988,6 +1988,7 @@
 			*wait_bh++=bh;
 		}
 	}
+out:
 	/*
 	 * If we issued read requests - let them complete.
 	 */
@@ -1996,8 +1997,9 @@
 		if (!buffer_uptodate(*wait_bh))
 			return -EIO;
 	}
-	return 0;
-out:
+	if (!err)
+		return err;
+
 	/*
 	 * Zero out any newly allocated blocks to avoid exposing stale
 	 * data.  If BH_New is set, we know that the block was newly

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

end of thread, other threads:[~2005-04-25  7:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-21  6:14 [patch] fix race in __block_prepare_write (again) Nick Piggin
2005-04-21  7:01 ` Anton Altaparmakov
2005-04-21  7:10   ` Anton Altaparmakov
2005-04-21  7:20     ` Nick Piggin
2005-04-21  7:31       ` Anton Altaparmakov
2005-04-22 15:10         ` Nikita Danilov
2005-04-22 15:50           ` Anton Altaparmakov
2005-04-24 21:24         ` Andrew Morton
2005-04-25  7:44           ` Anton Altaparmakov
2005-04-21  7:13   ` Nick Piggin

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®