Skip to content

Commit 9fe79d7

Browse files
committed
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> Acked-by: Dan Carpenter <[email protected]>
1 parent ff826b2 commit 9fe79d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ecryptfs/kthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int ecryptfs_privileged_open(struct file **lower_file,
149149
(*lower_file) = dentry_open(lower_dentry, lower_mnt, flags, cred);
150150
if (!IS_ERR(*lower_file))
151151
goto out;
152-
if (flags & O_RDONLY) {
152+
if ((flags & O_ACCMODE) == O_RDONLY) {
153153
rc = PTR_ERR((*lower_file));
154154
goto out;
155155
}

0 commit comments

Comments
 (0)