Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fd1c005 authored by Eric Biggers's avatar Eric Biggers Committed by Jaegeuk Kim
Browse files

ubifs: allow both hash and disk name to be provided in no-key names

In order to support a new dirhash method that is a secret-keyed hash
over the plaintext filenames (which will be used by encrypted+casefolded
directories on ext4 and f2fs), fscrypt will be switching to a new no-key
name format that always encodes the dirhash in the name.

UBIFS isn't happy with this because it has assertions that verify that
either the hash or the disk name is provided, not both.

Change it to use the disk name if one is provided, even if a hash is
available too; else use the hash.

Link: https://lore.kernel.org/r/20200120223201.241390-6-ebiggers@kernel.org


Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 89aca68d
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -237,9 +237,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
		goto out_fname;
		goto out_fname;
	}
	}


	if (nm.hash) {
	if (fname_name(&nm) == NULL) {
		ubifs_assert(fname_len(&nm) == 0);
		ubifs_assert(fname_name(&nm) == NULL);
		if (nm.hash & ~UBIFS_S_KEY_HASH_MASK)
		if (nm.hash & ~UBIFS_S_KEY_HASH_MASK)
			goto done; /* ENOENT */
			goto done; /* ENOENT */
		dent_key_init_hash(c, &key, dir->i_ino, nm.hash);
		dent_key_init_hash(c, &key, dir->i_ino, nm.hash);
+2 −2
Original line number Original line Diff line number Diff line
@@ -583,7 +583,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,


	if (!xent) {
	if (!xent) {
		dent->ch.node_type = UBIFS_DENT_NODE;
		dent->ch.node_type = UBIFS_DENT_NODE;
		if (nm->hash)
		if (fname_name(nm) == NULL)
			dent_key_init_hash(c, &dent_key, dir->i_ino, nm->hash);
			dent_key_init_hash(c, &dent_key, dir->i_ino, nm->hash);
		else
		else
			dent_key_init(c, &dent_key, dir->i_ino, nm);
			dent_key_init(c, &dent_key, dir->i_ino, nm);
@@ -630,7 +630,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
	kfree(dent);
	kfree(dent);


	if (deletion) {
	if (deletion) {
		if (nm->hash)
		if (fname_name(nm) == NULL)
			err = ubifs_tnc_remove_dh(c, &dent_key, nm->minor_hash);
			err = ubifs_tnc_remove_dh(c, &dent_key, nm->minor_hash);
		else
		else
			err = ubifs_tnc_remove_nm(c, &dent_key, nm);
			err = ubifs_tnc_remove_nm(c, &dent_key, nm);
+0 −1
Original line number Original line Diff line number Diff line
@@ -162,7 +162,6 @@ static inline void dent_key_init(const struct ubifs_info *c,
	uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
	uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));


	ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
	ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
	ubifs_assert(!nm->hash && !nm->minor_hash);
	key->u32[0] = inum;
	key->u32[0] = inum;
	key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS);
	key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS);
}
}