]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
ubifs: don't trigger assertion on invalid no-key filename
authorEric Biggers <ebiggers@google.com>
Mon, 20 Jan 2020 22:31:59 +0000 (14:31 -0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 04:31:00 +0000 (00:31 -0400)
commit31a0eb3453d1d1888d9d6883a3cb682fbc1ecc5b
treebfde32cf0a9e1ebbbfbcacf8445eb8bd23992a91
parent3f26b91301f39e58079095a9ce71a69cbea57095
ubifs: don't trigger assertion on invalid no-key filename

BugLink: https://bugs.launchpad.net/bugs/1866678
[ Upstream commit f0d07a98a070bb5e443df19c3aa55693cbca9341 ]

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: <stable@vger.kernel.org> # v4.10+
Link: https://lore.kernel.org/r/20200120223201.241390-5-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/ubifs/dir.c