diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-11-06 12:53:56 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-06 15:41:21 -0800 |
commit | fa93ca18a8b0da4e26bd9491ad144cd14d22f8ec (patch) | |
tree | 2950aa2baa218493329873a61aa234c7fcc5d83e /fs/fat/inode.c | |
parent | dfc209c0064efef5590f608056a48b61a5cac09c (diff) | |
download | kernel_goldelico_gta04-fa93ca18a8b0da4e26bd9491ad144cd14d22f8ec.zip kernel_goldelico_gta04-fa93ca18a8b0da4e26bd9491ad144cd14d22f8ec.tar.gz kernel_goldelico_gta04-fa93ca18a8b0da4e26bd9491ad144cd14d22f8ec.tar.bz2 |
fat: Fix _fat_bmap() race
fat_get_cluster() assumes the requested blocknr isn't truncated during
read. _fat_bmap() doesn't follow this rule.
This protects it by ->i_mutex.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/inode.c')
-rw-r--r-- | fs/fat/inode.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0da04e6..be88208 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -199,7 +199,14 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb, static sector_t _fat_bmap(struct address_space *mapping, sector_t block) { - return generic_block_bmap(mapping, block, fat_get_block); + sector_t blocknr; + + /* fat_get_cluster() assumes the requested blocknr isn't truncated. */ + mutex_lock(&mapping->host->i_mutex); + blocknr = generic_block_bmap(mapping, block, fat_get_block); + mutex_unlock(&mapping->host->i_mutex); + + return blocknr; } static const struct address_space_operations fat_aops = { |