staging: erofs: fix race of initializing xattrs of a inode at the same time
authorGao Xiang <gaoxiang25@huawei.com>
Mon, 11 Mar 2019 06:08:57 +0000 (14:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:02:40 +0000 (14:02 -0700)
commit28b8f234edaf8eb7402bda6d2f9e6a51c9e86874
tree74c9a08307206bbeda0a0410b28bbceb2a36e0b1
parent53a989a95a09cb89ca267c2b2d58aa86b0abb4ab
staging: erofs: fix race of initializing xattrs of a inode at the same time

commit 62dc45979f3f8cb0ea67302a93bff686f0c46c5a upstream.

In real scenario, there could be several threads accessing xattrs
of the same xattr-uninitialized inode, and init_inode_xattrs()
almost at the same time.

That's actually an unexpected behavior, this patch closes the race.

Fixes: b17500a0fdba ("staging: erofs: introduce xattr & acl support")
Cc: <stable@vger.kernel.org> # 4.19+
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/erofs/internal.h
drivers/staging/erofs/xattr.c