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]
Date:   Thu, 2 Aug 2018 20:06:46 +0200
From:   Jaco Kroon <jaco@....co.za>
To:     linux-ext4 <linux-ext4@...r.kernel.org>
Subject: [PATCH] debugfs/ncheck:  find all names for given inodes

Due to hard links inodes can have multiple names (except for folders),
ncheck should find all of the names (equal to the number of links to the
inodes, directories excepted), not names to the count of the provided
inodes.

Signed-off-by: Jaco Kroon <jaco@....co.za>
---
 debugfs/ncheck.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c
index dc4ab56d..158e8658 100644
--- a/debugfs/ncheck.c
+++ b/debugfs/ncheck.c
@@ -28,7 +28,7 @@ extern char *optarg;
 struct inode_walk_struct {
 	ext2_ino_t		dir;
 	ext2_ino_t		*iarray;
-	int			inodes_left;
+	int			names_left;
 	int			num_inodes;
 	int			position;
 	char			*parent;
@@ -81,10 +81,10 @@ static int ncheck_proc(struct ext2_dir_entry *dirent,
 				}
 			}
 			putc('\n', stdout);
-			iw->inodes_left--;
+			iw->names_left--;
 		}
 	}
-	if (!iw->inodes_left)
+	if (!iw->names_left)
 		return DIRENT_ABORT;
 
 	return 0;
@@ -131,15 +131,22 @@ void do_ncheck(int argc, char **argv)
 	}
 	memset(iw.iarray, 0, sizeof(ext2_ino_t) * argc);
 
+	iw.names_left = 0;
 	for (i=0; i < argc; i++) {
 		iw.iarray[i] = strtol(argv[i], &tmp, 0);
 		if (*tmp) {
 			com_err("ncheck", 0, "Bad inode - %s", argv[i]);
 			goto error_out;
 		}
+		if (debugfs_read_inode(iw.iarray[i], &inode, *argv))
+			goto error_out;
+		if (LINUX_S_ISDIR(inode.i_mode))
+			iw.names_left += 1;
+		else
+			iw.names_left += inode.i_links_count;
 	}
 
-	iw.num_inodes = iw.inodes_left = argc;
+	iw.num_inodes = argc;
 
 	retval = ext2fs_open_inode_scan(current_fs, 0, &scan);
 	if (retval) {
@@ -183,7 +190,7 @@ void do_ncheck(int argc, char **argv)
 			goto next;
 		}
 
-		if (iw.inodes_left == 0)
+		if (iw.names_left == 0)
 			break;
 
 	next:
-- 
2.16.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ