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>] [day] [month] [year] [list]
Message-Id: <20230502124103.428884-1-srivathsa.d.dara@oracle.com>
Date:   Tue,  2 May 2023 12:41:04 +0000
From:   Srivathsa Dara <srivathsa.d.dara@...cle.com>
To:     linux-ext4@...r.kernel.org
Cc:     rajesh.sivaramasubramaniom@...cle.com, junxiao.bi@...cle.com,
        srivathsa.d.dara@...cle.com
Subject: [PATCH] debugfs/htree.c: In do_dx_hash() read hash_seed, hash_version directly from superblock

debugfs hash command computes the hash for the given filename. It takes
hash_seed and hash_version (i.e hash algorithm) as arguments. User has
to refer to the superblock to get these values used by the filesystem.
If the arguments are not given then debugfs computes hash assuming both
hash_seed and hash_version are zeros. In most of the cases this assumption
will be different from the actual hash_seed and hash_version used by the
filesystem. In general user will be in need of hash computed from
hash_seed and hash_version of the filesystem. So, instead of assuming
hash_seed and hash_version as zero when the arguments are not provided,
read these directly from the superblock to simplify the task of user.

Example:
Before:-
debugfs:  hash -s 524e5394-e2a3-43fa-b192-79720b1fe3e1 -h half_md4 file1
Hash of file1 is 0x4a8d8c94 (minor 0x17a37f43)

After improvement:-
debugfs:  hash file1
Hash of file1 is 0x4a8d8c94 (minor 0x17a37f43)

Signed-off-by: Srivathsa Dara <srivathsa.d.dara@...cle.com>
---
 debugfs/htree.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/debugfs/htree.c b/debugfs/htree.c
index 7fae7f11..2d881c74 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -316,7 +316,12 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
 	int		hash_flags = 0;
 	const struct ext2fs_nls_table *encoding = NULL;
 
-	hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0;
+	hash_seed[0] = current_fs->super->s_hash_seed[0];
+	hash_seed[1] = current_fs->super->s_hash_seed[1];
+	hash_seed[2] = current_fs->super->s_hash_seed[2];
+	hash_seed[3] = current_fs->super->s_hash_seed[3];
+
+	hash_version = current_fs->super->s_def_hash_version;
 
 	reset_getopt();
 	while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) {
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ