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]
Date:   Tue, 8 Nov 2022 22:46:10 +0800
From:   Zhang Yi <yi.zhang@...wei.com>
To:     <linux-ext4@...r.kernel.org>
CC:     <tytso@....edu>, <adilger.kernel@...ger.ca>, <jack@...e.cz>,
        <yi.zhang@...wei.com>, <yukuai3@...wei.com>
Subject: [PATCH 05/12] ext4: add inode I/O fault injection

Add I/O fault injection when reading raw inode from disk, we can
specify the inode to inject, __ext4_get_inode_loc() will return -EIO
immediately instead of submitting I/O, note that it doesn't handle
the readhead case.

Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
---
 fs/ext4/ext4.h  |  2 ++
 fs/ext4/inode.c | 18 ++++++++++++------
 fs/ext4/sysfs.c |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 589d901e8946..29a819a186f7 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1521,6 +1521,7 @@ enum ext4_fault_bits {
 	/* inject metadata IO error*/
 	EXT4_FAULT_IBITMAP_EIO,		/* inode bitmap block */
 	EXT4_FAULT_BBITMAP_EIO,		/* block bitmap block */
+	EXT4_FAULT_INODE_EIO,		/* inode */
 	EXT4_FAULT_MAX
 };
 
@@ -1622,6 +1623,7 @@ EXT4_FAULT_INODE_FN(XATTR_CSUM, xattr_csum, 1)
 
 EXT4_FAULT_GRP_FN(IBITMAP_EIO, inode_bitmap_io, -EIO)
 EXT4_FAULT_GRP_FN(BBITMAP_EIO, block_bitmap_io, -EIO)
+EXT4_FAULT_INODE_FN(INODE_EIO, inode_io, -EIO)
 
 /*
  * fourth extended-fs super-block data in memory
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8bfbc8d100b4..8c611ad6dac1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4570,19 +4570,25 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
 	 * Read the block from disk.
 	 */
 	trace_ext4_load_inode(sb, ino);
+	if (ext4_fault_inode_io(sb, ino)) {
+		unlock_buffer(bh);
+		blk_finish_plug(&plug);
+		goto err;
+	}
 	ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO, NULL);
 	blk_finish_plug(&plug);
 	wait_on_buffer(bh);
 	ext4_simulate_fail_bh(sb, bh, EXT4_SIM_INODE_EIO);
-	if (!buffer_uptodate(bh)) {
-		if (ret_block)
-			*ret_block = block;
-		brelse(bh);
-		return -EIO;
-	}
+	if (!buffer_uptodate(bh))
+		goto err;
 has_buffer:
 	iloc->bh = bh;
 	return 0;
+err:
+	if (ret_block)
+		*ret_block = block;
+	brelse(bh);
+	return -EIO;
 }
 
 static int __ext4_get_inode_loc_noinmem(struct inode *inode,
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 638892046dc8..9c6d9a212d47 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -580,6 +580,7 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = {
 	"xattr_block_checksum",		/* EXT4_FAULT_XATTR_CSUM */
 	"inode_bitmap_eio",		/* EXT4_FAULT_IBITMAP_EIO */
 	"block_bitmap_eio",		/* EXT4_FAULT_BBITMAP_EIO */
+	"inode_eio",			/* EXT4_FAULT_INODE_EIO */
 };
 
 static int ext4_fault_available_show(struct seq_file *m, void *v)
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ