Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2490325pxj; Mon, 10 May 2021 04:21:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN8FXxahoVWM7r0vLNklTIfiDHwhDQ9gqRq8k14Au+OdghKLWOM73tXR7DMWlhf6rbcJRo X-Received: by 2002:a17:907:3398:: with SMTP id zj24mr22384627ejb.354.1620645710100; Mon, 10 May 2021 04:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645710; cv=none; d=google.com; s=arc-20160816; b=jM1wONf3LPrnIqVArUdf8jYbdMoE/4xrNSySfh2ctAfpv0QpuQgY9Em3+LHs4fI7G6 QxwbxWG6U4Ee5Vto4P46DA9tEOzVwGfr78QDYJ5Ag3AAXaBjyQ0zLZ7V7JGzQ9IHB590 weEK8n1cXW9sDXwLaYw6oOSx0X2k6Yc6WUE2JUgfpBrKyDx96JwOnyfVctc3zoS9AIL8 KdmX25FsTfiPGSbB7q9h4FsKCFA8LaRymsjkihI5VUeMvMH7sJ8+xH+ZXqDZicwcx7ec 45/TClMIwKbA9yfoMcChngBc1Sm8ihXlA4EmDQowTlvZWRK4CNRLYL9Q8Flov9WkyvOu kZAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d02ivladdkJN/W343zVAkql+GEBzIM21XmCi/NQABQ4=; b=KPensb0AQz6h9XdsSAgu0FAxDyQ2NztJXxYtJxMmP5GvvcAay+r5wKvfKJza+ZAqPT eiqK0D2MwJWNP9zxm38AF4US0m43Zw9Fil7BNHMdfUUVzLtrG2A5NZNyJ8T62yIoeAkC BEa28ooGpVKT+y43rxsA7slttvDfl7gd798zI++Rx18mYaD9LUCPh3aHlyftkFs80yOQ TOKFO8ZQSJMqMbEOE9wnq1BU9hAfWsbjx81/N3OM6AHQnjVeynZXsE5+dkgaJ5U3fYQP 9bNtf1nUM9n/QYTeuuueAxnE6LURxHJTgsH6D0ksXfBKNHoatcRlR4Q4nnaf05cKU3lH ltTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+jYZXKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz22si8792833edb.24.2021.05.10.04.21.26; Mon, 10 May 2021 04:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+jYZXKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238488AbhEJLRu (ORCPT + 99 others); Mon, 10 May 2021 07:17:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:41711 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233058AbhEJKyZ (ORCPT ); Mon, 10 May 2021 06:54:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 00FDE6191C; Mon, 10 May 2021 10:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643314; bh=Z0wYcN899ocdNzLotbRtqJ4W0IGmBtUATHKOr3zkWxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+jYZXKr0rqh80gNADq8yppSU7lyYjuQ3M/x8Rx4VJeWv5ajMw0uOMWIni6/K5VHQ 0i80X6g7KBzSN37d7k3pD9WhOqbgYj8j5f+IVBHesT2ic9YeLSgeI7kHt/BjoMOROs AJDfHePvPkWEHa/mSRSTM7pHuaMPa1quzjLGPXjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, syzbot+30774a6acf6a2cf6d535@syzkaller.appspotmail.com, Jan Kara , Theodore Tso Subject: [PATCH 5.10 264/299] ext4: annotate data race in start_this_handle() Date: Mon, 10 May 2021 12:21:01 +0200 Message-Id: <20210510102013.664483002@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit 3b1833e92baba135923af4a07e73fe6e54be5a2f upstream. Access to journal->j_running_transaction is not protected by appropriate lock and thus is racy. We are well aware of that and the code handles the race properly. Just add a comment and data_race() annotation. Cc: stable@kernel.org Reported-by: syzbot+30774a6acf6a2cf6d535@syzkaller.appspotmail.com Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20210406161804.20150-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/transaction.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -349,7 +349,12 @@ static int start_this_handle(journal_t * } alloc_transaction: - if (!journal->j_running_transaction) { + /* + * This check is racy but it is just an optimization of allocating new + * transaction early if there are high chances we'll need it. If we + * guess wrong, we'll retry or free unused transaction. + */ + if (!data_race(journal->j_running_transaction)) { /* * If __GFP_FS is not present, then we may be being called from * inside the fs writeback layer, so we MUST NOT fail.