Skip to contentSkip to conversation

FAILED: patch "[PATCH] ubifs: don't trigger assertion on invalid no-key filename" failed to apply to 4.14-stable tree

PATCH [email protected] 2 participants 2 messages Feb 6, 2020 – Feb 7, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From f0d07a98a070bb5e443df19c3aa55693cbca9341 Mon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Mon, 20 Jan 2020 14:31:59 -0800
Subject: [PATCH] ubifs: don't trigger assertion on invalid no-key filename

If userspace provides an invalid fscrypt no-key filename which encodes a hash value with any of the UBIFS node type bits set (i.e. the high 3 bits), gracefully report ENOENT rather than triggering ubifs_assert().

Test case with kvm-xfstests shell:

. fs/ubifs/config
. ~/xfstests/common/encrypt dev=$(__blkdev_to_ubi_volume /dev/vdc) ubiupdatevol $dev -t
mount $dev /mnt -t ubifs
mkdir /mnt/edir
xfs_io -c set_encpolicy /mnt/edir
rm /mnt/edir/_,,,,,DAAAAAAAAAAAAAAAAAAAAAAAAAA

With the bug, the following assertion fails on the 'rm' command:

    [   19.066048] UBIFS error (ubi0:0 pid 379): ubifs_assert_failed: UBIFS assert failed: !(hash & ~UBIFS_S_KEY_HASH_MASK), in fs/ubifs/key.h:170
Fixes f4f61d2cc6d8 ("ubifs: Implement encrypted filenames")
Cc <[email protected]> # v4.10+
fs/ubifs/dir.c +2 -0
index 636c3222c230..5f937226976a 100644
@@ -228,6 +228,8 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
 	if (nm.hash) {
 		ubifs_assert(c, fname_len(&nm) == 0);
 		ubifs_assert(c, fname_name(&nm) == NULL);
+		if (nm.hash & ~UBIFS_S_KEY_HASH_MASK)
+			goto done; /* ENOENT */
 		dent_key_init_hash(c, &key, dir->i_ino, nm.hash);
 		err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash);
 	} else {
maintainer
#1 lore raw
Quoted 32 lines · On Thu, Feb 06, 2020 at 08:14:22PM +0100, [email protected] wrote:

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From f0d07a98a070bb5e443df19c3aa55693cbca9341 Mon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Mon, 20 Jan 2020 14:31:59 -0800
Subject: [PATCH] ubifs: don't trigger assertion on invalid no-key filename

If userspace provides an invalid fscrypt no-key filename which encodes a hash value with any of the UBIFS node type bits set (i.e. the high 3 bits), gracefully report ENOENT rather than triggering ubifs_assert().

Test case with kvm-xfstests shell:

   . fs/ubifs/config
   . ~/xfstests/common/encrypt
   dev=$(__blkdev_to_ubi_volume /dev/vdc)
   ubiupdatevol $dev -t
   mount $dev /mnt -t ubifs
   mkdir /mnt/edir
   xfs_io -c set_encpolicy /mnt/edir
   rm /mnt/edir/_,,,,,DAAAAAAAAAAAAAAAAAAAAAAAAAA
Quoted 8 lines

With the bug, the following assertion fails on the 'rm' command:

   [   19.066048] UBIFS error (ubi0:0 pid 379): ubifs_assert_failed: UBIFS assert failed: !(hash & ~UBIFS_S_KEY_HASH_MASK), in fs/ubifs/key.h:170
Fixes f4f61d2cc6d8 ("ubifs: Implement encrypted filenames")
Cc <[email protected]> # v4.10+

Contextual conflicts due to missing 6eb61d587f45 ("ubifs: Pass struct ubifs_info to ubifs_assert()"). Fixed up and queued up.

Signature · 2 lines
Thanks,
Sasha