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]
Message-Id: <1326301242-5817-2-git-send-email-tim.gardner@canonical.com>
Date:	Wed, 11 Jan 2012 18:00:41 +0100
From:	Tim Gardner <tim.gardner@...onical.com>
To:	linux-fsdevel@...r.kernel.org, tyler.hicks@...onical.com
Cc:	Tim Gardner <tim.gardner@...onical.com>,
	linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: [PATCH 1/2] ecryptfs: Improve metatdata read failure logging

There are 3 read failure cases in ecryptfs_read_metadata(), but only 2
of them are uniquely noted by kernel log messages. This patch
identifies and logs each read failure case. It also correctly interprets
a negative return value from ecryptfs_read_lower().

Removes unnecessary variable initialization.

Cc: linux-kernel@...r.kernel.org
Cc: stable@...r.kernel.org
Cc: Tyler Hicks <tyler.hicks@...onical.com>
Signed-off-by: Tim Gardner <tim.gardner@...onical.com>
---
 fs/ecryptfs/crypto.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index d3c8776..ac063bd 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1590,8 +1590,8 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
  */
 int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
 {
-	int rc = 0;
-	char *page_virt = NULL;
+	int rc;
+	char *page_virt;
 	struct inode *ecryptfs_inode = ecryptfs_dentry->d_inode;
 	struct ecryptfs_crypt_stat *crypt_stat =
 	    &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
@@ -1611,10 +1611,15 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
 	}
 	rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size,
 				 ecryptfs_inode);
-	if (rc >= 0)
-		rc = ecryptfs_read_headers_virt(page_virt, crypt_stat,
-						ecryptfs_dentry,
-						ECRYPTFS_VALIDATE_HEADER_SIZE);
+	if (rc < 0) {
+		printk(KERN_ERR "%s: Could not read %u bytes\n",
+			__func__, crypt_stat->extent_size);
+		goto out;
+	}
+
+	rc = ecryptfs_read_headers_virt(page_virt, crypt_stat,
+					ecryptfs_dentry,
+					ECRYPTFS_VALIDATE_HEADER_SIZE);
 	if (rc) {
 		memset(page_virt, 0, PAGE_CACHE_SIZE);
 		rc = ecryptfs_read_xattr_region(page_virt, ecryptfs_inode);
-- 
1.7.8.3

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ