[PATCH] Backport /proc/pid inode security labels

From: James Carter (jwcart2@private)
Date: Fri Sep 26 2003 - 11:17:29 PDT

  • Next message: Chris Wright: "Re: [RFC][PATCH] Pass nameidata to security_inode_permission hook"

    This patch against lsm-2.4 is a backport of the changes accepted into
    the 2.5/6 kernel.  It adds a security_task_to_inode hook to
    proc_pid_make_inode to allow security modules to set the security
    attributes on /proc/pid inodes based on the security attributes of the
    associated task.
    
    The new 2.4-based SELinux (a backport of the 2.6-based SELinux) depends
    on these, so we'd like to get them into the lsm-2.4 tree so that we can
    also merge the new 2.4-based SELinux into it.
    
    For reference see Steve's email to the LSM list on 13 May 2003.
    http://mail.wirex.com/pipermail/linux-security-module/2003-May/4380.html
    
    If there are no objections, I will ask Steve to merge it.
    
     fs/proc/base.c           |    1 +
     include/linux/security.h |   14 ++++++++++++++
     security/dummy.c         |    4 ++++
     3 files changed, 19 insertions(+)
    
    diff -Nru a/fs/proc/base.c b/fs/proc/base.c
    --- a/fs/proc/base.c	Thu Sep 25 15:23:47 2003
    +++ b/fs/proc/base.c	Thu Sep 25 15:23:47 2003
    @@ -791,6 +791,7 @@
     		inode->i_uid = task->euid;
     		inode->i_gid = task->egid;
     	}
    +	security_task_to_inode(task, inode);
     
     out:
     	return inode;
    diff -Nru a/include/linux/security.h b/include/linux/security.h
    --- a/include/linux/security.h	Thu Sep 25 15:23:47 2003
    +++ b/include/linux/security.h	Thu Sep 25 15:23:47 2003
    @@ -595,6 +595,11 @@
      * 	Set the security attributes in @p->security for a kernel thread that
      * 	is being reparented to the init task.
      *	@p contains the task_struct for the kernel thread.
    + * @task_to_inode:
    + * 	Set the security attributes for an inode based on an associated task's
    + * 	security attributes, e.g. for /proc/pid inodes.
    + *	@p contains the task_struct for the task.
    + *	@inode contains the inode structure for the inode.
      *
      * Security hooks for socket operations.
      *
    @@ -1361,6 +1366,7 @@
     			   unsigned long arg5);
     	void (*task_kmod_set_label) (void);
     	void (*task_reparent_to_init) (struct task_struct * p);
    +	void (*task_to_inode)(struct task_struct *p, struct inode *inode);
     
     	int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
     
    @@ -2056,6 +2062,11 @@
     	security_ops->task_reparent_to_init (p);
     }
     
    +static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
    +{
    +	security_ops->task_to_inode(p, inode);
    +}
    +
     static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
     					   short flag)
     {
    @@ -2749,6 +2760,9 @@
     {
     	cap_task_reparent_to_init (p);
     }
    +
    +static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
    +{ }
     
     static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
     					   short flag)
    diff -Nru a/security/dummy.c b/security/dummy.c
    --- a/security/dummy.c	Thu Sep 25 15:23:47 2003
    +++ b/security/dummy.c	Thu Sep 25 15:23:47 2003
    @@ -611,6 +611,9 @@
     	return;
     }
     
    +static void dummy_task_to_inode(struct task_struct *p, struct inode *inode)
    +{ }
    +
     static int dummy_ipc_permission (struct kern_ipc_perm *ipcp, short flag)
     {
     	return 0;
    @@ -1053,6 +1056,7 @@
     	set_to_dummy_if_null(ops, task_prctl);
     	set_to_dummy_if_null(ops, task_kmod_set_label);
     	set_to_dummy_if_null(ops, task_reparent_to_init);
    +	set_to_dummy_if_null(ops, task_to_inode);
     	set_to_dummy_if_null(ops, ipc_permission);
     	set_to_dummy_if_null(ops, msg_msg_alloc_security);
     	set_to_dummy_if_null(ops, msg_msg_free_security);
    
    
    -- 
    James Carter <jwcart2@private>
    National Security Agency
    



    This archive was generated by hypermail 2b30 : Fri Sep 26 2003 - 11:43:36 PDT