Commit 3d4b2fcb authored by Eric Biggers's avatar Eric Biggers Committed by Richard Weinberger

ubifs: remove redundant checks for encryption key

In several places, ubifs checked for an encryption key before creating a
file in an encrypted directory.  This was redundant with
fscrypt_setup_filename() or ubifs_new_inode(), and in the case of
ubifs_link() it broke linking to special files.  So remove the extra
checks.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent a75467d9
...@@ -390,16 +390,6 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry, ...@@ -390,16 +390,6 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
dbg_gen("dent '%pd', mode %#hx in dir ino %lu", dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
dentry, mode, dir->i_ino); dentry, mode, dir->i_ino);
if (ubifs_crypt_is_encrypted(dir)) {
err = fscrypt_get_encryption_info(dir);
if (err)
return err;
if (!fscrypt_has_encryption_key(dir)) {
return -EPERM;
}
}
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
if (err) if (err)
return err; return err;
...@@ -741,18 +731,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -741,18 +731,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
ubifs_assert(inode_is_locked(dir)); ubifs_assert(inode_is_locked(dir));
ubifs_assert(inode_is_locked(inode)); ubifs_assert(inode_is_locked(inode));
if (ubifs_crypt_is_encrypted(dir)) { if (ubifs_crypt_is_encrypted(dir) &&
if (!fscrypt_has_permitted_context(dir, inode)) !fscrypt_has_permitted_context(dir, inode))
return -EPERM; return -EPERM;
err = fscrypt_get_encryption_info(inode);
if (err)
return err;
if (!fscrypt_has_encryption_key(inode))
return -EPERM;
}
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
if (err) if (err)
return err; return err;
...@@ -1000,17 +982,6 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -1000,17 +982,6 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
if (err) if (err)
return err; return err;
if (ubifs_crypt_is_encrypted(dir)) {
err = fscrypt_get_encryption_info(dir);
if (err)
goto out_budg;
if (!fscrypt_has_encryption_key(dir)) {
err = -EPERM;
goto out_budg;
}
}
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
if (err) if (err)
goto out_budg; goto out_budg;
...@@ -1096,17 +1067,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -1096,17 +1067,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
return err; return err;
} }
if (ubifs_crypt_is_encrypted(dir)) {
err = fscrypt_get_encryption_info(dir);
if (err)
goto out_budg;
if (!fscrypt_has_encryption_key(dir)) {
err = -EPERM;
goto out_budg;
}
}
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
if (err) if (err)
goto out_budg; goto out_budg;
...@@ -1231,18 +1191,6 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -1231,18 +1191,6 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
goto out_inode; goto out_inode;
} }
err = fscrypt_get_encryption_info(inode);
if (err) {
kfree(sd);
goto out_inode;
}
if (!fscrypt_has_encryption_key(inode)) {
kfree(sd);
err = -EPERM;
goto out_inode;
}
ostr.name = sd->encrypted_path; ostr.name = sd->encrypted_path;
ostr.len = disk_link.len; ostr.len = disk_link.len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment