mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 08:10:54 +07:00
Fixes for filename decryption and encrypted view plus a cleanup
- The filename decryption routines were, at times, writing a zero byte one character past the end of the filename buffer - The encrypted view feature attempted, and failed, to roll its own form of enforcing a read-only mount instead of letting the VFS enforce it -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCgAGBQJUlGlWAAoJENaSAD2qAscKgdwQAJLCgt5xgoij8uH65mYVy6PE ++E8KggCHchhUcFh19EuuG++ENzwZedqKqbbRhmZt+svla08uPDO0jY+sYaOZzqB HMzZyyL4Fw/DiVsK6LUMGfN2CS7tua9ReK0dj4tUc3jwBplnQnGrQlUPbgdPRJJp XJDKHVtHGQPQC1dJAeProCJTg23jv5wXacly2I5VxZuh5DnDWjuo2KkzqGMKfadU 9bxOf5DjVwQ/X6apgkNxG/8Q6J8a+80K7SGs/aRELIuRL0+mIj5AX9ht+p5Z0XI+ E8jU4HM2biuqj8PtxK/WbyF1bHiREVyOLdneW+n3pcqGTLMZ3TLpDURkNd0cwZcd AGoZtUZZuQ/xvzE9IrEj+KYeINnZzPQpyJu9jXXp1CsQJ8u/wUG9e0kcJrUI1dZ/ q26zhPaVhJ9x0go/BNOxzTUpOtuMWXttAVZGICthp74I5l+DgfSZ4J4CeQmFMMRs kbiTg5h4qsrD4jnEU/BCscpCLoz4qlF6+q/+lspwkg7OwvhHc0qSMJn3UjZ/eYzb ncDp6gc4Iju3RhWnVEZphA4ttbZJX7ahER4y0NdIG65Fa37AUEUxy0OmGfoyFOmC KVtlHkl2hKoCB5+ujLzL7WimH33ogtVhtOJTZlXzS0lsdSfSxUWU4/OZ22jTy0hL Bnx6uoNIPWsr6b5OJiA0 =jTyq -----END PGP SIGNATURE----- Merge tag 'ecryptfs-3.19-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs Pull eCryptfs fixes from Tyler Hicks: "Fixes for filename decryption and encrypted view plus a cleanup - The filename decryption routines were, at times, writing a zero byte one character past the end of the filename buffer - The encrypted view feature attempted, and failed, to roll its own form of enforcing a read-only mount instead of letting the VFS enforce it" * tag 'ecryptfs-3.19-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: eCryptfs: Remove buggy and unnecessary write in file name decode routine eCryptfs: Remove unnecessary casts when parsing packet lengths eCryptfs: Force RO mount when encrypted view is enabled
This commit is contained in:
commit
298647e31a
@ -1917,7 +1917,6 @@ ecryptfs_decode_from_filename(unsigned char *dst, size_t *dst_size,
|
||||
break;
|
||||
case 2:
|
||||
dst[dst_byte_offset++] |= (src_byte);
|
||||
dst[dst_byte_offset] = 0;
|
||||
current_bit_offset = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -190,23 +190,11 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int rc = 0;
|
||||
struct ecryptfs_crypt_stat *crypt_stat = NULL;
|
||||
struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
|
||||
struct dentry *ecryptfs_dentry = file->f_path.dentry;
|
||||
/* Private value of ecryptfs_dentry allocated in
|
||||
* ecryptfs_lookup() */
|
||||
struct ecryptfs_file_info *file_info;
|
||||
|
||||
mount_crypt_stat = &ecryptfs_superblock_to_private(
|
||||
ecryptfs_dentry->d_sb)->mount_crypt_stat;
|
||||
if ((mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
|
||||
&& ((file->f_flags & O_WRONLY) || (file->f_flags & O_RDWR)
|
||||
|| (file->f_flags & O_CREAT) || (file->f_flags & O_TRUNC)
|
||||
|| (file->f_flags & O_APPEND))) {
|
||||
printk(KERN_WARNING "Mount has encrypted view enabled; "
|
||||
"files may only be read\n");
|
||||
rc = -EPERM;
|
||||
goto out;
|
||||
}
|
||||
/* Released in ecryptfs_release or end of function if failure */
|
||||
file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
|
||||
ecryptfs_set_file_private(file, file_info);
|
||||
|
@ -100,12 +100,12 @@ int ecryptfs_parse_packet_length(unsigned char *data, size_t *size,
|
||||
(*size) = 0;
|
||||
if (data[0] < 192) {
|
||||
/* One-byte length */
|
||||
(*size) = (unsigned char)data[0];
|
||||
(*size) = data[0];
|
||||
(*length_size) = 1;
|
||||
} else if (data[0] < 224) {
|
||||
/* Two-byte length */
|
||||
(*size) = (((unsigned char)(data[0]) - 192) * 256);
|
||||
(*size) += ((unsigned char)(data[1]) + 192);
|
||||
(*size) = (data[0] - 192) * 256;
|
||||
(*size) += data[1] + 192;
|
||||
(*length_size) = 2;
|
||||
} else if (data[0] == 255) {
|
||||
/* If support is added, adjust ECRYPTFS_MAX_PKT_LEN_SIZE */
|
||||
|
@ -493,6 +493,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
|
||||
{
|
||||
struct super_block *s;
|
||||
struct ecryptfs_sb_info *sbi;
|
||||
struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
|
||||
struct ecryptfs_dentry_info *root_info;
|
||||
const char *err = "Getting sb failed";
|
||||
struct inode *inode;
|
||||
@ -511,6 +512,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
|
||||
err = "Error parsing options";
|
||||
goto out;
|
||||
}
|
||||
mount_crypt_stat = &sbi->mount_crypt_stat;
|
||||
|
||||
s = sget(fs_type, NULL, set_anon_super, flags, NULL);
|
||||
if (IS_ERR(s)) {
|
||||
@ -557,11 +559,19 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
|
||||
|
||||
/**
|
||||
* Set the POSIX ACL flag based on whether they're enabled in the lower
|
||||
* mount. Force a read-only eCryptfs mount if the lower mount is ro.
|
||||
* Allow a ro eCryptfs mount even when the lower mount is rw.
|
||||
* mount.
|
||||
*/
|
||||
s->s_flags = flags & ~MS_POSIXACL;
|
||||
s->s_flags |= path.dentry->d_sb->s_flags & (MS_RDONLY | MS_POSIXACL);
|
||||
s->s_flags |= path.dentry->d_sb->s_flags & MS_POSIXACL;
|
||||
|
||||
/**
|
||||
* Force a read-only eCryptfs mount when:
|
||||
* 1) The lower mount is ro
|
||||
* 2) The ecryptfs_encrypted_view mount option is specified
|
||||
*/
|
||||
if (path.dentry->d_sb->s_flags & MS_RDONLY ||
|
||||
mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
|
||||
s->s_flags |= MS_RDONLY;
|
||||
|
||||
s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
|
||||
s->s_blocksize = path.dentry->d_sb->s_blocksize;
|
||||
|
Loading…
Reference in New Issue
Block a user