mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 07:30:16 +00:00
Minor cleanups and a bug fix to completely ignore unencrypted filenames
in the lower filesystem when filename encryption is enabled at the eCryptfs layer. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCgAGBQJa2LwFAAoJENaSAD2qAscKt00P+wSOy/iUn7wd3L/mtjN+B34l 8MaBNoruoZ87pPPHm4ZjB85zk5fSzwQl/jKgS8y6dRA1bxcwsUYRMooTIsiOBFeg c1BEWfJVL8uq5AtmZ+czwUD2+DNn/U6S+XejXKr/bQyzOOgUtAeX8IPERPzGqJkB dXbz21NLBpICxslIHTTHCpCWodm8B9SJSrBeKd1WIad1d+ITjB6fnyHyIlEyFxlk yxkXLVZskR/yihIQ8JugJ4Li0nWz4KcdAvS2fbSIG5zgkAtLS9ypPAAQrfCf9pCA BYc4Q2Ai425tgVqAwK2uHXOzy7/WsPL4yrIXt/04vTra1XcK9cv2EdojYi1cK04W /a6xIWzFtp7HYEhuHZiVdvSTRXEOF9IYUXTw/gavE0KvMZ36k2FU9bLo4WKmx/91 atr+9p4vE6uA932YY54Wit++IjpLGN7FzXYxVVoACVz7HJ+sESqytPiLVX5iufux /xrrbmlEpLEeJa6/F1Yboo9R7aclrMsxEz4Y+Txkk/zmjzP8wYYiYodOCJ23pauY 5MJruAxLtlcmAzW7FbES/Id+6Rfj42BuzXi3TRceiUv8NWmDTk3y205o94CfJW5U mxEiFgb7Nxr1UsL66rZGmpnwcfJY4FFEyuXRGEmATBquEGJPTqhku9HKUkmORa7I mYJzK27VX7dE2lAzuMpr =bwS0 -----END PGP SIGNATURE----- Merge tag 'ecryptfs-4.17-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs Pull eCryptfs fixes from Tyler Hicks: "Minor cleanups and a bug fix to completely ignore unencrypted filenames in the lower filesystem when filename encryption is enabled at the eCryptfs layer" * tag 'ecryptfs-4.17-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: eCryptfs: don't pass up plaintext names when using filename encryption ecryptfs: fix spelling mistake: "cadidate" -> "candidate" ecryptfs: lookup: Don't check if mount_crypt_stat is NULL
This commit is contained in:
commit
43f70c9601
@ -1997,6 +1997,16 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static bool is_dot_dotdot(const char *name, size_t name_size)
|
||||
{
|
||||
if (name_size == 1 && name[0] == '.')
|
||||
return true;
|
||||
else if (name_size == 2 && name[0] == '.' && name[1] == '.')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ecryptfs_decode_and_decrypt_filename - converts the encoded cipher text name to decoded plaintext
|
||||
* @plaintext_name: The plaintext name
|
||||
@ -2021,13 +2031,21 @@ int ecryptfs_decode_and_decrypt_filename(char **plaintext_name,
|
||||
size_t packet_size;
|
||||
int rc = 0;
|
||||
|
||||
if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)
|
||||
&& !(mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
|
||||
&& (name_size > ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE)
|
||||
&& (strncmp(name, ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX,
|
||||
ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE) == 0)) {
|
||||
const char *orig_name = name;
|
||||
size_t orig_name_size = name_size;
|
||||
if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) &&
|
||||
!(mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)) {
|
||||
if (is_dot_dotdot(name, name_size)) {
|
||||
rc = ecryptfs_copy_filename(plaintext_name,
|
||||
plaintext_name_size,
|
||||
name, name_size);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (name_size <= ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE ||
|
||||
strncmp(name, ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX,
|
||||
ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE)) {
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
name += ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE;
|
||||
name_size -= ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE;
|
||||
@ -2047,12 +2065,9 @@ int ecryptfs_decode_and_decrypt_filename(char **plaintext_name,
|
||||
decoded_name,
|
||||
decoded_name_size);
|
||||
if (rc) {
|
||||
printk(KERN_INFO "%s: Could not parse tag 70 packet "
|
||||
"from filename; copying through filename "
|
||||
"as-is\n", __func__);
|
||||
rc = ecryptfs_copy_filename(plaintext_name,
|
||||
plaintext_name_size,
|
||||
orig_name, orig_name_size);
|
||||
ecryptfs_printk(KERN_DEBUG,
|
||||
"%s: Could not parse tag 70 packet from filename\n",
|
||||
__func__);
|
||||
goto out_free;
|
||||
}
|
||||
} else {
|
||||
|
@ -82,17 +82,28 @@ ecryptfs_filldir(struct dir_context *ctx, const char *lower_name,
|
||||
buf->sb, lower_name,
|
||||
lower_namelen);
|
||||
if (rc) {
|
||||
printk(KERN_ERR "%s: Error attempting to decode and decrypt "
|
||||
"filename [%s]; rc = [%d]\n", __func__, lower_name,
|
||||
rc);
|
||||
goto out;
|
||||
if (rc != -EINVAL) {
|
||||
ecryptfs_printk(KERN_DEBUG,
|
||||
"%s: Error attempting to decode and decrypt filename [%s]; rc = [%d]\n",
|
||||
__func__, lower_name, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Mask -EINVAL errors as these are most likely due a plaintext
|
||||
* filename present in the lower filesystem despite filename
|
||||
* encryption being enabled. One unavoidable example would be
|
||||
* the "lost+found" dentry in the root directory of an Ext4
|
||||
* filesystem.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf->caller->pos = buf->ctx.pos;
|
||||
rc = !dir_emit(buf->caller, name, name_size, ino, d_type);
|
||||
kfree(name);
|
||||
if (!rc)
|
||||
buf->entries_written++;
|
||||
out:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -395,8 +395,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
|
||||
|
||||
mount_crypt_stat = &ecryptfs_superblock_to_private(
|
||||
ecryptfs_dentry->d_sb)->mount_crypt_stat;
|
||||
if (mount_crypt_stat
|
||||
&& (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
|
||||
if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
|
||||
rc = ecryptfs_encrypt_and_encode_filename(
|
||||
&encrypted_and_encoded_name, &len,
|
||||
mount_crypt_stat, name, len);
|
||||
|
@ -1880,7 +1880,7 @@ find_next_matching_auth_tok:
|
||||
candidate_auth_tok = &auth_tok_list_item->auth_tok;
|
||||
if (unlikely(ecryptfs_verbosity > 0)) {
|
||||
ecryptfs_printk(KERN_DEBUG,
|
||||
"Considering cadidate auth tok:\n");
|
||||
"Considering candidate auth tok:\n");
|
||||
ecryptfs_dump_auth_tok(candidate_auth_tok);
|
||||
}
|
||||
rc = ecryptfs_get_auth_tok_sig(&candidate_auth_tok_sig,
|
||||
|
Loading…
x
Reference in New Issue
Block a user