Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3933194imm; Mon, 8 Oct 2018 11:55:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV61v67Xdmby8YqfcqfsTWAwd/ireqRcoqji1qz6FwPM/8DGoRgq7PintgLjtViG3WmS5rr1b X-Received: by 2002:a17:902:3a2:: with SMTP id d31-v6mr25259083pld.287.1539024932385; Mon, 08 Oct 2018 11:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024932; cv=none; d=google.com; s=arc-20160816; b=k+2SAarvcqw5OF+R0/Qk1G2+XcZGuogtArtf4sGH4bINQR7Su9fx0KUaIPDrKAF49U xVFaVNHTBeiXGOyajP/hOxS3dN1wjnkkpL31lQ7o5ABex4I2iRLLzKBhvG5n8qFIywxj 2jsgqbIQWIBOZ5ugMROK6MfAK9bm5hKNQ6I5xr+sfLFoxq8zDqqOgxmbSKeAlu3gvjtY qykARbNooBToZwLzkKexMLf+iYSXdupj090idi8LDGseCT6g+sp1nROwe3uxYJCtqrjp wqNafzmKmnD1cK6LeX2cEqmrERrTmYS+xufJ26CwDzrUxRfTKOSH4zmNceM1zjWQvqHQ cYcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kCNMCq40zJ1w4aMb43KD3tIhQU4JMhNDE9R0jqkNIfM=; b=DJ/tIMc+14pdBwZi6uVvzqY1npdt92u3X4bm8F2P2GoY1Rl5xJM534/NnfgZLKHBYN mCGNWnZ0LLtXPNNAy8k2f2QgIDPaowo/kgg/acxk64ozpMe+pza8QcwPZ2DK7F8JDRZF yvKhxgQLFObvP/6xbYbE4zKCuoO58k8f0dURsnq9sjDX114PMl0HXiQU895zyN2UfSc0 I6SmR4A2+6W7S2k8Bhkw4svAlvbEdFN9xPGaMEqB/5VK46WkNC1928t9vEt6vyIjPQY6 v1n26hReBQIRYix8gyEN8j7aflClt9nacvJjOCJr7mJhUYwGlz55zX7QEBQXUFsnEpb+ GEbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GP28VLer; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15-v6si18763534pfn.248.2018.10.08.11.55.16; Mon, 08 Oct 2018 11:55:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GP28VLer; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732836AbeJICHE (ORCPT + 99 others); Mon, 8 Oct 2018 22:07:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:57496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727670AbeJICHD (ORCPT ); Mon, 8 Oct 2018 22:07:03 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 5A9002087D; Mon, 8 Oct 2018 18:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024834; bh=9RUqfFoHl1DiWW0TuhcOObT0fweYzo+aXSPH206eO3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GP28VLerEpa/aJX7r+QGMV7rfjjtnn8Uk0KeOMiSD2V1WcmY7YzBoU3jDJvbB3Oby z95MYtLDKpt0kuIs0WaO4Chgs9awr2vvjnwQPedaxgCvv1i6nOitBAFbk0xZAXAef2 Pt1TKlg5FoZBE21VRMIMlZ1IQUkb/FkFrhnE6MUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Miklos Szeredi , Amir Goldstein Subject: [PATCH 4.18 145/168] vfs: dont evict uninitialized inode Date: Mon, 8 Oct 2018 20:32:05 +0200 Message-Id: <20181008175625.543394600@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi commit e950564b97fd0f541b02eb207685d0746f5ecf29 upstream. iput() ends up calling ->evict() on new inode, which is not yet initialized by owning fs. So use destroy_inode() instead. Add to sb->s_inodes list only if inode is not in I_CREATING state (meaning that it wasn't allocated with new_inode(), which already does the insertion). Reported-by: Al Viro Signed-off-by: Miklos Szeredi Fixes: 80ea09a002bf ("vfs: factor out inode_insert5()") Signed-off-by: Al Viro Cc: Amir Goldstein Signed-off-by: Greg Kroah-Hartman --- fs/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/fs/inode.c +++ b/fs/inode.c @@ -1050,6 +1050,7 @@ struct inode *inode_insert5(struct inode { struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); struct inode *old; + bool creating = inode->i_state & I_CREATING; again: spin_lock(&inode_hash_lock); @@ -1083,6 +1084,8 @@ again: inode->i_state |= I_NEW; hlist_add_head(&inode->i_hash, head); spin_unlock(&inode->i_lock); + if (!creating) + inode_sb_list_add(inode); unlock: spin_unlock(&inode_hash_lock); @@ -1117,12 +1120,13 @@ struct inode *iget5_locked(struct super_ struct inode *inode = ilookup5(sb, hashval, test, data); if (!inode) { - struct inode *new = new_inode(sb); + struct inode *new = alloc_inode(sb); if (new) { + new->i_state = 0; inode = inode_insert5(new, hashval, test, set, data); if (unlikely(inode != new)) - iput(new); + destroy_inode(new); } } return inode;