aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 21:52:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-19 21:52:29 -0400
commit3c2de27d793bf55167804fc47954711e94f27be7 (patch)
treeb554e41e350adc47cf983b3103f4b4b79451f67b /fs/ecryptfs
parent51b3eae8dbe5e6fa9657b21388ad6642d6934952 (diff)
parent8b23a8ce1094f25a85826e25217c5b9779a4f5aa (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: - Preparations of parallel lookups (the remaining main obstacle is the need to move security_d_instantiate(); once that becomes safe, the rest will be a matter of rather short series local to fs/*.c - preadv2/pwritev2 series from Christoph - assorted fixes * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (32 commits) splice: handle zero nr_pages in splice_to_pipe() vfs: show_vfsstat: do not ignore errors from show_devname method dcache.c: new helper: __d_add() don't bother with __d_instantiate(dentry, NULL) untangle fsnotify_d_instantiate() a bit uninline d_add() replace d_add_unique() with saner primitive quota: use lookup_one_len_unlocked() cifs_get_root(): use lookup_one_len_unlocked() nfs_lookup: don't bother with d_instantiate(dentry, NULL) kill dentry_unhash() ceph_fill_trace(): don't bother with d_instantiate(dn, NULL) autofs4: don't bother with d_instantiate(dentry, NULL) in ->lookup() configfs: move d_rehash() into configfs_create() for regular files ceph: don't bother with d_rehash() in splice_dentry() namei: teach lookup_slow() to skip revalidate namei: massage lookup_slow() to be usable by lookup_one_len_unlocked() lookup_one_len_unlocked(): use lookup_dcache() namei: simplify invalidation logics in lookup_dcache() namei: change calling conventions for lookup_{fast,slow} and follow_managed() ...
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r--fs/ecryptfs/crypto.c27
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h1
-rw-r--r--fs/ecryptfs/inode.c11
3 files changed, 12 insertions, 27 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 11255cbcb2db..64026e53722a 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1492,16 +1492,14 @@ out:
1492 */ 1492 */
1493static int 1493static int
1494ecryptfs_encrypt_filename(struct ecryptfs_filename *filename, 1494ecryptfs_encrypt_filename(struct ecryptfs_filename *filename,
1495 struct ecryptfs_crypt_stat *crypt_stat,
1496 struct ecryptfs_mount_crypt_stat *mount_crypt_stat) 1495 struct ecryptfs_mount_crypt_stat *mount_crypt_stat)
1497{ 1496{
1498 int rc = 0; 1497 int rc = 0;
1499 1498
1500 filename->encrypted_filename = NULL; 1499 filename->encrypted_filename = NULL;
1501 filename->encrypted_filename_size = 0; 1500 filename->encrypted_filename_size = 0;
1502 if ((crypt_stat && (crypt_stat->flags & ECRYPTFS_ENCFN_USE_MOUNT_FNEK)) 1501 if (mount_crypt_stat && (mount_crypt_stat->flags
1503 || (mount_crypt_stat && (mount_crypt_stat->flags 1502 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK)) {
1504 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))) {
1505 size_t packet_size; 1503 size_t packet_size;
1506 size_t remaining_bytes; 1504 size_t remaining_bytes;
1507 1505
@@ -1933,7 +1931,6 @@ out:
1933int ecryptfs_encrypt_and_encode_filename( 1931int ecryptfs_encrypt_and_encode_filename(
1934 char **encoded_name, 1932 char **encoded_name,
1935 size_t *encoded_name_size, 1933 size_t *encoded_name_size,
1936 struct ecryptfs_crypt_stat *crypt_stat,
1937 struct ecryptfs_mount_crypt_stat *mount_crypt_stat, 1934 struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
1938 const char *name, size_t name_size) 1935 const char *name, size_t name_size)
1939{ 1936{
@@ -1942,9 +1939,8 @@ int ecryptfs_encrypt_and_encode_filename(
1942 1939
1943 (*encoded_name) = NULL; 1940 (*encoded_name) = NULL;
1944 (*encoded_name_size) = 0; 1941 (*encoded_name_size) = 0;
1945 if ((crypt_stat && (crypt_stat->flags & ECRYPTFS_ENCRYPT_FILENAMES)) 1942 if (mount_crypt_stat && (mount_crypt_stat->flags
1946 || (mount_crypt_stat && (mount_crypt_stat->flags 1943 & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
1947 & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES))) {
1948 struct ecryptfs_filename *filename; 1944 struct ecryptfs_filename *filename;
1949 1945
1950 filename = kzalloc(sizeof(*filename), GFP_KERNEL); 1946 filename = kzalloc(sizeof(*filename), GFP_KERNEL);
@@ -1957,8 +1953,7 @@ int ecryptfs_encrypt_and_encode_filename(
1957 } 1953 }
1958 filename->filename = (char *)name; 1954 filename->filename = (char *)name;
1959 filename->filename_size = name_size; 1955 filename->filename_size = name_size;
1960 rc = ecryptfs_encrypt_filename(filename, crypt_stat, 1956 rc = ecryptfs_encrypt_filename(filename, mount_crypt_stat);
1961 mount_crypt_stat);
1962 if (rc) { 1957 if (rc) {
1963 printk(KERN_ERR "%s: Error attempting to encrypt " 1958 printk(KERN_ERR "%s: Error attempting to encrypt "
1964 "filename; rc = [%d]\n", __func__, rc); 1959 "filename; rc = [%d]\n", __func__, rc);
@@ -1969,11 +1964,9 @@ int ecryptfs_encrypt_and_encode_filename(
1969 NULL, &encoded_name_no_prefix_size, 1964 NULL, &encoded_name_no_prefix_size,
1970 filename->encrypted_filename, 1965 filename->encrypted_filename,
1971 filename->encrypted_filename_size); 1966 filename->encrypted_filename_size);
1972 if ((crypt_stat && (crypt_stat->flags 1967 if (mount_crypt_stat
1973 & ECRYPTFS_ENCFN_USE_MOUNT_FNEK))
1974 || (mount_crypt_stat
1975 && (mount_crypt_stat->flags 1968 && (mount_crypt_stat->flags
1976 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))) 1969 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))
1977 (*encoded_name_size) = 1970 (*encoded_name_size) =
1978 (ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 1971 (ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE
1979 + encoded_name_no_prefix_size); 1972 + encoded_name_no_prefix_size);
@@ -1991,11 +1984,9 @@ int ecryptfs_encrypt_and_encode_filename(
1991 kfree(filename); 1984 kfree(filename);
1992 goto out; 1985 goto out;
1993 } 1986 }
1994 if ((crypt_stat && (crypt_stat->flags 1987 if (mount_crypt_stat
1995 & ECRYPTFS_ENCFN_USE_MOUNT_FNEK))
1996 || (mount_crypt_stat
1997 && (mount_crypt_stat->flags 1988 && (mount_crypt_stat->flags
1998 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))) { 1989 & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK)) {
1999 memcpy((*encoded_name), 1990 memcpy((*encoded_name),
2000 ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX, 1991 ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX,
2001 ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE); 1992 ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE);
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index b7f81287c688..d123fbaa28e0 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -569,7 +569,6 @@ int ecryptfs_fill_zeros(struct file *file, loff_t new_length);
569int ecryptfs_encrypt_and_encode_filename( 569int ecryptfs_encrypt_and_encode_filename(
570 char **encoded_name, 570 char **encoded_name,
571 size_t *encoded_name_size, 571 size_t *encoded_name_size,
572 struct ecryptfs_crypt_stat *crypt_stat,
573 struct ecryptfs_mount_crypt_stat *mount_crypt_stat, 572 struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
574 const char *name, size_t name_size); 573 const char *name, size_t name_size);
575struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry); 574struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 0a8f1b469a63..121114e9a464 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -396,11 +396,9 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
396 int rc = 0; 396 int rc = 0;
397 397
398 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); 398 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
399 inode_lock(d_inode(lower_dir_dentry)); 399 lower_dentry = lookup_one_len_unlocked(ecryptfs_dentry->d_name.name,
400 lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
401 lower_dir_dentry, 400 lower_dir_dentry,
402 ecryptfs_dentry->d_name.len); 401 ecryptfs_dentry->d_name.len);
403 inode_unlock(d_inode(lower_dir_dentry));
404 if (IS_ERR(lower_dentry)) { 402 if (IS_ERR(lower_dentry)) {
405 rc = PTR_ERR(lower_dentry); 403 rc = PTR_ERR(lower_dentry);
406 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 404 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -418,18 +416,16 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
418 dput(lower_dentry); 416 dput(lower_dentry);
419 rc = ecryptfs_encrypt_and_encode_filename( 417 rc = ecryptfs_encrypt_and_encode_filename(
420 &encrypted_and_encoded_name, &encrypted_and_encoded_name_size, 418 &encrypted_and_encoded_name, &encrypted_and_encoded_name_size,
421 NULL, mount_crypt_stat, ecryptfs_dentry->d_name.name, 419 mount_crypt_stat, ecryptfs_dentry->d_name.name,
422 ecryptfs_dentry->d_name.len); 420 ecryptfs_dentry->d_name.len);
423 if (rc) { 421 if (rc) {
424 printk(KERN_ERR "%s: Error attempting to encrypt and encode " 422 printk(KERN_ERR "%s: Error attempting to encrypt and encode "
425 "filename; rc = [%d]\n", __func__, rc); 423 "filename; rc = [%d]\n", __func__, rc);
426 goto out; 424 goto out;
427 } 425 }
428 inode_lock(d_inode(lower_dir_dentry)); 426 lower_dentry = lookup_one_len_unlocked(encrypted_and_encoded_name,
429 lower_dentry = lookup_one_len(encrypted_and_encoded_name,
430 lower_dir_dentry, 427 lower_dir_dentry,
431 encrypted_and_encoded_name_size); 428 encrypted_and_encoded_name_size);
432 inode_unlock(d_inode(lower_dir_dentry));
433 if (IS_ERR(lower_dentry)) { 429 if (IS_ERR(lower_dentry)) {
434 rc = PTR_ERR(lower_dentry); 430 rc = PTR_ERR(lower_dentry);
435 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 431 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -501,7 +497,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
501 dir->i_sb)->mount_crypt_stat; 497 dir->i_sb)->mount_crypt_stat;
502 rc = ecryptfs_encrypt_and_encode_filename(&encoded_symname, 498 rc = ecryptfs_encrypt_and_encode_filename(&encoded_symname,
503 &encoded_symlen, 499 &encoded_symlen,
504 NULL,
505 mount_crypt_stat, symname, 500 mount_crypt_stat, symname,
506 strlen(symname)); 501 strlen(symname));
507 if (rc) 502 if (rc)