Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp424570pxx; Wed, 28 Oct 2020 08:04:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZWr15ZkD3gZj7YZ/2tJHse5E/bOzGLFsJJ+kvf2QzM43alO2c8KoGpEwqHuT3IGZh7Y3v X-Received: by 2002:a17:906:4d4f:: with SMTP id b15mr7856396ejv.356.1603897473865; Wed, 28 Oct 2020 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603897473; cv=none; d=google.com; s=arc-20160816; b=VZ4xAVmrSZv46EAKe1ML+MxBzbC9UDns1j+ucWynNNr7H+gkWB8TWd+iycDgi+heqD PQwexyQa6DFVYX0SiKvHbqUnFVoVuI/nQHwYHro9oFoTQRNcP657BsrAtXvK/HfmVtx4 HoSI8w0FpPE/kDOeA6IU8lSfqSnBkbtUOVHRNGT/zG45IEHdJm1LwnPnfK0pAAq1hpys vQqUWMrZTdW5CznhMiSUoWK/4Z5djtN3fx8ne9/UIIJSNXhhjJ2m7zHW5yz9MkD/K7Sv gv3CQBb9xIvFgjHefMnnLXCAE27IwLCmSiyLw3M6/FB6/BIoJemWyyA41Txn5Ldk/Iqt ZI1Q== 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=YNg920LaMeks0YluEzSmMpLbDSkEBIcRhWCz0SoLuIE=; b=ihlDyHpInVcWpVMGwkCnVisVAuCKwL2pKHsFx+d4NkVA7lQu2F4mKx0AEprkcnDAbY YF+sBofVGg041gJqrCEiOyxZmWMYp1ImWx1NxzjStO1d7uLgTbNO7Os4BkfPsKm006aZ DeTFRtwKQ3epGcJlT3Azrh/0abOG9jW2LoVVk+fZsOODIauInXgfXg8Lyc869In3rXE4 3ZZMbViFXH1j++i71z81ZM4TyC7zSxJV5YuDu7TOFrfkTCXkwcQBptHp6VyaambEOr0d JTTLFikf/S3aldABMn5F8wJwu3n4APnlbbwJo2Q3UWqAzygcpI5b86njOusouOG5HkkJ FTww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O4FOJxFR; 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=fail (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 t1si2868715ejb.712.2020.10.28.08.04.10; Wed, 28 Oct 2020 08:04:33 -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=@kernel.org header.s=default header.b=O4FOJxFR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1809739AbgJ0Q16 (ORCPT + 99 others); Tue, 27 Oct 2020 12:27:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1802798AbgJ0Pv2 (ORCPT ); Tue, 27 Oct 2020 11:51:28 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 038312065C; Tue, 27 Oct 2020 15:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813888; bh=lcTJaQN1WGdU+Bb1WNrFYiF9gQXh1tpXRdGxvpVmdRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O4FOJxFRck1WdonFuD+YLonxJ3njwCkZsqHJhSd5lT/oEezA+ntjapTtnSqzbg9J7 J0fWhzifsEA8RuifEMVA8QJQnUcfH6kjY48T5qK8N19FYxjYLNJeZ1Jc0di/mATDd9 Lkgxr++oS6vvIAwPexvGvRqkeH48P/w4OCpXe+Kk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+187510916eb6a14598f7@syzkaller.appspotmail.com, Eric Biggers , Jan Kara , Sasha Levin Subject: [PATCH 5.9 704/757] reiserfs: only call unlock_new_inode() if I_NEW Date: Tue, 27 Oct 2020 14:55:54 +0100 Message-Id: <20201027135523.524442714@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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: Eric Biggers [ Upstream commit 8859bf2b1278d064a139e3031451524a49a56bd0 ] unlock_new_inode() is only meant to be called after a new inode has already been inserted into the hash table. But reiserfs_new_inode() can call it even before it has inserted the inode, triggering the WARNING in unlock_new_inode(). Fix this by only calling unlock_new_inode() if the inode has the I_NEW flag set, indicating that it's in the table. This addresses the syzbot report "WARNING in unlock_new_inode" (https://syzkaller.appspot.com/bug?extid=187510916eb6a14598f7). Link: https://lore.kernel.org/r/20200628070057.820213-1-ebiggers@kernel.org Reported-by: syzbot+187510916eb6a14598f7@syzkaller.appspotmail.com Signed-off-by: Eric Biggers Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/reiserfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index e43fed96704d8..c76d563dec0e1 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -2159,7 +2159,8 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, out_inserted_sd: clear_nlink(inode); th->t_trans_id = 0; /* so the caller can't use this handle later */ - unlock_new_inode(inode); /* OK to do even if we hadn't locked it */ + if (inode->i_state & I_NEW) + unlock_new_inode(inode); iput(inode); return err; } -- 2.25.1