Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'exfat-for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat

Pull exfat updates from Namjae Jeon:

- Fix a remount failure caused by differing process masks by inheriting
the original mount options during the remount process

- Fix a potential divide-by-zero error and system crash in
exfat_allocate_bitmap that occurred when the readahead count was zero

- Add validation for directory cluster bitmap bits to prevent directory
and root cluster from being incorrectly zeroed out on corrupted
images

- Clear the post-EOF page cache when extending a file to prevent stale
mmap data from becoming visible, addressing an generic/363 failure

- Fix a reference count leak in exfat_find by properly releasing the
dentry set in specific error paths

* tag 'exfat-for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat:
exfat: fix remount failure in different process environments
exfat: fix divide-by-zero in exfat_allocate_bitmap
exfat: validate the cluster bitmap bits of directory
exfat: zero out post-EOF page cache on file extension
exfat: fix refcount leak in exfat_find

+77 -24
+25 -5
fs/exfat/balloc.c
··· 106 106 (PAGE_SHIFT - sb->s_blocksize_bits); 107 107 for (i = 0; i < sbi->map_sectors; i++) { 108 108 /* Trigger the next readahead in advance. */ 109 - if (0 == (i % max_ra_count)) { 109 + if (max_ra_count && 0 == (i % max_ra_count)) { 110 110 blk_start_plug(&plug); 111 111 for (j = i; j < min(max_ra_count, sbi->map_sectors - i) + i; j++) 112 112 sb_breadahead(sb, sector + j); ··· 183 183 kvfree(sbi->vol_amap); 184 184 } 185 185 186 - int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync) 186 + int exfat_set_bitmap(struct super_block *sb, unsigned int clu, bool sync) 187 187 { 188 188 int i, b; 189 189 unsigned int ent_idx; 190 - struct super_block *sb = inode->i_sb; 191 190 struct exfat_sb_info *sbi = EXFAT_SB(sb); 192 191 193 192 if (!is_valid_cluster(sbi, clu)) ··· 201 202 return 0; 202 203 } 203 204 204 - int exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync) 205 + int exfat_clear_bitmap(struct super_block *sb, unsigned int clu, bool sync) 205 206 { 206 207 int i, b; 207 208 unsigned int ent_idx; 208 - struct super_block *sb = inode->i_sb; 209 209 struct exfat_sb_info *sbi = EXFAT_SB(sb); 210 210 211 211 if (!is_valid_cluster(sbi, clu)) ··· 222 224 exfat_update_bh(sbi->vol_amap[i], sync); 223 225 224 226 return 0; 227 + } 228 + 229 + bool exfat_test_bitmap(struct super_block *sb, unsigned int clu) 230 + { 231 + int i, b; 232 + unsigned int ent_idx; 233 + struct exfat_sb_info *sbi = EXFAT_SB(sb); 234 + 235 + if (!sbi->vol_amap) 236 + return true; 237 + 238 + if (!is_valid_cluster(sbi, clu)) 239 + return false; 240 + 241 + ent_idx = CLUSTER_TO_BITMAP_ENT(clu); 242 + i = BITMAP_OFFSET_SECTOR_INDEX(sb, ent_idx); 243 + b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx); 244 + 245 + if (!test_bit_le(b, sbi->vol_amap[i]->b_data)) 246 + return false; 247 + 248 + return true; 225 249 } 226 250 227 251 /*
+5
fs/exfat/dir.c
··· 604 604 if (ret) 605 605 return ret; 606 606 607 + if (!exfat_test_bitmap(sb, clu)) { 608 + exfat_err(sb, "failed to test cluster bit(%u)", clu); 609 + return -EIO; 610 + } 611 + 607 612 /* byte offset in cluster */ 608 613 off = EXFAT_CLU_OFFSET(off, sbi); 609 614
+3 -2
fs/exfat/exfat_fs.h
··· 452 452 /* balloc.c */ 453 453 int exfat_load_bitmap(struct super_block *sb); 454 454 void exfat_free_bitmap(struct exfat_sb_info *sbi); 455 - int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync); 456 - int exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync); 455 + int exfat_set_bitmap(struct super_block *sb, unsigned int clu, bool sync); 456 + int exfat_clear_bitmap(struct super_block *sb, unsigned int clu, bool sync); 457 + bool exfat_test_bitmap(struct super_block *sb, unsigned int clu); 457 458 unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu); 458 459 int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count); 459 460 int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);
+3 -3
fs/exfat/fatent.c
··· 205 205 cur_cmap_i = next_cmap_i; 206 206 } 207 207 208 - err = exfat_clear_bitmap(inode, clu, (sync && IS_DIRSYNC(inode))); 208 + err = exfat_clear_bitmap(sb, clu, (sync && IS_DIRSYNC(inode))); 209 209 if (err) 210 210 break; 211 211 clu++; ··· 233 233 cur_cmap_i = next_cmap_i; 234 234 } 235 235 236 - if (exfat_clear_bitmap(inode, clu, (sync && IS_DIRSYNC(inode)))) 236 + if (exfat_clear_bitmap(sb, clu, (sync && IS_DIRSYNC(inode)))) 237 237 break; 238 238 239 239 if (sbi->options.discard) { ··· 409 409 } 410 410 411 411 /* update allocation bitmap */ 412 - if (exfat_set_bitmap(inode, new_clu, sync_bmap)) { 412 + if (exfat_set_bitmap(sb, new_clu, sync_bmap)) { 413 413 ret = -EIO; 414 414 goto free_cluster; 415 415 }
+5
fs/exfat/file.c
··· 25 25 struct exfat_sb_info *sbi = EXFAT_SB(sb); 26 26 struct exfat_chain clu; 27 27 28 + truncate_pagecache(inode, i_size_read(inode)); 29 + 28 30 ret = inode_newsize_ok(inode, size); 29 31 if (ret) 30 32 return ret; ··· 640 638 return -EIO; 641 639 642 640 inode_lock(inode); 641 + 642 + if (pos > i_size_read(inode)) 643 + truncate_pagecache(inode, i_size_read(inode)); 643 644 644 645 valid_size = ei->valid_size; 645 646
+10 -10
fs/exfat/namei.c
··· 645 645 info->valid_size = le64_to_cpu(ep2->dentry.stream.valid_size); 646 646 info->size = le64_to_cpu(ep2->dentry.stream.size); 647 647 648 - if (info->valid_size < 0) { 649 - exfat_fs_error(sb, "data valid size is invalid(%lld)", info->valid_size); 650 - return -EIO; 651 - } 652 - 653 - if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) { 654 - exfat_fs_error(sb, "data size is invalid(%lld)", info->size); 655 - return -EIO; 656 - } 657 - 658 648 info->start_clu = le32_to_cpu(ep2->dentry.stream.start_clu); 659 649 if (!is_valid_cluster(sbi, info->start_clu) && info->size) { 660 650 exfat_warn(sb, "start_clu is invalid cluster(0x%x)", ··· 681 691 ep->dentry.file.access_date, 682 692 0); 683 693 exfat_put_dentry_set(&es, false); 694 + 695 + if (info->valid_size < 0) { 696 + exfat_fs_error(sb, "data valid size is invalid(%lld)", info->valid_size); 697 + return -EIO; 698 + } 699 + 700 + if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) { 701 + exfat_fs_error(sb, "data size is invalid(%lld)", info->size); 702 + return -EIO; 703 + } 684 704 685 705 if (ei->start_clu == EXFAT_FREE_CLUSTER) { 686 706 exfat_fs_error(sb,
+26 -4
fs/exfat/super.c
··· 629 629 goto free_bh; 630 630 } 631 631 632 + if (!exfat_test_bitmap(sb, sbi->root_dir)) { 633 + exfat_warn(sb, "failed to test first cluster bit of root dir(%u)", 634 + sbi->root_dir); 635 + /* 636 + * The first cluster bit of the root directory should never 637 + * be unset except when storage is corrupted. This bit is 638 + * set to allow operations after mount. 639 + */ 640 + exfat_set_bitmap(sb, sbi->root_dir, false); 641 + } 642 + 632 643 ret = exfat_count_used_clusters(sb, &sbi->used_clusters); 633 644 if (ret) { 634 645 exfat_err(sb, "failed to scan clusters"); ··· 824 813 ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, 825 814 DEFAULT_RATELIMIT_BURST); 826 815 827 - sbi->options.fs_uid = current_uid(); 828 - sbi->options.fs_gid = current_gid(); 829 - sbi->options.fs_fmask = current->fs->umask; 830 - sbi->options.fs_dmask = current->fs->umask; 816 + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE && fc->root) { 817 + struct super_block *sb = fc->root->d_sb; 818 + struct exfat_mount_options *cur_opts = &EXFAT_SB(sb)->options; 819 + 820 + sbi->options.fs_uid = cur_opts->fs_uid; 821 + sbi->options.fs_gid = cur_opts->fs_gid; 822 + sbi->options.fs_fmask = cur_opts->fs_fmask; 823 + sbi->options.fs_dmask = cur_opts->fs_dmask; 824 + } else { 825 + sbi->options.fs_uid = current_uid(); 826 + sbi->options.fs_gid = current_gid(); 827 + sbi->options.fs_fmask = current->fs->umask; 828 + sbi->options.fs_dmask = current->fs->umask; 829 + } 830 + 831 831 sbi->options.allow_utime = -1; 832 832 sbi->options.errors = EXFAT_ERRORS_RO; 833 833 exfat_set_iocharset(&sbi->options, exfat_default_iocharset);