Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/ecryptfs/ecryptfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs/ecryptfs-2.6:
  eCryptfs: write lock requested keys
  eCryptfs: move ecryptfs_find_auth_tok_for_sig() call before mutex_lock
  eCryptfs: verify authentication tokens before their use
  eCryptfs: modified size of keysig in the ecryptfs_key_sig structure
  eCryptfs: removed num_global_auth_toks from ecryptfs_mount_crypt_stat
  eCryptfs: ecryptfs_keyring_auth_tok_for_sig() bug fix
  eCryptfs: Unlock page in write_begin error path
  ecryptfs: modify write path to encrypt page in writepage
  eCryptfs: Remove ECRYPTFS_NEW_FILE crypt stat flag
  eCryptfs: Remove unnecessary grow_file() function
  • Loading branch information
Linus Torvalds committed Mar 28, 2011
2 parents 212a17a + b5695d0 commit 7f5fe3e
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 188 deletions.
2 changes: 1 addition & 1 deletion fs/ecryptfs/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void ecryptfs_destroy_mount_crypt_stat(
&mount_crypt_stat->global_auth_tok_list,
mount_crypt_stat_list) {
list_del(&auth_tok->mount_crypt_stat_list);
mount_crypt_stat->num_global_auth_toks--;
if (auth_tok->global_auth_tok_key
&& !(auth_tok->flags & ECRYPTFS_AUTH_TOK_INVALID))
key_put(auth_tok->global_auth_tok_key);
Expand Down Expand Up @@ -1389,6 +1388,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry)
rc = -ENOMEM;
goto out;
}
/* Zeroed page ensures the in-header unencrypted i_size is set to 0 */
rc = ecryptfs_write_headers_virt(virt, virt_len, &size, crypt_stat,
ecryptfs_dentry);
if (unlikely(rc)) {
Expand Down
30 changes: 13 additions & 17 deletions fs/ecryptfs/ecryptfs_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ ecryptfs_get_key_payload_data(struct key *key)

struct ecryptfs_key_sig {
struct list_head crypt_stat_list;
char keysig[ECRYPTFS_SIG_SIZE_HEX];
char keysig[ECRYPTFS_SIG_SIZE_HEX + 1];
};

struct ecryptfs_filename {
Expand All @@ -257,19 +257,18 @@ struct ecryptfs_filename {
struct ecryptfs_crypt_stat {
#define ECRYPTFS_STRUCT_INITIALIZED 0x00000001
#define ECRYPTFS_POLICY_APPLIED 0x00000002
#define ECRYPTFS_NEW_FILE 0x00000004
#define ECRYPTFS_ENCRYPTED 0x00000008
#define ECRYPTFS_SECURITY_WARNING 0x00000010
#define ECRYPTFS_ENABLE_HMAC 0x00000020
#define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000040
#define ECRYPTFS_KEY_VALID 0x00000080
#define ECRYPTFS_METADATA_IN_XATTR 0x00000100
#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200
#define ECRYPTFS_KEY_SET 0x00000400
#define ECRYPTFS_ENCRYPT_FILENAMES 0x00000800
#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00001000
#define ECRYPTFS_ENCFN_USE_FEK 0x00002000
#define ECRYPTFS_UNLINK_SIGS 0x00004000
#define ECRYPTFS_ENCRYPTED 0x00000004
#define ECRYPTFS_SECURITY_WARNING 0x00000008
#define ECRYPTFS_ENABLE_HMAC 0x00000010
#define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000020
#define ECRYPTFS_KEY_VALID 0x00000040
#define ECRYPTFS_METADATA_IN_XATTR 0x00000080
#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000100
#define ECRYPTFS_KEY_SET 0x00000200
#define ECRYPTFS_ENCRYPT_FILENAMES 0x00000400
#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800
#define ECRYPTFS_ENCFN_USE_FEK 0x00001000
#define ECRYPTFS_UNLINK_SIGS 0x00002000
u32 flags;
unsigned int file_version;
size_t iv_bytes;
Expand Down Expand Up @@ -297,7 +296,6 @@ struct ecryptfs_inode_info {
struct inode vfs_inode;
struct inode *wii_inode;
struct file *lower_file;
struct mutex lower_file_mutex;
struct ecryptfs_crypt_stat crypt_stat;
};

Expand Down Expand Up @@ -333,7 +331,6 @@ struct ecryptfs_global_auth_tok {
u32 flags;
struct list_head mount_crypt_stat_list;
struct key *global_auth_tok_key;
struct ecryptfs_auth_tok *global_auth_tok;
unsigned char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
};

Expand Down Expand Up @@ -380,7 +377,6 @@ struct ecryptfs_mount_crypt_stat {
u32 flags;
struct list_head global_auth_tok_list;
struct mutex global_auth_tok_list_mutex;
size_t num_global_auth_toks;
size_t global_default_cipher_key_size;
size_t global_default_fn_cipher_key_bytes;
unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE
Expand Down
9 changes: 8 additions & 1 deletion fs/ecryptfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
static int
ecryptfs_fsync(struct file *file, int datasync)
{
return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
int rc = 0;

rc = generic_file_fsync(file, datasync);
if (rc)
goto out;
rc = vfs_fsync(ecryptfs_file_to_lower(file), datasync);
out:
return rc;
}

static int ecryptfs_fasync(int fd, struct file *file, int flag)
Expand Down
24 changes: 0 additions & 24 deletions fs/ecryptfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,6 @@ ecryptfs_do_create(struct inode *directory_inode,
return rc;
}

/**
* grow_file
* @ecryptfs_dentry: the eCryptfs dentry
*
* This is the code which will grow the file to its correct size.
*/
static int grow_file(struct dentry *ecryptfs_dentry)
{
struct inode *ecryptfs_inode = ecryptfs_dentry->d_inode;
char zero_virt[] = { 0x00 };
int rc = 0;

rc = ecryptfs_write(ecryptfs_inode, zero_virt, 0, 1);
i_size_write(ecryptfs_inode, 0);
rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode);
ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat.flags |=
ECRYPTFS_NEW_FILE;
return rc;
}

/**
* ecryptfs_initialize_file
*
Expand All @@ -181,7 +161,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
goto out;
}
crypt_stat->flags |= ECRYPTFS_NEW_FILE;
ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n");
rc = ecryptfs_new_file_context(ecryptfs_dentry);
if (rc) {
Expand All @@ -202,9 +181,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
goto out;
}
rc = grow_file(ecryptfs_dentry);
if (rc)
printk(KERN_ERR "Error growing file; rc = [%d]\n", rc);
out:
return rc;
}
Expand Down
Loading

0 comments on commit 7f5fe3e

Please sign in to comment.