From 6132433e400ff7be348fe04fdf8ee67eb105ec21 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 10 Nov 2022 16:22:06 +0100 Subject: [PATCH] ext4: Lock xattr buffer before inserting cache entry --- fs/ext4/xattr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 36d6ba7190b6..02e265bb94e2 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2970,15 +2970,18 @@ ext4_xattr_block_cache_insert(struct mb_cache *ea_block_cache, struct buffer_head *bh) { struct ext4_xattr_header *header = BHDR(bh); - __u32 hash = le32_to_cpu(header->h_hash); - int reusable = le32_to_cpu(header->h_refcount) < - EXT4_XATTR_REFCOUNT_MAX; + __u32 hash; + int reusable; int error; if (!ea_block_cache) return; + lock_buffer(bh); + hash = le32_to_cpu(header->h_hash); + reusable = le32_to_cpu(header->h_refcount) < EXT4_XATTR_REFCOUNT_MAX; error = mb_cache_entry_create(ea_block_cache, GFP_NOFS, hash, bh->b_blocknr, reusable); + unlock_buffer(bh); if (error) { if (error == -EBUSY) ea_bdebug(bh, "already in cache"); -- 2.35.3