lkml.org 
[lkml]   [2006]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] eCryptfs: readdir fix for seeking in directory streams
The lower file's f_pos needs to be set to the f_pos of the eCryptfs
file passed into readdir() in order to correctly handle seeks on
directory streams.

This patch also properly initializes the file_info struct to all
0's. This initialization is not strictly necessary for the code as it
is currently in the kernel, but without this patch, nasty bugs can
show up when anyone makes changes to the file_info struct (one such
future change may include a pointer to persistent directory read state
info).

Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>

---

fs/ecryptfs/file.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)

1824c175c78c15138a900aa4e05fd29af21d4de1
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 53dd53d..1cc2cc0 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -144,7 +144,6 @@ ecryptfs_filldir(void *dirent, const cha
int decoded_length;
char *decoded_name;

-
crypt_stat = ecryptfs_dentry_to_private(buf->dentry)->crypt_stat;
buf->filldir_called++;
decoded_length = ecryptfs_decode_filename(crypt_stat, name, namelen,
@@ -176,6 +175,7 @@ static int ecryptfs_readdir(struct file
struct ecryptfs_getdents_callback buf;

lower_file = ecryptfs_file_to_lower(file);
+ lower_file->f_pos = file->f_pos;
inode = file->f_dentry->d_inode;
memset(&buf, 0, sizeof(buf));
buf.dirent = dirent;
@@ -218,18 +218,19 @@ static int ecryptfs_open(struct inode *i
struct inode *lower_inode = NULL;
struct file *lower_file = NULL;
struct vfsmount *lower_mnt;
+ struct ecryptfs_file_info *file_info;
int lower_flags;

/* Released in ecryptfs_release or end of function if failure */
- ecryptfs_set_file_private(file,
- kmem_cache_alloc(ecryptfs_file_info_cache,
- SLAB_KERNEL));
- if (!ecryptfs_file_to_private(file)) {
+ file_info = kmem_cache_alloc(ecryptfs_file_info_cache, SLAB_KERNEL);
+ ecryptfs_set_file_private(file, file_info);
+ if (!file_info) {
ecryptfs_printk(KERN_ERR,
"Error attempting to allocate memory\n");
rc = -ENOMEM;
goto out;
}
+ memset(file_info, 0, sizeof(*file_info));
lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
mutex_lock(&crypt_stat->cs_mutex);
--
1.3.3
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-09-25 22:53    [W:0.029 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site