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=1796386405; b=X4iHaW7InsTU4o5D0jOtAFFslMnGHFot6IrZPrWkxsn1Y7GoL1UYZ+3V6DAL9QTfP54P 9IfMkM8LLj1PN+1sRrqQFVGFOhATOUyDG/7/Zf3HW+ja0GZOe/PARv2PdyeXhKqI7tWZc Fbx9U1o5R58n6aqeUb7m7MoWyv1VRM4DnKb/Tv8tQpczEopw7bzys23ACDLw1uSGH5gft rU3cNWZ7c7qjoqdoIbdggXmEJEgLB/0HrLS24NpNqaBtSlaxX+3+nqpxIimWvx5lgqA1l OxlVzTSSWT+YRsYEfXlnTu7QPvs01AXj4pfUwsLdk32r/QuILqHcUBBW8tG0xDSROZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386405; 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=Kxd5W979mM/5olLh3b1NnAvIQrjvMFF0qAOx6xSulKE=; b=zJR+49thsksvKEIwFXKU0uHtY/utCxc5RaZyXnOeG4DQNqF2aV6A5SC8JlGQWDeSQkwn 7TJtE+hxILEP6fh8mnZlSQz33Et8iVfeKQTVCD578l8Wx/bGvPYsv+dNifjeWe3A09AHf 4V6YMS1C6O2tqnnHhOsvztndND1GSxs4kWs7H5DeBk3tZOI/B7831bgLEsgxUUkP0av0k gUDNFzu7wm6+qriP7gwKLacJyKNpwjog7EM3RcuWZ0/IYbxErzpLMWqUjVxp5zurxHhkP qyf1vNqsuvovUxlWmPXP2Du3JIczna1JjOqKd4znqHtDz0qUNQvY/h+K27Rbn8Uy7sA== 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=NWqrAsVv; 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 BBD14606A32C; Fri, 4 Dec 2026 12:13:25 +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=NWqrAsVv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5921E1F000C2; Fri, 4 Dec 2026 12:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386405; bh=Kxd5W979mM/5olLh3b1NnAvIQrjvMFF0qAOx6xSulKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NWqrAsVvwYyPGQdXbClxL2CFDSgogpUPtBjSdEI8+D+btp7cE4Dm9XhSPEBx/4VRl YsYNDyr2ksK1M5/6bV4mRpFeq8EHpi6QKUF49PwL6O6pnFI/7s/Z7T3j1AVJqVeTAp UhBoS4b9+4UyMnMXSFIBnvVl5Skq3IJ885OKPpHg= 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.6 0949/1167] jbd2: set JBD2_LOADED under j_state_lock Date: Fri, 4 Dec 2026 19:06:16 +0900 Message-ID: <20261204100726.908667802@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 ad3f522101aba..d94d272c0092a 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2142,7 +2142,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