From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7738D32B11D; Sat, 30 May 2026 17:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780160684; cv=none; b=YppDjv6ZjkbQPvgQl585VfJuYTDa5b6eowHQxxxdXtt1OOrNDPlfFLDKneEPPjWNpqXK9VzjYdG8PeWXCtVHRPDi7nvOiqVp37qxHQcBAcPUTQjSG2EJaXK4mSC0XM4rMk7VtWrU+dT7bQnCo875ZJzRUfJzKQ+PF9jYc89Gwe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780160684; c=relaxed/simple; bh=bz8lNXsIhRkOmchIc7yzMw9ugwNbWlWnl+2UUvqH/Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PldevPf6MEWmolGwSXFb1G70ABzIiyyB70+K/YFPspvzzUbOEBWE/xvmhwtvfgi9Xhw9Z1hfr3oQAOivWvpp0OHW9Cft2QojbiK+GQEIXdcIeIiTR5S4TApcixqutjIqU+6Jfp3b48DGL7jvBhKr5OSWQ4iuRr7Rd+GmWdJh7b0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UNBDv4SF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UNBDv4SF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A48461F00893; Sat, 30 May 2026 17:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780160683; bh=oHfUuJe8s3b+iHd8qmr2bSftok1Hs18l/vda/+CEwKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UNBDv4SFadsq54glto00myeMQhxlFJTrfEjKMqZjpd6ZETZSzdRVC7c9yWKS1GCCD lddDI8Wutc7z7nwiqXRB8EOmWpQNIkWrugQLk02ZfT9xZqheCg60F0Hu41UAE19zoc 1Le9FU14xx/Y5Mhorjs4HzzhRyoOQCtnRsVIaQS0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cen Zhang , Chao Yu , Jaegeuk Kim Subject: [PATCH 6.1 375/969] f2fs: add READ_ONCE() for i_blocks in f2fs_update_inode() Date: Sat, 30 May 2026 17:58:19 +0200 Message-ID: <20260530160310.663012976@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cen Zhang commit 5471834a96fb697874be2ca0b052e74bcf3c23d1 upstream. f2fs_update_inode() reads inode->i_blocks without holding i_lock to serialize it to the on-disk inode, while concurrent truncate or allocation paths may modify i_blocks under i_lock. Since blkcnt_t is u64, this risks torn reads on 32-bit architectures. Following the approach in ext4_inode_blocks_set(), add READ_ONCE() to prevent potential compiler-induced tearing. Fixes: 19f99cee206c ("f2fs: add core inode operations") Cc: stable@vger.kernel.org Signed-off-by: Cen Zhang Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -597,7 +597,7 @@ void f2fs_update_inode(struct inode *ino ri->i_uid = cpu_to_le32(i_uid_read(inode)); ri->i_gid = cpu_to_le32(i_gid_read(inode)); ri->i_links = cpu_to_le32(inode->i_nlink); - ri->i_blocks = cpu_to_le64(SECTOR_TO_BLOCK(inode->i_blocks) + 1); + ri->i_blocks = cpu_to_le64(SECTOR_TO_BLOCK(READ_ONCE(inode->i_blocks)) + 1); if (!f2fs_is_atomic_file(inode) || is_inode_flag_set(inode, FI_ATOMIC_COMMITTED))