UPSTREAM: eCryptfs: Unlink lower inode when ecryptfs_create() fails
authorTyler Hicks <tyhicks@canonical.com>
Tue, 22 May 2012 20:09:50 +0000 (15:09 -0500)
committerChromeBot <chrome-bot@google.com>
Thu, 28 Feb 2013 08:59:39 +0000 (00:59 -0800)
commit993ef63b05ccaef67e901d5afd031560fdbbfb0c
treefa766fdc7622cc3a4b4e1f9cccac5cd664119408
parent55cca59588868e0bc51646ee404be8c42199e2c7
UPSTREAM: eCryptfs: Unlink lower inode when ecryptfs_create() fails

ecryptfs_create() creates a lower inode, allocates an eCryptfs inode,
initializes the eCryptfs inode and cryptographic metadata attached to
the inode, and then writes the metadata to the header of the file.

If an error was to occur after the lower inode was created, an empty
lower file would be left in the lower filesystem. This is a problem
because ecryptfs_open() refuses to open any lower files which do not
have the appropriate metadata in the file header.

This patch properly unlinks the lower inode when an error occurs in the
later stages of ecryptfs_create(), reducing the chance that an empty
lower file will be left in the lower filesystem.

https://launchpad.net/bugs/872905

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Cc: John Johansen <john.johansen@canonical.com>
Cc: Colin Ian King <colin.king@canonical.com>
BUG=chromium-os:35732
TEST=daisy build, ENOSPC bubbles up to userspace

(cherry picked from upstream commit 8bc2d3cf612994a960c2e8eaea37f6676f67082a)
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: I9ef97db96f1e1e594e5f995ae6c1293d1b3527e0
Reviewed-on: https://gerrit.chromium.org/gerrit/44152
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Commit-Queue: Kees Cook <keescook@chromium.org>
fs/ecryptfs/inode.c