linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: handle NULL p_ext in ext4_ext_next_allocated_block()
@ 2011-10-09  1:01 Curt Wohlgemuth
  2011-10-10  7:19 ` Lukas Czerner
  2011-10-26  8:38 ` Ted Ts'o
  0 siblings, 2 replies; 6+ messages in thread
From: Curt Wohlgemuth @ 2011-10-09  1:01 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, Curt Wohlgemuth

In ext4_ext_next_allocated_block(), the path[depth] might
have a p_ext that is NULL -- see ext4_ext_binsearch().  In
such a case, dereferencing it will crash the machine.

This patch checks for p_ext == NULL in
ext4_ext_next_allocated_block() before dereferencinging it.

Tested using a hand-crafted an inode with eh_entries == 0 in
an extent block, verified that running FIEMAP on it crashes
without this patch, works fine with it.

Signed-off-by: Curt Wohlgemuth <curtw@google.com>
---
 fs/ext4/extents.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 57cf568..063a5b8 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1395,7 +1395,9 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
 	while (depth >= 0) {
 		if (depth == path->p_depth) {
 			/* leaf */
-			if (path[depth].p_ext !=
+			/* p_ext can be NULL */
+			if (path[depth].p_ext &&
+				path[depth].p_ext !=
 					EXT_LAST_EXTENT(path[depth].p_hdr))
 			  return le32_to_cpu(path[depth].p_ext[1].ee_block);
 		} else {
-- 
1.7.3.1


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

end of thread, other threads:[~2011-10-26  8:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-09  1:01 [PATCH] ext4: handle NULL p_ext in ext4_ext_next_allocated_block() Curt Wohlgemuth
2011-10-10  7:19 ` Lukas Czerner
2011-10-10 15:28   ` Curt Wohlgemuth
2011-10-11  7:01     ` Dmitry Monakhov
2011-10-26  8:26       ` Ted Ts'o
2011-10-26  8:38 ` Ted Ts'o

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).