ANDROID: sdcardfs: Don't do d_add for lower fs
authorDaniel Rosenberg <drosen@google.com>
Wed, 19 Apr 2017 05:25:15 +0000 (22:25 -0700)
committerDaniel Rosenberg <drosen@google.com>
Tue, 30 Jan 2018 03:40:09 +0000 (19:40 -0800)
For file based encryption, ext4 explicitly does not
create negative dentries for encrypted files. If you
force one over it, the decrypted file will be hidden
until the cache is cleared. Instead, just fail out.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37231161
Change-Id: Id2a9708dfa75e1c22f89915c529789caadd2ca4b

fs/sdcardfs/lookup.c

index 19154b77b0fc3b7ff5a06bef96c8fc20ffafc79b..126e233654fead18d662167aae71848e5d4aa791 100644 (file)
@@ -368,17 +368,15 @@ put_name:
        dname.len = name->len;
        dname.hash = full_name_hash(lower_dir_dentry, dname.name, dname.len);
        lower_dentry = d_lookup(lower_dir_dentry, &dname);
-       if (lower_dentry)
-               goto setup_lower;
-
-       lower_dentry = d_alloc(lower_dir_dentry, &dname);
        if (!lower_dentry) {
-               err = -ENOMEM;
+               /* We called vfs_path_lookup earlier, and did not get a negative
+                * dentry then. Don't confuse the lower filesystem by forcing
+                * one on it now...
+                */
+               err = -ENOENT;
                goto out;
        }
-       d_add(lower_dentry, NULL); /* instantiate and hash */
 
-setup_lower:
        lower_path.dentry = lower_dentry;
        lower_path.mnt = mntget(lower_dir_mnt);
        sdcardfs_set_lower_path(dentry, &lower_path);