Commit 913e027c authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Linus Torvalds

fsioctl.c: make generic_block_fiemap() signal-tolerant

__generic_block_fiemap may spin very long time for large sparse files.

Without this patch an unprivileged user may abuse system resources simply
by spawning a vast number of unkilable busyloops (works on ext2/ext3):

  truncate --size 1T test
  for ((i=0;i<1024;i++))
         filefrag test > /dev/null &
Signed-off-by: default avatarDmitry Monakhov <>
Cc: Theodore Ts'o <>
Cc: Al Viro <>
Cc: Michael Kerrisk <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 99b8874e
......@@ -196,7 +196,8 @@ struct fiemap_extent_info {
It is intended that the file system should not need to access any of this
structure directly.
structure directly. Filesystem handlers should be tolerant to signals and return
EINTR once fatal signal received.
Flag checking should be done at the beginning of the ->fiemap callback via the
......@@ -379,6 +379,11 @@ int __generic_block_fiemap(struct inode *inode,
past_eof = true;
if (fatal_signal_pending(current)) {
ret = -EINTR;
} while (1);
/* If ret is 1 then we just hit the end of the extent array */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment