Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1121809pxx; Tue, 27 Oct 2020 08:44:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfS/HoCyBKAU0oXnFUNqc1jg3HR0ki8LUyM1gNRNPC1kxpvda/x2yeQcl+bVfzRUsU4qLk X-Received: by 2002:aa7:d597:: with SMTP id r23mr2809022edq.19.1603813496997; Tue, 27 Oct 2020 08:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813496; cv=none; d=google.com; s=arc-20160816; b=jG3hxUXutitoJ08fd2mPK5FoLEbD7g4TlIWryK6822RmSogB/AptO7cEBtH3sFlz53 nWIwN+YCth+rCC2YXk8lwYeYFMkv9R3wjbr0phB5Mj+WLDwVdmE8e67cEDBcrpN0mdhV +8dT6ejizmgwwdf68DPllHGYP8/a5mCR7V5xbxo6Aw43kZo3scv3VeuGEZ9t8o6bGjkL ZXt0Cd68hGZvOGraxmiVuDgWNj2hLANC1TBZNecS/LpIaFpmKl5mKkjapgi2ND8AQHU1 PDwq+5jDGtf1VaZNZCo8KfoLrxiIP2YFROk4NqzAX//gZgGwkDx/esa0mkC9oJukDVBF upFw== 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=qAqeaFqCxu0ATK0KmbenWUlrMMZU2c96nAb3Uz/72Wk=; b=iNxFiFr43AFGaUYnhdiQmwUMmkAbr5AQa5HzU4AH/vdSYOBCy33CPN549vqu+5KW70 lCihZ9ttmMnnYRW1jmNBClD4MnEdC98X9kaLv5Lf4EA8oMqMpDGNCKNC7yrcK8Lx+3Cu 2DGnW1qrNKWvMQ0Q2apaOYxL4PceCJ6RN1OMgWAeR1VIz5ISdCZ8KetapR/6xZRRpJsc fCSxBOf9Uya4x4WnpthIdXH76jyKFmaOkHbYWVDjr5C0J0sk2SSk9PWqDUV8qWBMAEW7 1i6gz+MiyHJ5XmZhE8dgdEa5syg8XqFKyr7Drx7n6eOkVT/JGuCCasl+QcTrFjMGHrYY Op3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o5FYV/xR"; 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 e21si1097885edy.555.2020.10.27.08.44.33; Tue, 27 Oct 2020 08:44:56 -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="o5FYV/xR"; 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 S1763978AbgJ0Ops (ORCPT + 99 others); Tue, 27 Oct 2020 10:45:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:45364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763892AbgJ0Op1 (ORCPT ); Tue, 27 Oct 2020 10:45:27 -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 35F342225E; Tue, 27 Oct 2020 14:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809926; bh=f+GTbl0pKb9hkZ+SMutdzDj8ZJsIrhD8MfsYjapkD1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5FYV/xR8x5AT4xZS27b83TLqDoGR/H5M2xIZiW2NYoZPziHWR+E6wK0LLTsqmOHy F5g3R1C/yiWUJicOIG5lPSua30VhLRDx++9OAWFfrO5BsFzAbbAfVjCSIsQZjh58UM G4MBNyuh28P0AfzinhzOTboLNCUhi7d+XLhZf6kI= 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.4 368/408] reiserfs: only call unlock_new_inode() if I_NEW Date: Tue, 27 Oct 2020 14:55:06 +0100 Message-Id: <20201027135512.082929769@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 70387650436cf..ac35ddf0dd603 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -2161,7 +2161,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