Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Eric Biggers <ebiggers@google.com>

+3 -6
+1 -3
fs/ubifs/dir.c
··· 225 225 goto done; 226 226 } 227 227 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) { 231 229 if (nm.hash & ~UBIFS_S_KEY_HASH_MASK) 232 230 goto done; /* ENOENT */ 233 231 dent_key_init_hash(c, &key, dir->i_ino, nm.hash);
+2 -2
fs/ubifs/journal.c
··· 588 588 589 589 if (!xent) { 590 590 dent->ch.node_type = UBIFS_DENT_NODE; 591 - if (nm->hash) 591 + if (fname_name(nm) == NULL) 592 592 dent_key_init_hash(c, &dent_key, dir->i_ino, nm->hash); 593 593 else 594 594 dent_key_init(c, &dent_key, dir->i_ino, nm); ··· 646 646 ubifs_add_auth_dirt(c, lnum); 647 647 648 648 if (deletion) { 649 - if (nm->hash) 649 + if (fname_name(nm) == NULL) 650 650 err = ubifs_tnc_remove_dh(c, &dent_key, nm->minor_hash); 651 651 else 652 652 err = ubifs_tnc_remove_nm(c, &dent_key, nm);
-1
fs/ubifs/key.h
··· 150 150 uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); 151 151 152 152 ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); 153 - ubifs_assert(c, !nm->hash && !nm->minor_hash); 154 153 key->u32[0] = inum; 155 154 key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); 156 155 }