Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp49713imm; Fri, 6 Jul 2018 13:46:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcf5BxYNcgGeluxljw1zY1EpFRFIRYjXle3iQqzCW0L7T9ezWiqnLTvHVZKsVhrVFnoJQfL X-Received: by 2002:a17:902:246a:: with SMTP id m39-v6mr11614826plg.141.1530909985978; Fri, 06 Jul 2018 13:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530909985; cv=none; d=google.com; s=arc-20160816; b=xH1HB9sQfpLkqjftYXZgmkLFfooUw+wuNYhBBVjpjChkaNBpgL/Ka36jf6kiTO9OOP y0FnVEY2LXTKP+2yfqwqRbkrM1C5oNiH/bEi+3LgXvYdTAbcb+DN8E48ZaPOZFBZzcxl /Y0RZ0kAqsOhwUJq5sj0Yd6dqzFguGum6Hw0G7CAP7ybl/xfhl5lZ+GvAgT9vPwdduS6 buZ5sxNgI5rQy68FqOha9ur96VgS7xmJH+MY/xpEIuaJ9/gsMw/c7auiZX6T5wr+9+Eb 8gIGZrmtkM2Zn9RfLX7lVjCvLbYCuZCP0pr+leV4IvRF6FASAkc94YZ2ZVqGWjdgpyqE wdRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=p5MFyrylEUGL40LVs+lJKPdZi1bxh4N3wg6eoW82tgU=; b=OejKFc6Yby9wmz+rCRjbk/JKm3PV7wV9IVDM5wBZ/gBuoxST5y4NqP/dpID7JxRNTv A/MNhWiO41q8TAeS13p2yO4XyfwXMJMeeppJcgQO4L+PUVpkTyl2fNktWz/kA89QYdNm KiCdM8c0MLUrfzMTh8EmLN4TAcEvyasyBMJSQgprTzJtQG6LrmxoxahtN8+20fLUyl+R eHkKyK0Sb0qbhzMWQ+oNLvjAj6n68rkLPg+Dg9xwo6dPZ56G5ncwFmNX2LXkXIG5P+cz 57e/OggVeQ1D/5io2SeUduGUozOlFK6z226Prnp8r9xwneBBKC0nWtohfLDscEbhLpaD nc3Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s25-v6si8298660pgd.188.2018.07.06.13.46.08; Fri, 06 Jul 2018 13:46:25 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934124AbeGFUp2 (ORCPT + 99 others); Fri, 6 Jul 2018 16:45:28 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41687 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933856AbeGFUp0 (ORCPT ); Fri, 6 Jul 2018 16:45:26 -0400 Received: by mail-wr1-f67.google.com with SMTP id h10-v6so5304555wrq.8 for ; Fri, 06 Jul 2018 13:45:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=p5MFyrylEUGL40LVs+lJKPdZi1bxh4N3wg6eoW82tgU=; b=aooCUDGfsHF9l3TtqFtCL8fLrlwbORSNa9JmPefEpg4TyouM0z90YFnAtxjOsm1VzL 4DWVNcm52ftGcW83bDB5aS0R4sZtXAudIhGwQbkOUhNDUWs2nEDMt2hWblOisrvtvXrl cIxsXvzm6R4gCTBDgxazfJozz+RM2dJpCtQrCr6vA+09y+bPnNjeSC5ojQBvBJmHsqx7 l7jlFtZzU5XYXTxoGBWWgEOXd1CRRje0pVh5apFqc7+mDle6PInSXlP6C9Ar1odxz9qG V6B1OIB2TABl81WXEUs2iwXGGa1DPsBEuqOhqKMRj5WZvm0Uq7O+gcm4q1cbVK3OuPOt DRqA== X-Gm-Message-State: APt69E1f3P5fr5BhxS8K7ugZlAYWCoovpqPZSGo9LDbUZMZPN3i7qetG W7lHGw0YODnPO6KRHps+RgsETQ== X-Received: by 2002:adf:9a0b:: with SMTP id z11-v6mr8244468wrb.47.1530909925701; Fri, 06 Jul 2018 13:45:25 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id t1-v6sm12242660wmt.40.2018.07.06.13.45.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jul 2018 13:45:25 -0700 (PDT) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 (v4.18 regression fix)] vfs: don't evict uninitialized inode Date: Fri, 6 Jul 2018 22:45:21 +0200 Message-Id: <20180706204521.29654-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()") --- fs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 04dd7e0d5142..e7de38c1d9d8 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1050,6 +1050,7 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval, { 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 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval, 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,12 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, struct inode *inode = ilookup5(sb, hashval, test, data); if (!inode) { - struct inode *new = new_inode(sb); + struct inode *new = alloc_inode(sb); if (new) { inode = inode_insert5(new, hashval, test, set, data); if (unlikely(inode != new)) - iput(new); + destroy_inode(new); } } return inode; -- 2.14.3