Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2530995pxj; Mon, 10 May 2021 05:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9tThRqgshQd5JkmSmcpEi9NzbUN6THjr1ailEjaDVP5Wte90QE2FR5PQpYox23lMDixc0 X-Received: by 2002:a17:906:170f:: with SMTP id c15mr25109864eje.358.1620649089645; Mon, 10 May 2021 05:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620649089; cv=none; d=google.com; s=arc-20160816; b=Xk+I49LT4lnn9Ur8mys51E+2W6rcTwZ+eeo3PL3QwmrCh1D+5r41VKxa3aGYo7F+io EbnARNOUJhG8YOWHrsduvJFwRUeECaNg59rCtKRP1Va10AiL9MYPe881vk1CnCnhvwv+ WfiJjUdfe0UuajTnrw4FioxiBcG/lJVqgGofpVZTHXLMCnmdIACNuAEFcGk4Mdmlw+8j MkWElgApMdk01BUWCTrFxQSCez2rTZh1lz+ynMu3c4h0uqtj5X72ZpTu3xMQKOjLdE9p DOb13EImbVX59qE0M33Yyjh2mYko/wGkHZy2Y/n2O0qEoGxbcP8vsNB+widjgrS8GjTx Jwfg== 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=dJMNR+Z8MjqXiOoOuwC9yLkXvKP3eTyoAZ1axmGoLmaV75SpS5cvW3fF1Nj13b1N5I 1uaZRLM0qGVx8EQF1ywM9iONmZR0UDVISvR+mIY4h+IXXsMyStd9eskD5Gkwmm0K114u qTcNE+fNoenw2a90tkuQY+KpnZ7utBWXzTWuPXHUP9aGQ/KJ+/w8s32+mPSu70i12fb7 Hbf9He66U09+6YJq9zW5HS0+FfQ3msbTgvLzrzjtJ3mMnYFoUUXmQq/h5n+z7bVYZh/d 8ndgWWP0oucMWoSVaLZ8w0AoUa+EC/6yxfDOOBosJ1Tc7kzXDbZXm+fVm8HSFrIvoBtX 8fdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="YnURsUa/"; 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 h12si15669645ejx.748.2021.05.10.05.17.46; Mon, 10 May 2021 05:18:09 -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="YnURsUa/"; 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 S1344130AbhEJMPI (ORCPT + 99 others); Mon, 10 May 2021 08:15:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:41148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235611AbhEJLFn (ORCPT ); Mon, 10 May 2021 07:05:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4284961363; Mon, 10 May 2021 10:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644136; bh=Z0wYcN899ocdNzLotbRtqJ4W0IGmBtUATHKOr3zkWxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YnURsUa/INweoSyZDtswqVsiPRliA7yz38QPiNyNYmkC80qH4WrNnGCHPITx+HJra SQph/u+5c4sR2QYLeSRt7g2nRdqFGFVNoEqQ61bhIl7S268PsTH1Xjqmse+SscKrKA A5oZzFNmEF4vqw9mLmgi+4wZnmy/T7+w6h+V0qig= 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.11 303/342] ext4: annotate data race in start_this_handle() Date: Mon, 10 May 2021 12:21:33 +0200 Message-Id: <20210510102020.115773414@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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.