Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp126418pxu; Wed, 6 Jan 2021 23:56:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzq6yMy+NmcrAwz7we0YQaOMuByTFapMn7mGZFkl4Ijhrx39Ww6zvjLUM1h6rD4pCCK24jW X-Received: by 2002:a17:906:9613:: with SMTP id s19mr5493115ejx.351.1610006198048; Wed, 06 Jan 2021 23:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610006198; cv=none; d=google.com; s=arc-20160816; b=rI5/zhGeHDkaK/O3MlH5spH2Peeqy3vFpkQHLBPsEYxC4v81MF12rMPnwV9Vh/Opli kFZUjWbVKlp3vmOWSGMZlv6c70qZwGjy0CACJx3OcQA6EQmza46aEz1tIM7YvUDU7Fm4 4EDHXL4U2enPF8RsOQpUbgH3FpjKOivl/MZBXY1eUBLTQUMEVj4XwKDjIZHLclbtvNzm v5qBZNJnyuXEPN1/KIky+LiCdM5eCktoBxC7TWzfY6FeJz/WjoQvxLcNekmS+3vkTgu5 wdoXk6HSheY9gyYYUfJzIV97RnqAzqKqJG2t/GST6taLQNa20GJVycIxo3aPSXBp99bk WM2g== 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=MgqC3HtZK+Yu1oUutgXDDVNwdoi6itF5C5Hl4Ysy4iE=; b=fusszhE91UeqLkK8mVILBfc0JLUuNkbrfIOEGh/G6G/V+MnwZTQSST14olVvRkIRO3 GJS5+kmL4EADWSI+TWfiNNwePK93L9XG5VkdSzrEYFK+HSLo2CoXU8Eha2tZIgXMOwBS phONSHsiT4SWE1pw7wYUmFCd4uiek/iKgc+pSDLRZDU8+ackaxPWqBr6QMZVOwU/KlXz OhXyUiEIoHwLEevlukIpEZ/i3c+sA1ZDZkKhlMMKtpfakz05BN7VGYdXdbXvYMMO8viL DQ+Ryi7lQwLmPovLxjT9S8oECbxEak2Mb08SHmmt325sCguXafgnSPIYdsuBCUXrL/++ SNiQ== 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 hj13si1853787ejb.475.2021.01.06.23.56.14; Wed, 06 Jan 2021 23:56:38 -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 S1727218AbhAGHxZ (ORCPT + 99 others); Thu, 7 Jan 2021 02:53:25 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:60190 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbhAGHxX (ORCPT ); Thu, 7 Jan 2021 02:53:23 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0UKyrqo6_1610005959; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0UKyrqo6_1610005959) by smtp.aliyun-inc.com(127.0.0.1); Thu, 07 Jan 2021 15:52:39 +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 v2 4.9 08/10] proc: Clear the pieces of proc_inode that proc_evict_inode cares about Date: Thu, 7 Jan 2021 15:52:20 +0800 Message-Id: <20210107075222.62623-9-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210107075222.62623-1-wenyang@linux.alibaba.com> References: <20210107075222.62623-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.9.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 920c761..739fb9c 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -32,21 +32,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