From patchwork Tue Oct 27 13:50:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 311812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41C7BC388F9 for ; Tue, 27 Oct 2020 18:07:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5CF020723 for ; Tue, 27 Oct 2020 18:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603822066; bh=kAHmD3REEo7pD5B4CPH3+kDd7e75hwALAHz76Bbpm/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rHvavvaOsdbuBLdEiUJc0kb7quzsgVZyjxsNkmH+K0OkCE3dRWF8s4nvQTNBVnbJ8 JY40KbGrWUYfc+n+nZzHDVXAznbyk+ShrzvAnlFaZMINzg79sltxJ5aXkGtRqvce2w YNNGL9Cm7Kyi0FQRRPZEbgTMRBFFvyQ+C+vXW4IA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1824777AbgJ0SFr (ORCPT ); Tue, 27 Oct 2020 14:05:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757224AbgJ0OQ4 (ORCPT ); Tue, 27 Oct 2020 10:16:56 -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 114AC22265; Tue, 27 Oct 2020 14:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808216; bh=kAHmD3REEo7pD5B4CPH3+kDd7e75hwALAHz76Bbpm/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QhgfpNBCvKHZ69EC88V2tgbeKpNxbqDyt5/qm8hQUm/7vVQMviB7mwQKVGoT2fCiL CndhDCecoQ3WMnPKH6TAYEU5+A5fyJ3c+TTVuhJn6H5qjhWcg9Bbza8cuPhccA/S0y kHfIX1Oc2PVDiD/nHWtiJHymHBG5EbUWQc7OTXX8= 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.14 168/191] reiserfs: only call unlock_new_inode() if I_NEW Date: Tue, 27 Oct 2020 14:50:23 +0100 Message-Id: <20201027134917.799576270@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 4b0fed69e0330..06c4d376b0e39 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -2160,7 +2160,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; }