Skip to content

Commit a5e1c3b

Browse files
committed
Merge tag 'ecryptfs-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs
Pull eCryptfs updates from Tyler Hicks: - avoid unnecessary eCryptfs inode timestamp truncation by re-using the lower filesystem's time granularity - various small code cleanups - reorganize the setattr hook inode resizing to improve style and readability, remove an unnecessary memory allocation when shrinking, and to support an upcoming rework of the VFS interfaces involved in truncation * tag 'ecryptfs-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: ecryptfs: keep the lower iattr contained in truncate_upper ecryptfs: factor out a ecryptfs_iattr_to_lower helper ecryptfs: merge ecryptfs_inode_newsize_ok into truncate_upper ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr ecryptfs: use ZERO_PAGE instead of allocating zeroed memory in truncate_upper ecryptfs: streamline truncate_upper ecryptfs: cleanup ecryptfs_setattr ecryptfs: Drop TODO comment in ecryptfs_derive_iv ecryptfs: Fix typo in ecryptfs_derive_iv function comment ecryptfs: Log function name only once in decode_and_decrypt_filename ecryptfs: Remove redundant if checks in encrypt_and_encode_filename ecryptfs: Fix tag number in encrypt_filename() error message ecryptfs: Use struct_size to improve process_response + send_miscdev ecryptfs: Replace memcpy + manual NUL termination with strscpy ecryptfs: Set s_time_gran to get correct time granularity
2 parents 36d179f + e836ec1 commit a5e1c3b

7 files changed

Lines changed: 142 additions & 173 deletions

File tree

fs/ecryptfs/crypto.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
7272

7373
/**
7474
* ecryptfs_derive_iv
75-
* @iv: destination for the derived iv vale
75+
* @iv: destination for the derived iv value
7676
* @crypt_stat: Pointer to crypt_stat struct for the current inode
7777
* @offset: Offset of the extent whose IV we are to derive
7878
*
@@ -89,10 +89,6 @@ void ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat,
8989
ecryptfs_printk(KERN_DEBUG, "root iv:\n");
9090
ecryptfs_dump_hex(crypt_stat->root_iv, crypt_stat->iv_bytes);
9191
}
92-
/* TODO: It is probably secure to just cast the least
93-
* significant bits of the root IV into an unsigned long and
94-
* add the offset to that rather than go through all this
95-
* hashing business. -Halcrow */
9692
memcpy(src, crypt_stat->root_iv, crypt_stat->iv_bytes);
9793
memset((src + crypt_stat->iv_bytes), 0, 16);
9894
snprintf((src + crypt_stat->iv_bytes), 16, "%lld", offset);
@@ -1376,9 +1372,9 @@ ecryptfs_encrypt_filename(struct ecryptfs_filename *filename,
13761372
mount_crypt_stat, NULL,
13771373
filename->filename_size);
13781374
if (rc) {
1379-
printk(KERN_ERR "%s: Error attempting to get packet "
1380-
"size for tag 72; rc = [%d]\n", __func__,
1381-
rc);
1375+
ecryptfs_printk(KERN_ERR,
1376+
"Error attempting to get packet size for tag 70; rc = [%d]\n",
1377+
rc);
13821378
filename->encrypted_filename_size = 0;
13831379
goto out;
13841380
}
@@ -1802,18 +1798,18 @@ int ecryptfs_encrypt_and_encode_filename(
18021798
filename->filename_size = name_size;
18031799
rc = ecryptfs_encrypt_filename(filename, mount_crypt_stat);
18041800
if (rc) {
1805-
printk(KERN_ERR "%s: Error attempting to encrypt "
1806-
"filename; rc = [%d]\n", __func__, rc);
1801+
ecryptfs_printk(KERN_ERR,
1802+
"Error attempting to encrypt filename; rc = [%d]\n",
1803+
rc);
18071804
kfree(filename);
18081805
goto out;
18091806
}
18101807
ecryptfs_encode_for_filename(
18111808
NULL, &encoded_name_no_prefix_size,
18121809
filename->encrypted_filename,
18131810
filename->encrypted_filename_size);
1814-
if (mount_crypt_stat
1815-
&& (mount_crypt_stat->flags
1816-
& ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))
1811+
if (mount_crypt_stat->flags
1812+
& ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK)
18171813
(*encoded_name_size) =
18181814
(ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE
18191815
+ encoded_name_no_prefix_size);
@@ -1828,9 +1824,8 @@ int ecryptfs_encrypt_and_encode_filename(
18281824
kfree(filename);
18291825
goto out;
18301826
}
1831-
if (mount_crypt_stat
1832-
&& (mount_crypt_stat->flags
1833-
& ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK)) {
1827+
if (mount_crypt_stat->flags
1828+
& ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK) {
18341829
memcpy((*encoded_name),
18351830
ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX,
18361831
ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE);
@@ -1848,9 +1843,9 @@ int ecryptfs_encrypt_and_encode_filename(
18481843
rc = -EOPNOTSUPP;
18491844
}
18501845
if (rc) {
1851-
printk(KERN_ERR "%s: Error attempting to encode "
1852-
"encrypted filename; rc = [%d]\n", __func__,
1853-
rc);
1846+
ecryptfs_printk(KERN_ERR,
1847+
"Error attempting to encode encrypted filename; rc = [%d]\n",
1848+
rc);
18541849
kfree((*encoded_name));
18551850
(*encoded_name) = NULL;
18561851
(*encoded_name_size) = 0;
@@ -1925,8 +1920,7 @@ int ecryptfs_decode_and_decrypt_filename(char **plaintext_name,
19251920
decoded_name_size);
19261921
if (rc) {
19271922
ecryptfs_printk(KERN_DEBUG,
1928-
"%s: Could not parse tag 70 packet from filename\n",
1929-
__func__);
1923+
"Could not parse tag 70 packet from filename\n");
19301924
goto out_free;
19311925
}
19321926
} else {

fs/ecryptfs/debug.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author(s): Michael A. Halcrow <[email protected]>
88
*/
99

10+
#include <linux/string.h>
1011
#include "ecryptfs_kernel.h"
1112

1213
/*
@@ -33,9 +34,7 @@ void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
3334
ECRYPTFS_PERSISTENT_PASSWORD) {
3435
ecryptfs_printk(KERN_DEBUG, " * persistent\n");
3536
}
36-
memcpy(sig, auth_tok->token.password.signature,
37-
ECRYPTFS_SIG_SIZE_HEX);
38-
sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
37+
strscpy(sig, auth_tok->token.password.signature);
3938
ecryptfs_printk(KERN_DEBUG, " * signature = [%s]\n", sig);
4039
}
4140
ecryptfs_printk(KERN_DEBUG, " * session_key.flags = [0x%x]\n",

0 commit comments

Comments
 (0)