[PATCH 0/2] ubifs: Fixes for xattr concurrent operations

From: Zhihao Cheng
Date: Mon May 31 2021 - 08:42:58 EST


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

Patch 1: Import a new rw-lock in @ubifs_inode to serilize write
operations on xattr
Patch 2: Remove unnecessary ui_mutex in ubifs_xattr_get and change_xattr

BTW changing @host->ui_mutex to a rw lock to adapting xattr operations
is a risky method, since @host->ui_mutex acts as too many roles:
* serializes inode write-back with the rest of VFS operations(such as
rename, mkdir, rmdir, create, eg.)
* serializes "clean <-> dirty" state changes, serializes bulk-read
* protects @dirty, @bulk_read, @ui_size, and @xattr_size

Besides, if xattr operations and io/vfs operations share same rw-lock,
xattr operations may effect UBIFS performance more or less.

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

Zhihao Cheng (2):
ubifs: Fix races between xattr_{set|get} and listxattr operations
ubifs: Remove ui_mutex in ubifs_xattr_get and change_xattr

fs/ubifs/super.c | 1 +
fs/ubifs/ubifs.h | 2 ++
fs/ubifs/xattr.c | 48 +++++++++++++++++++++++++++++++++---------------
3 files changed, 36 insertions(+), 15 deletions(-)

--
2.25.4