From patchwork Fri Jul 6 15:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10511969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 55FFF600CA for ; Fri, 6 Jul 2018 15:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469E328672 for ; Fri, 6 Jul 2018 15:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39C9F286BD; Fri, 6 Jul 2018 15:36:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFEFF28672 for ; Fri, 6 Jul 2018 15:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754039AbeGFPf4 (ORCPT ); Fri, 6 Jul 2018 11:35:56 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43838 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754001AbeGFPfz (ORCPT ); Fri, 6 Jul 2018 11:35:55 -0400 Received: by mail-wr1-f68.google.com with SMTP id b15-v6so4599925wrv.10 for ; Fri, 06 Jul 2018 08:35:55 -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=JLffXw2ge01HDBy9zI+ZF9fw489JARQSa16hJXlbYv4=; b=aPk48aZeOTKj8WkS2Nx0AygryjMygf9XvdBJBZQHQAV1C2cYr3VPQ0sN8WoIiYZARJ MLPnvhzMbSMC79jeLjyPT6QQVeSSM/5FqJItvRiRK8gjgjcyiKsrMmEDEuH06sTFTEU1 cXfrFZirtY+aG+j8l1KOf01rCGqDS68EzxsQrb/vDk07OVtxoAOWDo58qKYylJbNfZq/ VLe9Obd77U29CzCcclCGgClRbm8xINsvp4mooGiI3XQLiHI7GCY0EH2HAk4K7wELZ/Kn +Gqh+7s9hH6ha1JGBvlp/rcssht2LJlBZEF7XcHxyn6G/vpxE3Pb925Gy/CS1AgvmSkI 1STQ== X-Gm-Message-State: AOUpUlEV3mmQym9X4HD3ncGvE80vEejh72RTHHaSiboTA3H0iWKS96jL xK/c0hPopazLY4tic+eJseHrlQ== X-Google-Smtp-Source: AAOMgpfhssxFVPE0fJr00slbvKZGoNncJ422WH9HSdjvlU/ug25ZovjrKb/28AudCcik7KYQgJZPZQ== X-Received: by 2002:a5d:494c:: with SMTP id r12-v6mr313779wrs.66.1530891354485; Fri, 06 Jul 2018 08:35:54 -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 189-v6sm11700012wmd.17.2018.07.06.08.35.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jul 2018 08:35:53 -0700 (PDT) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH (v4.18 regression fix)] vfs: don't evict uninitialized inode Date: Fri, 6 Jul 2018 17:35:48 +0200 Message-Id: <20180706153548.23287-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 after the inode has been inserted into the hash. The exact point at which the inode is added onto the sb list shouldn't matter as long as it is done while the inode is in the I_NEW state. Reported-by: Al Viro Signed-off-by: Miklos Szeredi Fixes: 80ea09a002bf ("vfs: factor out inode_insert5()") --- fs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 2c300e981796..2f6b411b904f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1094,12 +1094,14 @@ 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 = new_inode_pseudo(sb); if (new) { inode = inode_insert5(new, hashval, test, set, data); if (unlikely(inode != new)) - iput(new); + destroy_inode(new); + else + inode_sb_list_add(inode); } } return inode;