lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8cb6d3fe-22ed-4166-c047-de0da97c4a11@paragon-software.com>
Date:   Fri, 24 Jun 2022 14:41:23 +0300
From:   Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
To:     <ntfs3@...ts.linux.dev>
CC:     <linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>
Subject: [PATCH 2/3] fs/ntfs3: Check reserved size for maximum allowed

Also don't mask EFBIG
Fixes xfstest generic/485
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
---
  fs/ntfs3/attrib.c | 11 ++++++++++-
  fs/ntfs3/file.c   |  3 ---
  2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index bea0e70e974a..3bd51cf4d8bd 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -2114,9 +2114,11 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
  
  	if (!attr_b->non_res) {
  		data_size = le32_to_cpu(attr_b->res.data_size);
+		alloc_size = data_size;
  		mask = sbi->cluster_mask; /* cluster_size - 1 */
  	} else {
  		data_size = le64_to_cpu(attr_b->nres.data_size);
+		alloc_size = le64_to_cpu(attr_b->nres.alloc_size);
  		mask = (sbi->cluster_size << attr_b->nres.c_unit) - 1;
  	}
  
@@ -2130,6 +2132,13 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
  		return -EINVAL;
  	}
  
+	/*
+	 * valid_size <= data_size <= alloc_size
+	 * Check alloc_size for maximum possible.
+	 */
+	if (bytes > sbi->maxbytes_sparse - alloc_size)
+		return -EFBIG;
+
  	vcn = vbo >> sbi->cluster_bits;
  	len = bytes >> sbi->cluster_bits;
  
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 5ee035e42c21..de37d5c1d60b 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -732,9 +732,6 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
  	if (map_locked)
  		filemap_invalidate_unlock(mapping);
  
-	if (err == -EFBIG)
-		err = -ENOSPC;
-
  	if (!err) {
  		inode->i_ctime = inode->i_mtime = current_time(inode);
  		mark_inode_dirty(inode);
-- 
2.36.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ