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

Merge tag 'ntfs3_for_6.18' of https://github.com/Paragon-Software-Group/linux-ntfs3

Pull ntfs3 updates from Konstantin Komarov:
"Added:
- support for FS_IOC_{GET,SET}FSLABEL ioctl
- reject index allocation if $BITMAP is empty but blocks exist

Fixed:
- integer overflow in run_unpack()
- resource leak bug in wnd_extend()

Changed:
- pretend $Extend records as regular files
- stop using write_cache_pages"

* tag 'ntfs3_for_6.18' of https://github.com/Paragon-Software-Group/linux-ntfs3:
ntfs3: stop using write_cache_pages
fs/ntfs3: reject index allocation if $BITMAP is empty but blocks exist
fs/ntfs3: Fix a resource leak bug in wnd_extend()
fs: ntfs3: Fix integer overflow in run_unpack()
ntfs3: pretend $Extend records as regular files
ntfs3: add FS_IOC_SETFSLABEL ioctl
ntfs3: add FS_IOC_GETFSLABEL ioctl
ntfs3: transition magic number to shared constant

+50 -4
+1
fs/ntfs3/bitmap.c
··· 1371 1371 mark_buffer_dirty(bh); 1372 1372 unlock_buffer(bh); 1373 1373 /* err = sync_dirty_buffer(bh); */ 1374 + put_bh(bh); 1374 1375 1375 1376 b0 = 0; 1376 1377 bits -= op;
+28
fs/ntfs3/file.c
··· 49 49 return 0; 50 50 } 51 51 52 + static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf) 53 + { 54 + if (copy_to_user(buf, sbi->volume.label, FSLABEL_MAX)) 55 + return -EFAULT; 56 + 57 + return 0; 58 + } 59 + 60 + static int ntfs_ioctl_set_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf) 61 + { 62 + u8 user[FSLABEL_MAX] = {0}; 63 + int len; 64 + 65 + if (!capable(CAP_SYS_ADMIN)) 66 + return -EPERM; 67 + 68 + if (copy_from_user(user, buf, FSLABEL_MAX)) 69 + return -EFAULT; 70 + 71 + len = strnlen(user, FSLABEL_MAX); 72 + 73 + return ntfs_set_label(sbi, user, len); 74 + } 75 + 52 76 /* 53 77 * ntfs_ioctl - file_operations::unlocked_ioctl 54 78 */ ··· 88 64 switch (cmd) { 89 65 case FITRIM: 90 66 return ntfs_ioctl_fitrim(sbi, arg); 67 + case FS_IOC_GETFSLABEL: 68 + return ntfs_ioctl_get_volume_label(sbi, (u8 __user *)arg); 69 + case FS_IOC_SETFSLABEL: 70 + return ntfs_ioctl_set_volume_label(sbi, (u8 __user *)arg); 91 71 } 92 72 return -ENOTTY; /* Inappropriate ioctl for device. */ 93 73 }
+10
fs/ntfs3/index.c
··· 1508 1508 bmp_size = bmp_size_v = le32_to_cpu(bmp->res.data_size); 1509 1509 } 1510 1510 1511 + /* 1512 + * Index blocks exist, but $BITMAP has zero valid bits. 1513 + * This implies an on-disk corruption and must be rejected. 1514 + */ 1515 + if (in->name == I30_NAME && 1516 + unlikely(bmp_size_v == 0 && indx->alloc_run.count)) { 1517 + err = -EINVAL; 1518 + goto out1; 1519 + } 1520 + 1511 1521 bit = bmp_size << 3; 1512 1522 } 1513 1523
+1
fs/ntfs3/inode.c
··· 471 471 fname->home.seq == cpu_to_le16(MFT_REC_EXTEND)) { 472 472 /* Records in $Extend are not a files or general directories. */ 473 473 inode->i_op = &ntfs_file_inode_operations; 474 + mode = S_IFREG; 474 475 } else { 475 476 err = -EINVAL; 476 477 goto out;
+1 -1
fs/ntfs3/ntfs_fs.h
··· 280 280 __le16 flags; // Cached current VOLUME_INFO::flags, VOLUME_FLAG_DIRTY. 281 281 u8 major_ver; 282 282 u8 minor_ver; 283 - char label[256]; 283 + char label[FSLABEL_MAX]; 284 284 bool real_dirty; // Real fs state. 285 285 } volume; 286 286
+9 -3
fs/ntfs3/run.c
··· 9 9 #include <linux/blkdev.h> 10 10 #include <linux/fs.h> 11 11 #include <linux/log2.h> 12 + #include <linux/overflow.h> 12 13 13 14 #include "debug.h" 14 15 #include "ntfs.h" ··· 983 982 984 983 if (!dlcn) 985 984 return -EINVAL; 986 - lcn = prev_lcn + dlcn; 985 + 986 + if (check_add_overflow(prev_lcn, dlcn, &lcn)) 987 + return -EINVAL; 987 988 prev_lcn = lcn; 988 989 } else { 989 990 /* The size of 'dlcn' can't be > 8. */ 990 991 return -EINVAL; 991 992 } 992 993 993 - next_vcn = vcn64 + len; 994 + if (check_add_overflow(vcn64, len, &next_vcn)) 995 + return -EINVAL; 996 + 994 997 /* Check boundary. */ 995 998 if (next_vcn > evcn + 1) 996 999 return -EINVAL; ··· 1158 1153 return -EINVAL; 1159 1154 1160 1155 run_buf += size_size + offset_size; 1161 - vcn64 += len; 1156 + if (check_add_overflow(vcn64, len, &vcn64)) 1157 + return -EINVAL; 1162 1158 1163 1159 #ifndef CONFIG_NTFS3_64BIT_CLUSTER 1164 1160 if (vcn64 > 0x100000000ull)