Skip to content

Commit 913e027

Browse files
Dmitry Monakhovtorvalds
authored andcommitted
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++)) do filefrag test > /dev/null & done Signed-off-by: Dmitry Monakhov <[email protected]> Cc: Theodore Ts'o <[email protected]> Cc: Al Viro <[email protected]> Cc: Michael Kerrisk <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 99b8874 commit 913e027

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Documentation/filesystems/fiemap.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ struct fiemap_extent_info {
196196
};
197197

198198
It is intended that the file system should not need to access any of this
199-
structure directly.
199+
structure directly. Filesystem handlers should be tolerant to signals and return
200+
EINTR once fatal signal received.
200201

201202

202203
Flag checking should be done at the beginning of the ->fiemap callback via the

fs/ioctl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ int __generic_block_fiemap(struct inode *inode,
379379
past_eof = true;
380380
}
381381
cond_resched();
382+
if (fatal_signal_pending(current)) {
383+
ret = -EINTR;
384+
break;
385+
}
386+
382387
} while (1);
383388

384389
/* If ret is 1 then we just hit the end of the extent array */

0 commit comments

Comments
 (0)