Commit fb1d8e0e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'upstream-4.10-rc5' of git://git.infradead.org/linux-ubifs

Pull UBIFS fixes from Richard Weinberger:
 "This contains fixes for UBIFS:

   - a long standing issue in UBIFS journal replay code

   - fallout from the merge window"

* tag 'upstream-4.10-rc5' of git://git.infradead.org/linux-ubifs:
  ubifs: Fix journal replay wrt. xattr nodes
  ubifs: remove redundant checks for encryption key
  ubifs: allow encryption ioctls in compat mode
  ubifs: add CONFIG_BLOCK dependency for encryption
  ubifs: fix unencrypted journal write
  ubifs: ensure zero err is returned on successful return
parents fa19a769 1cb51a15
...@@ -53,7 +53,7 @@ config UBIFS_ATIME_SUPPORT ...@@ -53,7 +53,7 @@ config UBIFS_ATIME_SUPPORT
config UBIFS_FS_ENCRYPTION config UBIFS_FS_ENCRYPTION
bool "UBIFS Encryption" bool "UBIFS Encryption"
depends on UBIFS_FS depends on UBIFS_FS && BLOCK
select FS_ENCRYPTION select FS_ENCRYPTION
default n default n
help help
......
...@@ -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;
......
...@@ -217,6 +217,9 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -217,6 +217,9 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case FS_IOC32_SETFLAGS: case FS_IOC32_SETFLAGS:
cmd = FS_IOC_SETFLAGS; cmd = FS_IOC_SETFLAGS;
break; break;
case FS_IOC_SET_ENCRYPTION_POLICY:
case FS_IOC_GET_ENCRYPTION_POLICY:
break;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
...@@ -744,6 +744,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, ...@@ -744,6 +744,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
} else { } else {
data->compr_size = 0; data->compr_size = 0;
out_len = compr_len;
} }
dlen = UBIFS_DATA_NODE_SZ + out_len; dlen = UBIFS_DATA_NODE_SZ + out_len;
...@@ -1319,6 +1320,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in ...@@ -1319,6 +1320,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
dn->compr_type = cpu_to_le16(compr_type); dn->compr_type = cpu_to_le16(compr_type);
dn->size = cpu_to_le32(*new_len); dn->size = cpu_to_le32(*new_len);
*new_len = UBIFS_DATA_NODE_SZ + out_len; *new_len = UBIFS_DATA_NODE_SZ + out_len;
err = 0;
out: out:
kfree(buf); kfree(buf);
return err; return err;
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
#include <linux/slab.h> #include <linux/slab.h>
#include "ubifs.h" #include "ubifs.h"
static int try_read_node(const struct ubifs_info *c, void *buf, int type,
int len, int lnum, int offs);
static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_zbranch *zbr, void *node);
/* /*
* Returned codes of 'matches_name()' and 'fallible_matches_name()' functions. * Returned codes of 'matches_name()' and 'fallible_matches_name()' functions.
* @NAME_LESS: name corresponding to the first argument is less than second * @NAME_LESS: name corresponding to the first argument is less than second
...@@ -402,7 +407,19 @@ static int tnc_read_hashed_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, ...@@ -402,7 +407,19 @@ static int tnc_read_hashed_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
return 0; return 0;
} }
if (c->replaying) {
err = fallible_read_node(c, &zbr->key, zbr, node);
/*
* When the node was not found, return -ENOENT, 0 otherwise.
* Negative return codes stay as-is.
*/
if (err == 0)
err = -ENOENT;
else if (err == 1)
err = 0;
} else {
err = ubifs_tnc_read_node(c, zbr, node); err = ubifs_tnc_read_node(c, zbr, node);
}
if (err) if (err)
return err; return err;
...@@ -2857,6 +2874,10 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c, ...@@ -2857,6 +2874,10 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
if (fname_len(nm) > 0) { if (fname_len(nm) > 0) {
if (err) { if (err) {
/* Handle collisions */ /* Handle collisions */
if (c->replaying)
err = fallible_resolve_collision(c, key, &znode, &n,
nm, 0);
else
err = resolve_collision(c, key, &znode, &n, nm); err = resolve_collision(c, key, &znode, &n, nm);
dbg_tnc("rc returned %d, znode %p, n %d", dbg_tnc("rc returned %d, znode %p, n %d",
err, znode, n); err, znode, n);
......
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