Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp126644pxu; Wed, 6 Jan 2021 23:57:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEJts3aw4iaF6Afn7e6i9PqKOBVCyROqvYwIPC7bMNyDxtDE2qwczBU8NMv2GNxiYiXUmx X-Received: by 2002:a50:8004:: with SMTP id 4mr746034eda.329.1610006229036; Wed, 06 Jan 2021 23:57:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610006229; cv=none; d=google.com; s=arc-20160816; b=LzPMSFzwE6ksIh4jQiPNw6a1ImVNICqX7nj21lLqmVPVc3vak6YKxUnT3wfAvWyR0D oU88tSqnh3w8H5hZ3uHxOdoukZ93fyTYQZ4OvsVIFd/lsv9jEb8mgm/jKw+us85aT6rR LJzQYbgWM1LpjDzn4ySA07WURe46Xbuy7vs0R5/AuzL0lg2Eef+r5wrSOZb6tPuEXJh6 W0yhzXintGCQ46OQ3BeCSe2koghQe2UOgk6lVx+igxiVUqgcZ+2klghye2bUp7x+MrEO P/5IV3FH5h6s870q08JZZCG0YxtK667zIQfXHtSgCO9qd8GvyH05Ydjqtet+M30kyD4j xmRg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fkB2atBbdMSXVeRG6Es90GqjU39nJu1ePZyrVLk1Muo=; b=UVv/RTdWY/Px/ZQCWVaoNW+IExRlOfT0HgQb6/5c1na5MIjDXyr/Vmjv6JbrwrZYAB A2NFGB4QC3/bi6ItxL44w6xegSyPDXmRbUNnG5SgFyg3MN/x501HTo6KRjFKiyQBTNLv I+YaNNWqIK8JfJoZKqIK2l+icgM2v3y0N4CfvwFfgx+aQMvAaYck3hhHvRqLlvkNLB/f XJlW8BYyiLO/yNT1ZRURyjZWxZSnXRPyvHXGliBJaS5Cf4GtCnxkSp31lrplnfGDp/rc XdFvZlxenOhrEYSZ2rxOnTYajn6m35moewnN1z1TuQ/hh2BJrNtv1lHAbwxipHxEmAGE eZLg== ARC-Authentication-Results: i=1; mx.google.com; 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si1976032edq.97.2021.01.06.23.56.46; Wed, 06 Jan 2021 23:57:09 -0800 (PST) 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; 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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbhAGHye (ORCPT + 99 others); Thu, 7 Jan 2021 02:54:34 -0500 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:48027 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727396AbhAGHyE (ORCPT ); Thu, 7 Jan 2021 02:54:04 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UKzNwIV_1610006000; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0UKzNwIV_1610006000) by smtp.aliyun-inc.com(127.0.0.1); Thu, 07 Jan 2021 15:53:20 +0800 From: Wen Yang To: Greg Kroah-Hartman , Sasha Levin Cc: Xunlei Pang , linux-kernel@vger.kernel.org, "Eric W. Biederman" , stable@vger.kernel.org, Wen Yang Subject: [PATCH 4.19 5/7] proc: Clear the pieces of proc_inode that proc_evict_inode cares about Date: Thu, 7 Jan 2021 15:53:12 +0800 Message-Id: <20210107075314.62683-6-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210107075314.62683-1-wenyang@linux.alibaba.com> References: <20210107075314.62683-1-wenyang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Eric W. Biederman" [ Upstream commit 71448011ea2a1cd36d8f5cbdab0ed716c454d565 ] This just keeps everything tidier, and allows for using flags like SLAB_TYPESAFE_BY_RCU where slabs are not always cleared before reuse. I don't see reuse without reinitializing happening with the proc_inode but I had a false alarm while reworking flushing of proc dentries and indoes when a process dies that caused me to tidy this up. The code is a little easier to follow and reason about this way so I figured the changes might as well be kept. Signed-off-by: "Eric W. Biederman" Cc: # 4.19.x Signed-off-by: Wen Yang --- fs/proc/inode.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index fffc7e4..45b4344 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -34,21 +34,27 @@ static void proc_evict_inode(struct inode *inode) { struct proc_dir_entry *de; struct ctl_table_header *head; + struct proc_inode *ei = PROC_I(inode); truncate_inode_pages_final(&inode->i_data); clear_inode(inode); /* Stop tracking associated processes */ - put_pid(PROC_I(inode)->pid); + if (ei->pid) { + put_pid(ei->pid); + ei->pid = NULL; + } /* Let go of any associated proc directory entry */ - de = PDE(inode); - if (de) + de = ei->pde; + if (de) { pde_put(de); + ei->pde = NULL; + } - head = PROC_I(inode)->sysctl; + head = ei->sysctl; if (head) { - RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL); + RCU_INIT_POINTER(ei->sysctl, NULL); proc_sys_evict_inode(inode, head); } } -- 1.8.3.1