Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
sdcardfs: fix wrong ENOENT when creating a file
Browse files Browse the repository at this point in the history
There is subtle race condtion where lower_dentry is null. If we retry
lookup again, we should get the correct dentry.

Bug: 110585947
Bug: 110464178
Bug: 80587794
Bug: 37231161
Bug: 110199687
Change-Id: I39b95de4649b034287776f5c8a5d197b6ebd9ada
Signed-off-by: Jaegeuk Kim <[email protected]>
Signed-off-by: Dhruv <[email protected]>
Signed-off-by: negrroo <[email protected]>
  • Loading branch information
Jaegeuk Kim authored and reocat committed Jan 24, 2024
1 parent aa08197 commit 63b6c05
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fs/sdcardfs/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* General Public License.
*/

#include <linux/fscrypt.h>
#include "sdcardfs.h"
#include "linux/delay.h"

Expand Down Expand Up @@ -274,6 +275,7 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
lower_dir_dentry = lower_parent_path->dentry;
lower_dir_mnt = lower_parent_path->mnt;

retry_lookup:
/* Use vfs_path_lookup to check if the dentry exists or not */
err = vfs_path_lookup(lower_dir_dentry, lower_dir_mnt, name->name, 0,
&lower_path);
Expand Down Expand Up @@ -377,8 +379,14 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
* dentry then. Don't confuse the lower filesystem by forcing
* one on it now...
*/
err = -ENOENT;
goto out;
struct inode *lower_dir = d_inode(lower_dir_dentry);

if (IS_ENCRYPTED(lower_dir) &&
!fscrypt_has_encryption_key(lower_dir)) {
err = -ENOENT;
goto out;
}
goto retry_lookup;
}

lower_path.dentry = lower_dentry;
Expand Down

0 comments on commit 63b6c05

Please sign in to comment.