Received: by 10.192.165.148 with SMTP id m20csp4105527imm; Mon, 23 Apr 2018 19:23:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4++tEPSJIBtOxJgD2PFtXE/wZ6RsQsi9z56xIU6ntyISPC5WuPybnDP8cdBT0TkkW4Thz9p X-Received: by 10.98.66.143 with SMTP id h15mr10547089pfd.156.1524536599416; Mon, 23 Apr 2018 19:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524536599; cv=none; d=google.com; s=arc-20160816; b=wF02XqPVUSHT32A58ROwLCsxngrB9mlL1kk8WAKHx53DyCAk/oLsuRk1Llj2KtERgI ++jVOSc4aqcBhJmh/VG+IXW3One2TyzQwuNGZuDcjs7najoZLhDfFwWQDpHegyAJjCHi g8Xcb73E5az2Rhl78x5GGWPkxM538smn3CkmUxsABdBrxcQsLjHd9ichJ8sVhTfQRViW OtN/Pd+UBJMjQxNmkBfkC6rXy12HJcgN2NNiWXc8XCFUfQN6/WQI2yuxS28CHKmN2r3t sruEAPGYY2fduZsDvO7s+y1szeLk68yguGtWpZdEs4SVL2RcxC0T2ktllKdutqy29xc9 nEFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ovPhmYwv6A53FyRfu3NZT+14UuDXC50KPiME6OrK+P4=; b=Rf+E5vfDDI+rTtZKa2g8QAe/UQ/soGM0B2dELKtEqK757+qmPFYtASE0+SoTvIi8q2 O51S3dj5KSgtSGQ8ZwOgzUt6yNcpjKzFIpKMiWrK6HPiJQ6ATrG4zUI5+p/yeJz/nLnT yqwSSda1Ffc8I4/i/Th1IeYM4hCA163ObSh80GrZjA5/+Cf70Xetn0T4jWbNF5grzEY2 +vda5hHQTEqIWXllvLlEt0Cpfge7FxVI4bGe9colth+AOE5mpGWtZ6zE8IauPT8nKsQg OfZ2NhUpbGFoRuYeLBM0N6TNoKBcCjkgqFEIm4kUbUukKksiskC3TmNOZDTtutZvHxSN LIGQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 132si10540714pgb.470.2018.04.23.19.23.05; Mon, 23 Apr 2018 19:23:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932756AbeDXCVR (ORCPT + 99 others); Mon, 23 Apr 2018 22:21:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:36644 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932670AbeDXCVO (ORCPT ); Mon, 23 Apr 2018 22:21:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 64EBAADF5; Tue, 24 Apr 2018 02:21:12 +0000 (UTC) Received: from starscream.home.jeffm.io (starscream-1.home.jeffm.io [IPv6:2001:559:c0d4::1fe]) by mail.home.jeffm.io (Postfix) with ESMTPS id 2212581AD3E6; Mon, 23 Apr 2018 22:20:54 -0400 (EDT) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id D5258816A4; Mon, 23 Apr 2018 22:21:10 -0400 (EDT) From: jeffm@suse.com To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Al Viro , "Eric W . Biederman" , Alexey Dobriyan , Oleg Nesterov , Jeff Mahoney Subject: [PATCH 2/5] procfs: factor out inode revalidation work from pid_revalidation Date: Mon, 23 Apr 2018 22:21:03 -0400 Message-Id: <20180424022106.16952-3-jeffm@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180424022106.16952-1-jeffm@suse.com> References: <20180424022106.16952-1-jeffm@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Mahoney Subsequent patches will introduce their own d_revalidate callbacks and we won't want to get the task multiple times. Signed-off-by: Jeff Mahoney --- fs/proc/base.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index e9876a89a5ad..e7ca45504a5f 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1802,14 +1802,24 @@ int pid_getattr(const struct path *path, struct kstat *stat, /* dentry stuff */ + +/* + * Rewrite the inode's ownerships here because the owning task may have + * performed a setuid(), etc. + */ +static void pid_revalidate_inode(struct inode *inode, struct task_struct *task) +{ + task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid); + + inode->i_mode &= ~(S_ISUID | S_ISGID); + security_task_to_inode(task, inode); +} + /* * Exceptional case: normally we are not allowed to unhash a busy * directory. In this case, however, we can do it - no aliasing problems * due to the way we treat inodes. * - * Rewrite the inode's ownerships here because the owning task may have - * performed a setuid(), etc. - * */ int pid_revalidate(struct dentry *dentry, unsigned int flags) { @@ -1823,10 +1833,7 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags) task = get_proc_task(inode); if (task) { - task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid); - - inode->i_mode &= ~(S_ISUID | S_ISGID); - security_task_to_inode(task, inode); + pid_revalidate_inode(inode, task); put_task_struct(task); return 1; } -- 2.12.3