From 75c93eb4397b3fdbc7587e48fb8bb884775747c5 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Fri, 8 Jan 2021 13:00:43 -0800 Subject: [PATCH] ANDROID: Incremental fs: Fix selinux issues Bug: 177075428 Test: incfs_test passes atest GtsIncrementalInstallTestCases has only 8 failures Signed-off-by: Paul Lawrence Change-Id: I73accfc1982aec1cd7947996c25a23e4a97cfdac --- fs/incfs/vfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index 915d8eb6f9b1..d7a750290953 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -898,7 +898,7 @@ static int init_new_file(struct mount_info *mi, struct dentry *dentry, .dentry = dentry }; new_file = dentry_open(&path, O_RDWR | O_NOATIME | O_LARGEFILE, - mi->mi_owner); + current_cred()); if (IS_ERR(new_file)) { error = PTR_ERR(new_file); @@ -1026,7 +1026,7 @@ static int dir_relative_path_resolve( if (dir_fd < 0) return dir_fd; - dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, mi->mi_owner); + dir_f = dentry_open(base_path, O_RDONLY | O_NOATIME, current_cred()); if (IS_ERR(dir_f)) { error = PTR_ERR(dir_f); @@ -1904,10 +1904,13 @@ static int file_open(struct inode *inode, struct file *file) struct file *backing_file = NULL; struct path backing_path = {}; int err = 0; + const struct cred *old_cred; get_incfs_backing_path(file->f_path.dentry, &backing_path); - backing_file = dentry_open( - &backing_path, O_RDWR | O_NOATIME | O_LARGEFILE, mi->mi_owner); + old_cred = override_creds(mi->mi_owner); + backing_file = dentry_open(&backing_path, + O_RDWR | O_NOATIME | O_LARGEFILE, current_cred()); + revert_creds(old_cred); path_put(&backing_path); if (IS_ERR(backing_file)) {