summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-10-31 15:05:50 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-05 11:08:35 +0100
commit000d849574fa636f1764919be459827df0114185 (patch)
tree6c1ab7ea4c8c673ad9db146e064f92f3d87f67fb /include
parent1ae161d27b01ebe062cc4bf228a1e5debc473310 (diff)
downloadlinux-stable-000d849574fa636f1764919be459827df0114185.tar.gz
linux-stable-000d849574fa636f1764919be459827df0114185.tar.bz2
linux-stable-000d849574fa636f1764919be459827df0114185.zip
fscrypt: fix race allowing rename() and link() of ciphertext dentries
commit 968dd6d0c6d6b6a989c6ddb9e2584a031b83e7b5 upstream. Close some race conditions where fscrypt allowed rename() and link() on ciphertext dentries that had been looked up just prior to the key being concurrently added. It's better to return -ENOKEY in this case. This avoids doing the nonsensical thing of encrypting the names a second time when searching for the actual on-disk dir entries. It also guarantees that DCACHE_ENCRYPTED_NAME dentries are never rename()d, so the dcache won't have support all possible combinations of moving DCACHE_ENCRYPTED_NAME around during __d_move(). Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fscrypt.h2
-rw-r--r--include/linux/fscrypt_notsupp.h4
-rw-r--r--include/linux/fscrypt_supp.h3
3 files changed, 5 insertions, 4 deletions
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index c83e4dc55c06..af52a240c739 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -97,7 +97,7 @@ static inline int fscrypt_prepare_link(struct dentry *old_dentry,
struct dentry *dentry)
{
if (IS_ENCRYPTED(dir))
- return __fscrypt_prepare_link(d_inode(old_dentry), dir);
+ return __fscrypt_prepare_link(d_inode(old_dentry), dir, dentry);
return 0;
}
diff --git a/include/linux/fscrypt_notsupp.h b/include/linux/fscrypt_notsupp.h
index ee8b43e4c15a..15bbbd7c52b8 100644
--- a/include/linux/fscrypt_notsupp.h
+++ b/include/linux/fscrypt_notsupp.h
@@ -183,8 +183,8 @@ static inline int fscrypt_file_open(struct inode *inode, struct file *filp)
return 0;
}
-static inline int __fscrypt_prepare_link(struct inode *inode,
- struct inode *dir)
+static inline int __fscrypt_prepare_link(struct inode *inode, struct inode *dir,
+ struct dentry *dentry)
{
return -EOPNOTSUPP;
}
diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h
index 6456c6b2005f..b8443a2e47dc 100644
--- a/include/linux/fscrypt_supp.h
+++ b/include/linux/fscrypt_supp.h
@@ -184,7 +184,8 @@ extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
/* hooks.c */
extern int fscrypt_file_open(struct inode *inode, struct file *filp);
-extern int __fscrypt_prepare_link(struct inode *inode, struct inode *dir);
+extern int __fscrypt_prepare_link(struct inode *inode, struct inode *dir,
+ struct dentry *dentry);
extern int __fscrypt_prepare_rename(struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,