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=1796380425; b=3n0LXhCrzt1cD2cWORwOGkf5ysU3lSJaEAMywDkFKCymAEx3CWMerVuV+X2QK4L1jwhG pJuXhtK9SLDp2QqR9cE4DkmUdm6OMWlX9KR8a35IDl/iPL/iJ1CzRrNiMQZZql3fJIhcR PTefEL2ciO7ITk6c4bbvEJO/wTiZmCsjT6AWeoK1vGAD/Q1LNUyGGhxclw3Vl0OQQJgZW tLsbqp19dtPrle+1U/9d4svOTlnQ/+PDO38ooXFTUFz0NWfAVi+6Dj3ypv3KLxMYLq7Gt YAPa7Lvtje2SiflrrWxBGqzax/uIiTGezr3er8xzFeU1Wh5BZuYWTEjrl6zkicI125Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380425; 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=wf4XKaQuLcsFbsT3sNtx04kobqeTsw3yiqSu2QsPMBE=; b=zPk2nH2kpTIuDfSbBdR6LjAIQXi6sCQQPF/O1HFgWCeBBqJBegZnfW4UlqOY2Frnz91S Mi+ZRCznEV6anWGk5X8hyJHJPNTTKR62DMbRLcTf4diyv4QSgMBImCFO31qZfHamoc7kC Iz76gBkPqbaUUdOD7AVMDcgNogRfHJvHHgcWiXidumWJ+4oMmDDnp0KyLY34s5kfHcsDl M86DxiD6IBndeEe1Hbf/nqQypLX0w9PnCvjToydx7o+JZFH6nCQkVDeGsGm52pzHP2Dp2 cs5HhwJenUh9gg2uhudKTFrWMyMK+umaaZYqF+muoKBFE6t0t2EnK9Av7nq6mx2xWQw== 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=gR7Nyd3c; 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 08CEE606A333; Fri, 4 Dec 2026 10:33:44 +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=gR7Nyd3c Received: by smtp.kernel.org (Postfix) with ESMTPSA id 339811F00897; Fri, 4 Dec 2026 10:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380424; bh=wf4XKaQuLcsFbsT3sNtx04kobqeTsw3yiqSu2QsPMBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gR7Nyd3cRXI+UaA/phxjOTrp6RhvPZES4PlUDPdntmvp2+91LU/d+fcy6H8E8PJFb 9mX83AuzsdtTkE1hzvXVth+O+pzapPBmgSy9asitOmDyeKmJvpCDifw1sXW33kaFuQ c4ZJXstVSVJwytQG7bb6r6f1KxIE6duNriwwXXI8= 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 7.3 227/742] jbd2: set JBD2_LOADED under j_state_lock Date: Fri, 4 Dec 2026 19:01:31 +0900 Message-ID: <20261204100641.105790305@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 55b4ce0102289..a10623504234e 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2091,7 +2091,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