提交 a33f13ef 编写于 作者: J Joel Becker

libfs: Fix shift bug in generic_check_addressable()

generic_check_addressable() erroneously shifts pages down by a block
factor when it should be shifting up.  To prevent overflow, we shift
blocks down to pages.
Signed-off-by: NJoel Becker <joel.becker@oracle.com>
上级 3bdb8efd
......@@ -925,6 +925,8 @@ EXPORT_SYMBOL(generic_file_fsync);
int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
{
u64 last_fs_block = num_blocks - 1;
u64 last_fs_page =
last_fs_block >> (PAGE_CACHE_SHIFT - blocksize_bits);
if (unlikely(num_blocks == 0))
return 0;
......@@ -932,10 +934,8 @@ int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT))
return -EINVAL;
if ((last_fs_block >
(sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
(last_fs_block >
(pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - blocksize_bits))) {
if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
(last_fs_page > (pgoff_t)(~0ULL))) {
return -EFBIG;
}
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册