]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
eCryptfs: Initialize empty lower files when opening them
authorTyler Hicks <tyhicks@canonical.com>
Thu, 21 Jun 2012 06:50:59 +0000 (23:50 -0700)
committerTyler Hicks <tyhicks@canonical.com>
Sun, 8 Jul 2012 17:51:45 +0000 (12:51 -0500)
commite3ccaa9761200952cc269b1f4b7d7bb77a5e071b
treefce1240d5666184763da4b5fe3bfcfdf294faab6
parent8bc2d3cf612994a960c2e8eaea37f6676f67082a
eCryptfs: Initialize empty lower files when opening them

Historically, eCryptfs has only initialized lower files in the
ecryptfs_create() path. Lower file initialization is the act of writing
the cryptographic metadata from the inode's crypt_stat to the header of
the file. The ecryptfs_open() path already expects that metadata to be
in the header of the file.

A number of users have reported empty lower files in beneath their
eCryptfs mounts. Most of the causes for those empty files being left
around have been addressed, but the presence of empty files causes
problems due to the lack of proper cryptographic metadata.

To transparently solve this problem, this patch initializes empty lower
files in the ecryptfs_open() error path. If the metadata is unreadable
due to the lower inode size being 0, plaintext passthrough support is
not in use, and the metadata is stored in the header of the file (as
opposed to the user.ecryptfs extended attribute), the lower file will be
initialized.

The number of nested conditionals in ecryptfs_open() was getting out of
hand, so a helper function was created. To avoid the same nested
conditional problem, the conditional logic was reversed inside of the
helper function.

https://launchpad.net/bugs/911507

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Cc: John Johansen <john.johansen@canonical.com>
Cc: Colin Ian King <colin.king@canonical.com>
fs/ecryptfs/ecryptfs_kernel.h
fs/ecryptfs/file.c
fs/ecryptfs/inode.c