eCryptfs: Clear buffer before reading in metadata xattr

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, April 19, 2010 - 4:59 pm

Gitweb:     http://git.kernel.org/linus/1984c23f9e0cdb432d90a85ecf88b424d36878fc
Commit:     1984c23f9e0cdb432d90a85ecf88b424d36878fc
Parent:     fa3ef1cb4e6e9958a9bfaa977c107c515907f102
Author:     Tyler Hicks <tyhicks@linux.vnet.ibm.com>
AuthorDate: Wed Feb 10 23:17:44 2010 -0600
Committer:  Tyler Hicks <tyhicks@linux.vnet.ibm.com>
CommitDate: Tue Mar 23 12:31:09 2010 -0500

    eCryptfs: Clear buffer before reading in metadata xattr
    
    We initially read in the first PAGE_CACHE_SIZE of a file to if the
    eCryptfs header marker can be found.  If it isn't found and
    ecryptfs_xattr_metadata was given as a mount option, then the
    user.ecryptfs xattr is read into the same buffer.  Since the data from
    the first page of the file wasn't cleared, it is possible that we think
    we've found a second tag 3 or tag 1 packet and then error out after the
    packet contents aren't as expected.  This patch clears the buffer before
    filling it with metadata from the user.ecryptfs xattr.
    
    Reviewed-by: Eric Sandeen <sandeen@redhat.com>
    Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
---
 fs/ecryptfs/crypto.c |    1 +
 fs/ecryptfs/inode.c  |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 391f558..4d9db0e 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1603,6 +1603,7 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
 						ecryptfs_dentry,
 						ECRYPTFS_VALIDATE_HEADER_SIZE);
 	if (rc) {
+		memset(page_virt, 0, PAGE_CACHE_SIZE);
 		rc = ecryptfs_read_xattr_region(page_virt, ecryptfs_inode);
 		if (rc) {
 			printk(KERN_DEBUG "Valid eCryptfs headers not found in "
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index a50efb1..ddbd096 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -323,6 +323,7 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
 	rc = ecryptfs_read_and_validate_header_region(page_virt,
 						      ecryptfs_dentry->d_inode);
 	if (rc) {
+		memset(page_virt, 0, PAGE_CACHE_SIZE);
 		rc = ecryptfs_read_and_validate_xattr_region(page_virt,
 							     ecryptfs_dentry);
 		if (rc) {
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
eCryptfs: Clear buffer before reading in metadata xattr, Linux Kernel Mailing ..., (Mon Apr 19, 4:59 pm)