From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383546; b=5bAa+hpr2owcaMacLUzZuhQZXD0ozL58r7oT8lSs+Cxi2/8hpQOD7u97ZdaCE9eeQPlw yhaaHQRppU/8RRcX7zSg8jE27YPw1QJOzQrN/ZLSrMGD/AwuYXWjGjbTciQ/8m1oYOs5m gWQ0oScbpTESO8FE/RhqX10iw+c62oZiUhgKVLEiGdVuus4pQ/PXNpvwchRaFTiRPle6p Cx7kxalK8tTdZLq4QJv7IurD3K3WtVMsAsvYOHqfamqWFNbi+YwJPeEU6uYKGR8o9DFHY pPTc1R0M5qwVyYDsVrxWOSIlgCh5EOOIB0diYeNwaj2hWy1Gm3ZO4EzS1AZh+9WAuMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383546; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=ZsK/wjDuaffDptGUBUSwi44R0KbvRtu0JRzuKJ8Yg9g=; b=dUmzFu0S2RBs5Dc5w9PGi0CGOtjLli7fIj8vEzFs7hxcqpCyO53Ed/HWku84QBpHzJXE 4E/XwgNlazhdG3ZDjhz8h7W0u8yJRds+3aCFHXshSVmnegriTBtPnkV6eeTSyXmw5dzCg jDChirU0RzNmtwk6oeH0EZUIqbRyOFLrPOumMmJ5IOEtDafAPvSGQNk4CvazSGtr76/3E 33Qfb3+sQZmP5DJqIJmST4/+IJTCcEX0G7iCkhly5svKhkg8gESigY3ctgA2pLYUl41Pd QGqzakg22M5raNPcrQMAZekNbDFzGv/umnCD/dwx3EgX0pPMYtyF/qdaEH+ViLIqygA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kpNcPLQo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1F67606A322; Fri, 4 Dec 2026 11:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kpNcPLQo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27A081F000C2; Fri, 4 Dec 2026 11:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383545; bh=ZsK/wjDuaffDptGUBUSwi44R0KbvRtu0JRzuKJ8Yg9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kpNcPLQo8LneMpLi8XL2R/FNfLNDstkWJ/BVQ0UOCw975G38e2ZR4FSwEtV1MXSww Ax/qu1koRQYTeba2/tJAAYkglXMrzkhBVaGGzh+jJ/3eJMVdJr0hcBNMl2bYD4A13T ELPDzEO0o+1zc6bbXVvLhI8jzQkFODGxU4Nx0pxI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20G=C3=B6ttsche?= , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 6.12 266/555] jbd2: set JBD2_LOADED under j_state_lock Date: Fri, 4 Dec 2026 19:05:09 +0900 Message-ID: <20261204100619.230157448@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Göttsche [ Upstream commit 40e53dad45a92e932156de23a69c991f3e2512c9 ] j_flags is protected by j_state_lock, with only quick racy checks done without it. jbd2_journal_load() however sets JBD2_LOADED with a plain read-modify-write after journal_reset() has already started kjournald2, which tests and may update j_flags under the lock. KCSAN reports this while mounting the root file system: BUG: KCSAN: data-race in jbd2_journal_load / kjournald2 write to 0xffff9c6b012c6000 of 8 bytes by task 1 on cpu 3: jbd2_journal_load+0x279/0x3c0 ext4_fill_super+0x34dc/0x5740 get_tree_bdev_flags+0x21d/0x340 ... read to 0xffff9c6b012c6000 of 8 bytes by task 77 on cpu 0: kjournald2+0xc8/0x3e0 kthread+0x1bd/0x200 ... value changed: 0x00000000000000a8 -> 0x00000000000000b8 A concurrent update of another flag, e.g. JBD2_ABORT, could be lost. Take j_state_lock when setting JBD2_LOADED, like the other writers of j_flags do. Fixes: 470decc613ab ("[PATCH] jbd2: initial copy of files from jbd") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Christian Göttsche Reviewed-by: Jan Kara Link: https://patch.msgid.link/20260928202159.2463182-1-cgoettsche@seltendoof.de Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/jbd2/journal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 67dc1903d53dc..47b39ad7013ea 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2112,7 +2112,10 @@ int jbd2_journal_load(journal_t *journal) return err; } + /* kjournald2 is already running, see journal_reset(). */ + write_lock(&journal->j_state_lock); journal->j_flags |= JBD2_LOADED; + write_unlock(&journal->j_state_lock); return 0; } -- 2.53.0