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-next>] [day] [month] [year] [list]
Message-ID: <20241107084044.182463-1-alexjlzheng@tencent.com>
Date: Thu,  7 Nov 2024 16:40:44 +0800
From: Jinliang Zheng <alexjlzheng@...il.com>
To: dchinner@...hat.com
Cc: cem@...nel.org,
	djwong@...nel.org,
	chandanbabu@...nel.org,
	linux-xfs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Jinliang Zheng <alexjlzheng@...cent.com>
Subject: [PATCH v2] xfs: check the remaining length of extent after roundup

In xfs_alloc_compute_diff(), ensure that the remaining length of extent
still meets the wantlen requirements after newbno1 is rounded.

Signed-off-by: Jinliang Zheng <alexjlzheng@...cent.com>
---
Changelog:

V2: Fix the error logic

V1: https://lore.kernel.org/linux-xfs/20241107070300.13535-1-alexjlzheng@tencent.com/#R
---
 fs/xfs/libxfs/xfs_alloc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 22bdbb3e9980..1d4cc75b7318 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -393,7 +393,8 @@ xfs_alloc_compute_diff(
 	 * grows in the short term.
 	 */
 	if (freebno >= wantbno || (userdata && freeend < wantend)) {
-		if ((newbno1 = roundup(freebno, alignment)) >= freeend)
+		newbno1 = roundup(freebno, alignment);
+		if (newbno1 >= freeend || newbno1 > freeend - wantlen)
 			newbno1 = NULLAGBLOCK;
 	} else if (freeend >= wantend && alignment > 1) {
 		newbno1 = roundup(wantbno, alignment);
@@ -414,6 +415,8 @@ xfs_alloc_compute_diff(
 				newbno1 = newbno2;
 		} else if (newbno2 != NULLAGBLOCK)
 			newbno1 = newbno2;
+		if (newbno1 > freeend - wantlen)
+			newbno1 = NULLAGBLOCK;
 	} else if (freeend >= wantend) {
 		newbno1 = wantbno;
 	} else if (alignment > 1) {
-- 
2.41.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ