Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp175442pxx; Wed, 28 Oct 2020 01:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEy966nwjb9lxAl92TuSwMz4vtvnozMFT9ArRkTCFrjP5g9QMEdKwhW6pZ83e0qGS0UxLx X-Received: by 2002:a17:906:8610:: with SMTP id o16mr6233354ejx.209.1603874352770; Wed, 28 Oct 2020 01:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603874352; cv=none; d=google.com; s=arc-20160816; b=A08VgJsS94flxcWWJnaRXGF5oB5wO3x79sAnk8qaxVF0qZc1OrSENPfCK/LJFSQxBf iAX2ch4IQ3fFDuK/3HEdKeofZ8mlHBF/XufTueXT0NADsc9e7kJbxDUuJJs87InVwEZE PnXwDI6CeFoPt7y3S/fU2L9fBtz7AENd+wxgUmJQAKv4gNTo0bjTdntsSrOwn/+XHg0U tPKEZSWp1UVcJS7g0Md+5yarPkP0GI1QNDTSiUUMQp0HuMfZMhl1a5GylN8s2AZccYmg KtZ5f9+8qcGZFgPTQTZZe0mqTdMSR3MNhgmkis8mt9VVTyGVzSDoFtvrpAyaZpYouk4r D7oA== 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=+SCQHPinWQKG6FdTS64Xk1XoYtc3rHhIwvzad+w35bg=; b=aMOpl/4E/63oWfw38n9PR3F3cJJVufVWPKnPBo1oLodGi+9CiRMKMGNQwTAMjVbXwl oBo9TxOAKb8dDAjKBC/1DWMYtIdC3XBZZ0UB0OkE9GKSSO/JPRCIB0Co0MDHVJLp7l0X 11ghLEmrnoRfEQq9iKdX5wrBBgedaxKB4LGj3Bf1iFz6ZAmPMG5m2T/KHSsgE8cXAFto clOfHIBYHN7WaJzAODlzvibJT1+AZ2FXlxhKx+A0g2PMTYu0UxUG4MYHTxkA4wJKac/n HKC30P0T9MfcMck5kcUnzDhtVvmvxZp9KVHH65kMbuvKEhOtMXg3AHgqWDKTmg9RgX2A oTpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UPpvmWZF; 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 dk22si2709939edb.258.2020.10.28.01.38.50; Wed, 28 Oct 2020 01:39:12 -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=UPpvmWZF; 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 S1754893AbgJ0OHe (ORCPT + 99 others); Tue, 27 Oct 2020 10:07:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:55754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754795AbgJ0OHH (ORCPT ); Tue, 27 Oct 2020 10:07:07 -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 B24F422258; Tue, 27 Oct 2020 14:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807626; bh=KDEjwspJyIH0+HO6uIy5jM5u5QAk6OY+cIrgJ+2DZJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPpvmWZFhu43YNbbykguJth0aAojtGcf/9YMjHzuRNqi/XtwiP1t66IW0fhSlIj0t 3XW1sUtqqSEv2E1GlnsZq9AGphYvpBOoMc8Gmgd0d81pGWz0ZKwHHFaGzOXEB1CkeP PAKvajXmWZUC0gY304No5SETj8t7LYCz2nBMN0+A= 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 4.9 121/139] reiserfs: only call unlock_new_inode() if I_NEW Date: Tue, 27 Oct 2020 14:50:15 +0100 Message-Id: <20201027134907.890094564@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@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 897154e993800..f28999f717761 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -2166,7 +2166,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