UPSTREAM: eCryptfs: Properly check for O_RDONLY flag before doing privileged open
authorTyler Hicks <tyhicks@canonical.com>
Tue, 12 Jun 2012 18:17:01 +0000 (11:17 -0700)
committerChromeBot <chrome-bot@google.com>
Thu, 28 Feb 2013 08:59:28 +0000 (00:59 -0800)
commit875235226e5d40d504a2fafe40e36394d52d9dba
tree0a8e42a1d8f2b1ec61a610c9a2c54eb88bf97bc8
parent462eb688e5d9731fb2f07956c82d362119de03c3
UPSTREAM: eCryptfs: Properly check for O_RDONLY flag before doing privileged open

If the first attempt at opening the lower file read/write fails,
eCryptfs will retry using a privileged kthread. However, the privileged
retry should not happen if the lower file's inode is read-only because a
read/write open will still be unsuccessful.

The check for determining if the open should be retried was intended to
be based on the access mode of the lower file's open flags being
O_RDONLY, but the check was incorrectly performed. This would cause the
open to be retried by the privileged kthread, resulting in a second
failed open of the lower file. This patch corrects the check to
determine if the open request should be handled by the privileged
kthread.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
BUG=chromium-os:35732
TEST=daisy build, ENOSPC bubbles up to userspace

(cherry picked from commit 9fe79d7600497ed8a95c3981cbe5b73ab98222f0)
Signed-off-by: Kees Cook <keescook@chromium.org>
Change-Id: I748856005c76dd310a5a1d8a053bcba01ddded77
Reviewed-on: https://gerrit.chromium.org/gerrit/44148
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Commit-Queue: Kees Cook <keescook@chromium.org>
fs/ecryptfs/kthread.c