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: <20250826033557.127367-4-yang.chenzhi@vivo.com>
Date: Tue, 26 Aug 2025 11:35:56 +0800
From: Chenzhi Yang <yang.chenzhi@...o.com>
To: slava@...eyko.com,
	glaubitz@...sik.fu-berlin.de,
	frank.li@...o.com
Cc: linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Yang Chenzhi <yang.chenzhi@...o.com>
Subject: [RFC PATCH 3/4] hfs: restruct hfs_bnode_read

From: Yang Chenzhi <yang.chenzhi@...o.com>

Since __hfs_bnode_read and hfs_bnode_read have the same
implementation, make hfs_bnode_read call __hfs_bnode_read
and report errors when detected, while keeping the
original function logic unchanged.

Signed-off-by: Yang Chenzhi <yang.chenzhi@...o.com>
---
 fs/hfs/bnode.c | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index da0ab993921d..b0bbaf016b8d 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -112,40 +112,18 @@ static int __hfs_bnode_read_u8(struct hfs_bnode *node, u8* buf, u16 off)
 
 void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)
 {
-	struct page *page;
-	int pagenum;
-	int bytes_read;
-	int bytes_to_read;
-
-	if (!is_bnode_offset_valid(node, off))
-		return;
+	int res;
 
-	if (len == 0) {
-		pr_err("requested zero length: "
+	len = check_and_correct_requested_length(node, off, len);
+	res = __hfs_bnode_read(node, buf, (u16)off, (u16)len);
+	if (res) {
+		pr_err("hfs_bnode_read error: "
 		       "NODE: id %u, type %#x, height %u, "
 		       "node_size %u, offset %d, len %d\n",
 		       node->this, node->type, node->height,
 		       node->tree->node_size, off, len);
-		return;
-	}
-
-	len = check_and_correct_requested_length(node, off, len);
-
-	off += node->page_offset;
-	pagenum = off >> PAGE_SHIFT;
-	off &= ~PAGE_MASK; /* compute page offset for the first page */
-
-	for (bytes_read = 0; bytes_read < len; bytes_read += bytes_to_read) {
-		if (pagenum >= node->tree->pages_per_bnode)
-			break;
-		page = node->page[pagenum];
-		bytes_to_read = min_t(int, len - bytes_read, PAGE_SIZE - off);
-
-		memcpy_from_page(buf + bytes_read, page, off, bytes_to_read);
-
-		pagenum++;
-		off = 0; /* page offset only applies to the first page */
 	}
+	return;
 }
 
 u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ