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]
Date:	Mon, 17 Nov 2014 20:31:08 +0400
From:	Konstantin Khlebnikov <k.khlebnikov@...sung.com>
To:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Alexander Viro <viro@...iv.linux.org.uk>
Cc:	koct9i@...il.com
Subject: [PATCH RFC] fs: check and toss errors returned by ->sync_fs

->ssync_fs returns int but the result is always ignored silently.
Of course syscall sync is declared as void and it writes multiple
fs thus returning error codes here is impossible and meaningless.
But recently added syscall syncfs writes only one filesystem, it
returns int but only -EBADF is documented for now.

After this patch sync_filesystem() and syscall syncfs returns these
error codes. Also they will skip waiting if somebody returned -EIO,
the same logic is used in filemap_write_and_wait().

Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@...sung.com>
---
 fs/sync.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index bdc729d..e2c3622 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -29,14 +29,21 @@
  */
 static int __sync_filesystem(struct super_block *sb, int wait)
 {
+	int ret = 0, ret2;
+
 	if (wait)
 		sync_inodes_sb(sb);
 	else
 		writeback_inodes_sb(sb, WB_REASON_SYNC);
 
 	if (sb->s_op->sync_fs)
-		sb->s_op->sync_fs(sb, wait);
-	return __sync_blockdev(sb->s_bdev, wait);
+		ret = sb->s_op->sync_fs(sb, wait);
+
+	ret2 = __sync_blockdev(sb->s_bdev, wait);
+	if (!ret)
+		ret = ret2;
+
+	return ret;
 }
 
 /*
@@ -46,7 +53,7 @@ static int __sync_filesystem(struct super_block *sb, int wait)
  */
 int sync_filesystem(struct super_block *sb)
 {
-	int ret;
+	int ret, ret2;
 
 	/*
 	 * We need to be protected against the filesystem going from
@@ -61,9 +68,18 @@ int sync_filesystem(struct super_block *sb)
 		return 0;
 
 	ret = __sync_filesystem(sb, 0);
-	if (ret < 0)
+	/*
+	 * EIO may indicate the worst thing: bug or hardware failure.
+	 * In other cases it's better to wait for partially written data.
+	 */
+	if (ret == -EIO)
 		return ret;
-	return __sync_filesystem(sb, 1);
+
+	ret2 = __sync_filesystem(sb, 1);
+	if (!ret)
+		ret = ret2;
+
+	return ret;
 }
 EXPORT_SYMBOL(sync_filesystem);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists