UPSTREAM: eCryptfs: Gracefully refuse miscdev file ops on inherited/passed files
authorTyler Hicks <tyhicks@canonical.com>
Mon, 11 Jun 2012 16:24:11 +0000 (09:24 -0700)
committerChromeBot <chrome-bot@google.com>
Thu, 28 Feb 2013 08:59:33 +0000 (00:59 -0800)
commit0442b5f82ced1d397d011054ccde51adcb65e55f
tree969790714a40e5d5e6044c57c55043175a1ea547
parent4176a4f19c1841261d13174742d8f3c53b5863d8
UPSTREAM: eCryptfs: Gracefully refuse miscdev file ops on inherited/passed files

File operations on /dev/ecryptfs would BUG() when the operations were
performed by processes other than the process that originally opened the
file. This could happen with open files inherited after fork() or file
descriptors passed through IPC mechanisms. Rather than calling BUG(), an
error code can be safely returned in most situations.

In ecryptfs_miscdev_release(), eCryptfs still needs to handle the
release even if the last file reference is being held by a process that
didn't originally open the file. ecryptfs_find_daemon_by_euid() will not
be successful, so a pointer to the daemon is stored in the file's
private_data. The private_data pointer is initialized when the miscdev
file is opened and only used when the file is released.

https://launchpad.net/bugs/994247

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Tested-by: Sasha Levin <levinsasha928@gmail.com>
BUG=chromium-os:35732
TEST=daisy build, ENOSPC bubbles up to userspace

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