diff options
author | Christophe Vu-Brugier <christophe.vu-brugier@seagate.com> | 2021-11-22 22:02:37 +0900 |
---|---|---|
committer | Namjae Jeon <linkinjeon@kernel.org> | 2022-01-10 11:00:02 +0900 |
commit | 92fba084b79e6bc7b12fc118209f1922c1a2df56 (patch) | |
tree | e7a06c1f197b82966db2a1ebcafcec8f9ed7187c /fs/exfat/inode.c | |
parent | 7dee6f57d7f22a89dd214518c778aec448270d4c (diff) | |
download | linux-92fba084b79e6bc7b12fc118209f1922c1a2df56.tar.bz2 |
exfat: fix i_blocks for files truncated over 4 GiB
In exfat_truncate(), the computation of inode->i_blocks is wrong if
the file is larger than 4 GiB because a 32-bit variable is used as a
mask. This is fixed and simplified by using round_up().
Also fix the same buggy computation in exfat_read_root() and another
(correct) one in exfat_fill_inode(). The latter was fixed another way
last month but can be simplified by using round_up() as well. See:
commit 0c336d6e33f4 ("exfat: fix incorrect loading of i_blocks for
large files")
Fixes: 98d917047e8b ("exfat: add file operations")
Cc: stable@vger.kernel.org # v5.7+
Suggested-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Diffstat (limited to 'fs/exfat/inode.c')
-rw-r--r-- | fs/exfat/inode.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 5c442182f516..df805bd05508 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -602,8 +602,8 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) exfat_save_attr(inode, info->attr); - inode->i_blocks = ((i_size_read(inode) + (sbi->cluster_size - 1)) & - ~((loff_t)sbi->cluster_size - 1)) >> inode->i_blkbits; + inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> + inode->i_blkbits; inode->i_mtime = info->mtime; inode->i_ctime = info->mtime; ei->i_crtime = info->crtime; |