From mboxrd@z Thu Jan 1 00:00:00 1970 From: Djalal Harouni Subject: [PATCH 2/9] proc: add proc_file_private struct to store private information Date: Sun, 11 Mar 2012 00:25:12 +0100 Message-ID: <1331421919-15499-3-git-send-email-tixxdz@opendz.org> References: <1331421919-15499-1-git-send-email-tixxdz@opendz.org> Cc: Alan Cox , Greg KH , Ingo Molnar , Stephen Wilson , "Jason A. Donenfeld" , Djalal Harouni , Vasiliy Kulikov , Solar Designer To: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Andrew Morton , Linus Torvalds , Al Viro , Alexey Dobriyan , "Eric W. Biederman" , Vasiliy Kulikov , Kees Cook , Solar Designer , WANG Cong , James Morris , Oleg Nesterov , linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org Return-path: In-Reply-To: <1331421919-15499-1-git-send-email-tixxdz@opendz.org> Sender: linux-security-module-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org In order to store and to track the private information specific to each procfs opened file we convert the 'proc_maps_private' struct which is used by the /proc/$pid/{maps,smaps,numa_maps} files to 'proc_file_private' which can now be used by all the /proc//* and even other /proc/* files to store private information that must be kept across syscalls. The proc_file_private struct includes an exec_id member which can be used to track and to protect special and sensitive procfs files. In general it will be set at open time to the task's exec_id to bind the file to this task. The proc_file_private struct offers the way to make the checks and to bind special procfs files to the appropriate task in a consistent and unified way. Cc: Vasiliy Kulikov Cc: Solar Designer Signed-off-by: Djalal Harouni --- fs/proc/internal.h | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 2925775..a8968f6 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -61,10 +61,19 @@ extern const struct file_operations proc_pagemap_operations; extern const struct file_operations proc_net_operations; extern const struct inode_operations proc_net_inode_operations; -struct proc_maps_private { +/* + * Internal proc_file_private is used to track procfs files being + * processed especially the ones that varies during runtime. + */ +struct proc_file_private { + /* The Execve ID of the task, use this to protect special procfs + * files. Must be set at open time. */ + u64 exec_id; struct pid *pid; + struct inode *inode; struct task_struct *task; #ifdef CONFIG_MMU + /* For /proc/pid/{maps,smaps...} */ struct vm_area_struct *tail_vma; #endif }; -- 1.7.1