ubifs: Fix races between xattr_{set|get} and listxattr operations
authorZhihao Cheng <chengzhihao1@huawei.com>
Mon, 31 May 2021 12:52:09 +0000 (20:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jul 2021 06:53:16 +0000 (08:53 +0200)
commit7adc05b73d91a5e3d4ca7714fa53ad9b70c53d08
tree3280b8ae2eada818170478aac1f0755fbc759282
parent5e4aae9e3e6b16485ebf9053477cb81502df268a
ubifs: Fix races between xattr_{set|get} and listxattr operations

commit f4e3634a3b642225a530c292fdb1e8a4007507f5 upstream.

UBIFS may occur some problems with concurrent xattr_{set|get} and
listxattr operations, such as assertion failure, memory corruption,
stale xattr value[1].

Fix it by importing a new rw-lock in @ubifs_inode to serilize write
operations on xattr, concurrent read operations are still effective,
just like ext4.

[1] https://lore.kernel.org/linux-mtd/20200630130438.141649-1-houtao1@huawei.com

Fixes: 1e51764a3c2ac05a23 ("UBIFS: add new flash file system")
Cc: stable@vger.kernel.org # v2.6+
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ubifs/super.c
fs/ubifs/ubifs.h
fs/ubifs/xattr.c