mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 01:51:39 +00:00
eCryptfs: Strip metadata in xattr flag in encrypted view
The ecryptfs_encrypted_view mount option provides a unified way of viewing encrypted eCryptfs files. If the metadata is stored in a xattr, the metadata is moved to the file header when the file is read inside the eCryptfs mount. Because of this, we should strip the ECRYPTFS_METADATA_IN_XATTR flag from the header's flag section. This allows eCryptfs to treat the file as an eCryptfs file with a header at the front. Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
This commit is contained in:
parent
1984c23f9e
commit
f4e60e6b30
3 changed files with 22 additions and 4 deletions
|
@ -1107,8 +1107,8 @@ static void write_ecryptfs_marker(char *page_virt, size_t *written)
|
||||||
(*written) = MAGIC_ECRYPTFS_MARKER_SIZE_BYTES;
|
(*written) = MAGIC_ECRYPTFS_MARKER_SIZE_BYTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void ecryptfs_write_crypt_stat_flags(char *page_virt,
|
||||||
write_ecryptfs_flags(char *page_virt, struct ecryptfs_crypt_stat *crypt_stat,
|
struct ecryptfs_crypt_stat *crypt_stat,
|
||||||
size_t *written)
|
size_t *written)
|
||||||
{
|
{
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
|
@ -1290,7 +1290,8 @@ static int ecryptfs_write_headers_virt(char *page_virt, size_t max,
|
||||||
offset = ECRYPTFS_FILE_SIZE_BYTES;
|
offset = ECRYPTFS_FILE_SIZE_BYTES;
|
||||||
write_ecryptfs_marker((page_virt + offset), &written);
|
write_ecryptfs_marker((page_virt + offset), &written);
|
||||||
offset += written;
|
offset += written;
|
||||||
write_ecryptfs_flags((page_virt + offset), crypt_stat, &written);
|
ecryptfs_write_crypt_stat_flags((page_virt + offset), crypt_stat,
|
||||||
|
&written);
|
||||||
offset += written;
|
offset += written;
|
||||||
ecryptfs_write_header_metadata((page_virt + offset), crypt_stat,
|
ecryptfs_write_header_metadata((page_virt + offset), crypt_stat,
|
||||||
&written);
|
&written);
|
||||||
|
|
|
@ -659,6 +659,9 @@ int ecryptfs_decrypt_page(struct page *page);
|
||||||
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry);
|
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry);
|
||||||
int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);
|
int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);
|
||||||
int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry);
|
int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry);
|
||||||
|
void ecryptfs_write_crypt_stat_flags(char *page_virt,
|
||||||
|
struct ecryptfs_crypt_stat *crypt_stat,
|
||||||
|
size_t *written);
|
||||||
int ecryptfs_read_and_validate_header_region(char *data,
|
int ecryptfs_read_and_validate_header_region(char *data,
|
||||||
struct inode *ecryptfs_inode);
|
struct inode *ecryptfs_inode);
|
||||||
int ecryptfs_read_and_validate_xattr_region(char *page_virt,
|
int ecryptfs_read_and_validate_xattr_region(char *page_virt,
|
||||||
|
|
|
@ -82,6 +82,19 @@ out:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void strip_xattr_flag(char *page_virt,
|
||||||
|
struct ecryptfs_crypt_stat *crypt_stat)
|
||||||
|
{
|
||||||
|
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
|
||||||
|
size_t written;
|
||||||
|
|
||||||
|
crypt_stat->flags &= ~ECRYPTFS_METADATA_IN_XATTR;
|
||||||
|
ecryptfs_write_crypt_stat_flags(page_virt, crypt_stat,
|
||||||
|
&written);
|
||||||
|
crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header Extent:
|
* Header Extent:
|
||||||
* Octets 0-7: Unencrypted file size (big-endian)
|
* Octets 0-7: Unencrypted file size (big-endian)
|
||||||
|
@ -136,6 +149,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
|
||||||
|
|
||||||
rc = ecryptfs_read_xattr_region(
|
rc = ecryptfs_read_xattr_region(
|
||||||
page_virt, page->mapping->host);
|
page_virt, page->mapping->host);
|
||||||
|
strip_xattr_flag(page_virt + 16, crypt_stat);
|
||||||
ecryptfs_write_header_metadata(page_virt + 20,
|
ecryptfs_write_header_metadata(page_virt + 20,
|
||||||
crypt_stat,
|
crypt_stat,
|
||||||
&written);
|
&written);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue