Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753049Ab3JAUcE (ORCPT ); Tue, 1 Oct 2013 16:32:04 -0400 Received: from numidia.opendz.org ([98.142.220.152]:52660 "EHLO numidia.opendz.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617Ab3JAUcA (ORCPT ); Tue, 1 Oct 2013 16:32:00 -0400 From: Djalal Harouni To: "Eric W. Biederman" , Kees Cook , Al Viro , Andrew Morton , Linus Torvalds , Ingo Molnar , "Serge E. Hallyn" , Cyrill Gorcunov , David Rientjes , LKML , linux-fsdevel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: tixxdz@gmail.com, Djalal Harouni Subject: [PATCH v2 5/9] procfs: make /proc entries that use seq files able to access file->f_cred Date: Tue, 1 Oct 2013 21:26:14 +0100 Message-Id: <1380659178-28605-6-git-send-email-tixxdz@opendz.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1380659178-28605-1-git-send-email-tixxdz@opendz.org> References: <1380659178-28605-1-git-send-email-tixxdz@opendz.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1835 Lines: 50 In order to check if the cred of current have changed between ->open() and ->read(), we must able to access the file's opener cred 'file->f_cred' at any point. To make this possible for /proc/*/{stack,personality,stat} pass the 'file struct' as a 3rd argument to single_open() so it will be stored in seq_file->private in seq_open(). This way these entries are able to continue to use seq files, and access the file->f_cred easily. This is also a preparation for the following patches which will check the corresponding file->f_cred. Signed-off-by: Djalal Harouni --- fs/proc/base.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 54e926a..d4b604d 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -765,7 +765,8 @@ static const struct file_operations proc_info_file_operations = { static int proc_single_show(struct seq_file *m, void *v) { - struct inode *inode = m->private; + struct file *filp = m->private; + struct inode *inode = file_inode(filp); struct pid_namespace *ns; struct pid *pid; struct task_struct *task; @@ -785,7 +786,9 @@ static int proc_single_show(struct seq_file *m, void *v) static int proc_single_open(struct inode *inode, struct file *filp) { - return single_open(filp, proc_single_show, inode); + /* Later we need inode and filp->f_cred, so pass filp as 3rd + * argument, it will be referenced by seq_file->private */ + return single_open(filp, proc_single_show, filp); } static const struct file_operations proc_single_file_operations = { -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/