Commit 248736c2a57206388c86f8cdd3392ee986e84f9f

Authored by Eric Sesterhenn
Committed by Linus Torvalds
1 parent 6e71529444

hfsplus: fix possible deadlock when handling corrupted extents

A corrupted extent for the extent file itself may try to get an impossible
extent, causing a deadlock if I see it correctly.

Check the inode number after the first_blocks checks and fail if it's the
extent file, as according to the spec the extent file should have no
extent for itself.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

fs/hfsplus/extents.c
... ... @@ -199,6 +199,9 @@
199 199 goto done;
200 200 }
201 201  
  202 + if (inode->i_ino == HFSPLUS_EXT_CNID)
  203 + return -EIO;
  204 +
202 205 mutex_lock(&HFSPLUS_I(inode).extents_lock);
203 206 res = hfsplus_ext_read_extent(inode, ablock);
204 207 if (!res) {