ANDROID: sdcardfs: Change current->fs under lock
authorDaniel Rosenberg <drosen@google.com>
Fri, 20 Jul 2018 23:11:40 +0000 (16:11 -0700)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:46:29 +0000 (23:46 +0900)
Adjusted from previous version to add missing include

bug: 111641492

Change-Id: I321d83f5d599efb3abdfaf2f3a4900ac512beca6
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
fs/sdcardfs/inode.c

index 7c6a64d861fb571fe37974fd742ab8bd630eb5bf..4dd681e0d59d948374883a7e34ed8318d4537e23 100644 (file)
@@ -97,8 +97,11 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
                err = -ENOMEM;
                goto out_unlock;
        }
+       copied_fs->umask = 0;
+       task_lock(current);
        current->fs = copied_fs;
-       current->fs->umask = 0;
+       task_unlock(current);
+
        err = vfs_create2(lower_dentry_mnt, d_inode(lower_parent_dentry), lower_dentry, mode, want_excl);
        if (err)
                goto out;
@@ -112,7 +115,9 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
        fixup_lower_ownership(dentry, dentry->d_name.name);
 
 out:
+       task_lock(current);
        current->fs = saved_fs;
+       task_unlock(current);
        free_fs_struct(copied_fs);
 out_unlock:
        unlock_dir(lower_parent_dentry);
@@ -250,8 +255,11 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
                unlock_dir(lower_parent_dentry);
                goto out_unlock;
        }
+       copied_fs->umask = 0;
+       task_lock(current);
        current->fs = copied_fs;
-       current->fs->umask = 0;
+       task_unlock(current);
+
        err = vfs_mkdir2(lower_mnt, d_inode(lower_parent_dentry), lower_dentry, mode);
 
        if (err) {
@@ -319,7 +327,10 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
                }
        }
 out:
+       task_lock(current);
        current->fs = saved_fs;
+       task_unlock(current);
+
        free_fs_struct(copied_fs);
 out_unlock:
        sdcardfs_put_lower_path(dentry, &lower_path);