Skip to content

Commit aec992a

Browse files
committed
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/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent f0d07a9 commit aec992a

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

fs/ubifs/dir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
225225
goto done;
226226
}
227227

228-
if (nm.hash) {
229-
ubifs_assert(c, fname_len(&nm) == 0);
230-
ubifs_assert(c, fname_name(&nm) == NULL);
228+
if (fname_name(&nm) == NULL) {
231229
if (nm.hash & ~UBIFS_S_KEY_HASH_MASK)
232230
goto done; /* ENOENT */
233231
dent_key_init_hash(c, &key, dir->i_ino, nm.hash);

fs/ubifs/journal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
588588

589589
if (!xent) {
590590
dent->ch.node_type = UBIFS_DENT_NODE;
591-
if (nm->hash)
591+
if (fname_name(nm) == NULL)
592592
dent_key_init_hash(c, &dent_key, dir->i_ino, nm->hash);
593593
else
594594
dent_key_init(c, &dent_key, dir->i_ino, nm);
@@ -646,7 +646,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
646646
ubifs_add_auth_dirt(c, lnum);
647647

648648
if (deletion) {
649-
if (nm->hash)
649+
if (fname_name(nm) == NULL)
650650
err = ubifs_tnc_remove_dh(c, &dent_key, nm->minor_hash);
651651
else
652652
err = ubifs_tnc_remove_nm(c, &dent_key, nm);

fs/ubifs/key.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ static inline void dent_key_init(const struct ubifs_info *c,
150150
uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
151151

152152
ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK));
153-
ubifs_assert(c, !nm->hash && !nm->minor_hash);
154153
key->u32[0] = inum;
155154
key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS);
156155
}

0 commit comments

Comments
 (0)