Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp710268pxu; Thu, 3 Dec 2020 10:37:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+IvDsYw/lRhXxTs76NVn5Y811Bb+zkE8/+EC4vMhgAG06CzZZhv58+eJWY61uKYBkoU7M X-Received: by 2002:a17:906:e58:: with SMTP id q24mr1076771eji.438.1607020635017; Thu, 03 Dec 2020 10:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607020635; cv=none; d=google.com; s=arc-20160816; b=f146JJHDD3q7kuThB8aPSq/3rwPkMmH3Cp7yHr0yN1P7jtLyToxuj9tn4qGEwQJGDu jC+Ii/FQQA5VEJ7J5gCDOw5FHEPJpWlFLCk8NbHKqAsPA9GpuE7UsroZHhzDZPR5TqV5 G8qbai0UmZ9JatX9cxbu8VKgxXUFL1eDIE+Rld3j90sM+Yf5u1hMQqzD3SkXpdwEsNKN I/zMnoKUqhPYmfFTljwU0UcOs23u4Yn69zrykAteng1B5z2TBIgiFIZhWy9HU1JOMkFn t7WRonWcQE57+/VXPHsNkeK9otPie9jotI9Y7e4UsnNZrCaLmbIV0StlFcKXdrHNVjQe w1Aw== 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=R1ftv6+y16M2JvLuCgZVSBDrmDmcKPLcCfZkzOiNeTUsS6/W3307dWBrG+Ys6W2H9l 4mSeoTY8VOOFcLLopWkvP7eQcSiwL6mzi+9+ecU7i3OOkt6jk0Epb3T/CSVkQGlK3wx8 FY5Ua91zqC2Gyua/rumOOntYOWQmXFBjrvCJ1gBqV1m0Oe/Ep4aoGD+3uICpCUU5SkX0 SxIuglHoRL6bNB1UNHQmtrdr32vqCULWz405STpXSZNucLfeJ/lmZPdqhupCfWzsM6fu ao+o8AGQevMrqaA0WiBOWZS3wK+7WFng0IvvwI/Z6FcdxbCQmWEpIsscQQFUZ98fwSbJ eEEQ== 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 y12si1553327ejm.210.2020.12.03.10.36.52; Thu, 03 Dec 2020 10:37:15 -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 S1731742AbgLCSeZ (ORCPT + 99 others); Thu, 3 Dec 2020 13:34:25 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:42296 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729250AbgLCSeZ (ORCPT ); Thu, 3 Dec 2020 13:34:25 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R931e4;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_---0UHRBP2t_1607020413; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0UHRBP2t_1607020413) by smtp.aliyun-inc.com(127.0.0.1); Fri, 04 Dec 2020 02:33:42 +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 08/10] proc: Clear the pieces of proc_inode that proc_evict_inode cares about Date: Fri, 4 Dec 2020 02:32:02 +0800 Message-Id: <20201203183204.63759-9-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201203183204.63759-1-wenyang@linux.alibaba.com> References: <20201203183204.63759-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