Skip to contentSkip to conversation

Synchronize lsm-2.5 with lsm-2.5-bk

PATCH New Stephen D. Smalley 1 participant 1 message Dec 16, 2002

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Synchronize lsm-2.5 with lsm-2.5-bk

The first attached patch, also committed to the sourceforge CVS tree, synchronizes our lsm-2.5 tree with the head of the lsm-2.5 BitKeeper tree. Note that one of these changes conflicts with the selinux-2.5.patch, so revert that patch prior to applying. An updated selinux-2.5.patch is attached, and has been committed to the sourceforge CVS tree as well.

--
Stephen Smalley, NSA
[email protected]

Index: lsm-2.5/security/Kconfig
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/Kconfig,v retrieving revision 1.1.1.1

security/Kconfig +2 -2
diff -u -r1.1.1.1 Kconfig
@@ -36,7 +36,7 @@
 
 config SECURITY_OWLSM
 	tristate "LSM port of Openwall (EXPERIMENTAL)"
-	depends EXPERIMENTAL
+	depends SECURITY && EXPERIMENTAL
 	help
 	  This enables the LSM port of the Openwall kernel patch.
 	  This is NOT official Openwall.  For more information on the
@@ -145,7 +145,7 @@
 
 config SECURITY_DTE
 	tristate "Domain and Type Enforcement (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	depends SECURITY && EXPERIMENTAL
 	help
 	  This enables Domain and Type Enforcement.  It assigns labels to
 	  files and processes.  File labels are called types, and process

Index: lsm-2.5/security/dummy.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/dummy.c,v retrieving revision 1.1.1.7

security/dummy.c +66 -177

264 lines not on this page · raw message

Index: lsm-2.5/security/owlsm.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/owlsm.c,v retrieving revision 1.1.1.7

security/owlsm.c +24 -947

1,013 lines not on this page · raw message

Index: lsm-2.5/security/security.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/security.c,v retrieving revision 1.1.1.5

security/security.c +6 -0
diff -u -r1.1.1.5 security.c
@@ -48,6 +48,12 @@
 	printk (KERN_INFO "Security Scaffold v" SECURITY_SCAFFOLD_VERSION
 		" initialized\n");
 
+	if (verify (&dummy_security_ops)) {
+		printk (KERN_ERR "%s could not verify "
+			"dummy_security_ops structure.\n", __FUNCTION__);
+		return -EIO;
+	}
+
 	security_ops = &dummy_security_ops;
 
 	return 0;

Index: lsm-2.5/security/lids/Kconfig
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/Kconfig,v retrieving revision 1.1.1.1

security/lids/Kconfig +15 -23
diff -u -r1.1.1.1 Kconfig
@@ -2,12 +2,11 @@
 #	Kconfig for LIDS
 #
 
-menu "Linux Intrusion Detection System"
-
-if EXPERIMENTAL && SYSCTL
+if EXPERIMENTAL && SYSCTL && SECURITY
 
 config LIDS
 	tristate "Linux Intrusion Detection System support (EXPERIMENTAL)"
+	depends SECURITY && EXPERIMENTAL
 	help
 	  LIDS - Linux Intrusion Detection System can let you protect
 	  your linux kernel.
@@ -39,26 +38,25 @@
 
 if LIDS
 
-comment "Lids features"
-
 config LIDS_MAX_INODE 
 	int "Maximum protected objects to manage"
-	default 256
+	default 1024 
 
 config LIDS_MAX_SACL
 	int "Maximum ACL subjects to manage"
-	default 256
+	default 1024 
 
 config LIDS_MAX_OACL
 	int "Maximum ACL objects to manage"
-	default 256
+	default 1024 
 
 config LIDS_MAX_PROTECTED_PID
 	int "Maximum protected proceeds"
-	default 256
+	default 1024
 
 config LIDS_SA_EXEC_UP
 	bool "Security alert when execing unprotected programs before sealing LIDS"
+	default n
 	help
 	  Saying yes will generate a security alert for each unprotected
 	  program that is executed before LIDS is sealed (with lidsadm
@@ -71,6 +69,7 @@
 
 config LIDS_NO_EXEC_UP
 	bool "Do not execute unprotected programs before sealing LIDS"
+	default n
 	depends on LIDS_SA_EXEC_UP
 	help
 
@@ -87,6 +86,7 @@
 
 config LIDS_NO_FLOOD_LOG
 	bool "Attempt not to flood logs"
+	default y
 	help
 	  If you say Yes here, LIDS will try not to flood logs with the
 	  same message repeated a lot of times.
@@ -107,6 +107,7 @@
 
 config  LIDS_ALLOW_SWITCH
 	bool "Allow switching LIDS protections"
+	default y
 	help
 	  If you say Yes here, you will enable the possibility to switch
 	  LIDS on and off.
@@ -119,6 +120,7 @@
 
 config LIDS_RESTRICT_MODE_SWITCH
 	bool "Restrict mode switching to specified terminals" 
+	default n
 	help
 	  If you enable this option, mode switching will be only allowed
 	  from specified terminal types.
@@ -127,6 +129,7 @@
 
 config LIDS_MODE_SWITCH_CONSOLE
 	bool "Allow mode switching from a Linux Console"
+	default y
 	help
 	  Allow mode switching from a Linux Console.
 
@@ -161,20 +164,9 @@
 
 	  The higher it is, the more secure the system will be.
 
-config LIDS_ALLOW_ANY_PROG_SWITCH
-	bool "Allow any program to switch LIDS protections"
-	help
-	  If you say Yes here, you will allow programs others than
-	  /sbin/lidsadm to feed /proc/sys/lids/locks.
-  
-	  Notes : * It is strongly recommended to leave this option
-	            unmarked ! Don't say yes !
-	          * I don't know what it could be useful for :)
-
-	  Say no.
-
 config LIDS_RELOAD_CONF
 	bool "Allow reloading config. file"
+	default y 
 	help
 	  Saying Yes here will compile the necessary code to reload
 	  the config file. Each time you pass +RELOAD_CONF argument to
@@ -194,6 +186,7 @@
 
 config LIDS_SA_THROUGH_NET
 	bool "Send security alerts through network"
+	default n
 	help
 	  Say yes here if you want to send LIDS security alerts to a
 	  remote machine through the network, directly from the kernel,
@@ -261,11 +254,10 @@
 
 config LIDS_DEBUG
   bool "LIDS Debug"
+  default n
 
 # endif LIDS
 endif
 
 # endif EXPERIMENTAL && SYSCTL
 endif
-
-endmenu

Index: lsm-2.5/security/lids/lids_acl.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_acl.c,v retrieving revision 1.1.1.6

security/lids/lids_acl.c +4 -8
diff -u -r1.1.1.6 lids_acl.c
@@ -40,7 +40,7 @@
 
 #include <asm/namei.h>
 
-#include <linux/utime.h>
+#include <linux/time.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 
@@ -119,11 +119,7 @@
 			read_unlock(&tasklist_lock);
 			return 1;
 		}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
 		t=t->parent;
-#else
-		t=t->p_pptr;
-#endif
 	}
 	read_unlock(&tasklist_lock);
 	return 0;
@@ -200,7 +196,7 @@
 	struct lids_sys_acl *current_sys_acl = current->security;
 
 	if (!current_sys_acl) return -1;
-	return lids_time_checker(get_seconds()%(60*60*24), current_sys_acl->cap[cap].time);	
+	return lids_time_checker(get_seconds()%(60*60*24), current_sys_acl->cap[cap].time);
 	
 }
 /*
@@ -293,7 +289,7 @@
 		return -EPERM; 
 
 	ino = inode->i_ino;
-	dev = to_kdev_t(inode->i_dev);
+	dev = to_kdev_t(inode->i_sb->s_dev);
 
 	if (check_domain)
 		acl = current_sys_acl->lids_domain;
@@ -713,7 +709,7 @@
 	
 	while (dentry) {
 		if ((ino=dentry->d_inode)!=NULL)
-		    if ((retval=lids_search_inode(ino->i_ino,to_kdev_t(ino->i_dev),
+		    if ((retval=lids_search_inode(ino->i_ino,to_kdev_t(ino->i_sb->s_dev),
 			&lids_data[lids_curr&1])) >= 0) {
 			return (retval & flag) ? 0:
 				lids_check_acl(base,flag,lids_curr,0);

Index: lsm-2.5/security/lids/lids_exec.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_exec.c,v retrieving revision 1.1.1.6

security/lids/lids_exec.c +12 -23
diff -u -r1.1.1.6 lids_exec.c
@@ -128,8 +128,8 @@
 		dentry = bprm->file->f_dentry;
 		lids_security_alert("Attempt to give [%.128s] to privilegied program %.128s (dev %d:%d inode %ld)", 					
 			kaddr, bprm->filename,
-			MAJOR(dentry->d_inode->i_dev),
-			MINOR(dentry->d_inode->i_dev),
+			MAJOR(dentry->d_inode->i_sb->s_dev),
+			MINOR(dentry->d_inode->i_sb->s_dev),
 			dentry->d_inode->i_ino);
 	}
 	kfree(p);
@@ -158,15 +158,11 @@
 	struct lids_sys_acl *current_sys_acl = current->security;
 	struct dentry *dentry;
 	
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
 	if(current->parent->pid == 0) return 0;
-#else
-	if(current->p_pptr->pid == 0) return 0;
-#endif
 
 	if(!bprm || !bprm->file) { printk("%s:BUG!\n",__FUNCTION__); return 0; }
 
-	LIDS_DBG("%s:##### pid %i exec [%s]\n",__FUNCTION__ ,current->pid,bprm->filename);
+	LIDS_DBG("%s:##### pid %i exec [%s]\n",__FUNCTION__,current->pid,bprm->filename);
 	dentry = bprm->file->f_dentry;
 	/* check if this program is protected or not */
 	if (lids_check_base(dentry,LIDS_APPEND)) {
@@ -180,7 +176,7 @@
 		
 		/* if it is protected, set the ACLs */
 		lids_get_task_acl(&current_acl, current);
-		new_sys_acl = lids_search_acl(dentry->d_inode->i_ino,to_kdev_t(dentry->d_inode->i_dev),lids_current);
+		new_sys_acl = lids_search_acl(dentry->d_inode->i_ino,to_kdev_t(dentry->d_inode->i_sb->s_dev),lids_current);
 
 		if (lids_compute_acls(&current_acl,new_sys_acl,&computed_acl) < 0) {
 			dput(dentry);
@@ -203,8 +199,8 @@
 #ifdef CONFIG_LIDS_NO_EXEC_UP
 			lids_security_alert("Attempt to exec unprotected program %s (dev %d:%d inode %ld) before sealing LIDS",
 					    bprm->filename,
-					    MAJOR(dentry->d_inode->i_dev),
-					    MINOR(dentry->d_inode->i_dev),
+					    MAJOR(dentry->d_inode->i_sb->s_dev),
+					    MINOR(dentry->d_inode->i_sb->s_dev),
 					    dentry->d_inode->i_ino);
 			if (dentry)
 				dput(dentry);
@@ -212,8 +208,8 @@
 #else
 			lids_security_alert("Exec'ed unprotected program %s (dev %d:%d inode %ld) before sealing LIDS",
 					    bprm->filename,
-					    MAJOR(dentry->d_inode->i_dev),
-					    MINOR(dentry->d_inode->i_dev),
+					    MAJOR(dentry->d_inode->i_sb->s_dev),
+					    MINOR(dentry->d_inode->i_sb->s_dev),
 					    dentry->d_inode->i_ino);
 #endif
 		}
@@ -222,7 +218,7 @@
 		/* maybe we need some locks here */
 		if (current_sys_acl) {
 			lids_get_task_acl(&current_acl, current);
-			new_sys_acl = lids_search_acl(dentry->d_inode->i_ino,to_kdev_t(dentry->d_inode->i_dev),lids_current);
+			new_sys_acl = lids_search_acl(dentry->d_inode->i_ino,to_kdev_t(dentry->d_inode->i_sb->s_dev),lids_current);
 			if (lids_compute_acls(&current_acl,new_sys_acl,&computed_acl) < 0) {
 				dput(dentry);
 				return -EPERM;
@@ -232,8 +228,8 @@
 			    || computed_acl.lids_sys_acl->flags ) {
 				lids_security_alert("Attempt to transmit privileges to an unprotected program (%s dev %d:%d inode %ld)",
 					bprm->filename,
-					MAJOR(dentry->d_inode->i_dev),
-					MINOR(dentry->d_inode->i_dev),
+					MAJOR(dentry->d_inode->i_sb->s_dev),
+					MINOR(dentry->d_inode->i_sb->s_dev),
 					dentry->d_inode->i_ino);
 			}
 			current_sys_acl->lids_cap=0;
@@ -254,11 +250,8 @@
 	struct lids_task_acl src,dst;
 
 	if(!tsk) {printk("%s: BUG\n", __FUNCTION__); return 0 ;}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
+
 	if(!tsk->parent->pid) return 0;
-#else
-	if(!tsk->p_pptr->pid) return 0;
-#endif
 	
 	lids_get_task_acl(&src, current);
 	if (lids_task_acl_deep_copy(&dst,&src) < 0) {
@@ -277,11 +270,7 @@
 	if(!task_sys_acl) return 0;
 	if ( cap_raised(task_sys_acl->lids_cap, CAP_PROTECTED) ) {
 		if (current->pid && (current->pid != p->pid) 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
 			&& ((sig != SIGCHLD) || (current->parent->pid != p->pid))) {
-#else
-			&& ((sig != SIGCHLD) || (current->p_pptr->pid != p->pid))) {
-#endif
 			if (!capable(CAP_KILL_PROTECTED)) {
 				lids_security_alert("Attempt to kill pid=%d with sig=%d",p->pid,sig);
 				return -1;

Index: lsm-2.5/security/lids/lids_init.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_init.c,v retrieving revision 1.1.1.4

security/lids/lids_init.c +5 -13
diff -u -r1.1.1.4 lids_init.c
@@ -224,7 +224,7 @@
 			*ino=simple_strtoul(ino_str,0,0);
 			*dev= (kdev_t){simple_strtoul(dev_str,0,0)};
 			if ((*ino != d_file->d_inode->i_ino) ||
-			    (!kdev_same(*dev, to_kdev_t(d_file->d_inode->i_dev)))) {
+			    (!kdev_same(*dev, to_kdev_t(d_file->d_inode->i_sb->s_dev)))) {
 				LIDS_DBG("now=%p\n",d_file);
 				printk("LIDS: [%s] dev/inode in lids.conf seems wrong\n",q);
 			}
@@ -643,10 +643,8 @@
 	int	finished=0;
 	int	error = 0;
 	_lids_data_t *data=&lids_data[(lids_current&1)^1];
-#ifndef CONFIG_LIDS_ALLOW_ANY_PROG_SWITCH
 	struct dentry *dentry;
 	struct nameidata nd;
-#endif
 
 
 	/* Get lidsadm dev/inode */
@@ -666,14 +664,8 @@
 
 	memset(data->fastguess,0,sizeof(data->fastguess));
 
-#ifndef CONFIG_LIDS_ALLOW_ANY_PROG_SWITCH
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,6)
 	error = path_lookup(LIDS_ADM_PATH, LOOKUP_FOLLOW,&nd);
-#else
-	if (path_init(LIDS_ADM_PATH, LOOKUP_FOLLOW|LOOKUP_POSITIVE,&nd))
-		error = path_walk(LIDS_ADM_PATH,&nd);
-#endif
+
 	if (error)
 		return -1;
 	/*
@@ -689,7 +681,7 @@
   	}
 	else {
 		if (!dentry->d_inode ||
-		   !dentry->d_inode->i_dev ||
+		   !dentry->d_inode->i_sb->s_dev ||
 		   !dentry->d_inode->i_ino) {
 			printk("LIDS: something wrong with " LIDS_ADM_PATH "\n");
 			lidsadm.ino = 0;
@@ -697,11 +689,11 @@
 		}
 		else {
 			lidsadm.ino = dentry->d_inode->i_ino;
-			lidsadm.dev = to_kdev_t(dentry->d_inode->i_dev);
+			lidsadm.dev = to_kdev_t(dentry->d_inode->i_sb->s_dev);
 		}
 	}
 	path_release(&nd);
-#endif
+
 	/* Now, try to read lids.conf */
 
 /*	if ( init_add_file(LIDS_CONF_DIR,data) < 0 ) {

Index: lsm-2.5/security/lids/lids_logs.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_logs.c,v retrieving revision 1.1.1.4

security/lids/lids_logs.c +2 -6
diff -u -r1.1.1.4 lids_logs.c
@@ -99,8 +99,8 @@
 		strncpy(progname,f_dentry->d_iname,63);
 		snprintf(proginfo,127,"%s (dev %d:%d inode %ld)",
 			 progname,
-			 MAJOR(f_dentry->d_inode->i_dev),
-			 MINOR(f_dentry->d_inode->i_dev),
+			 MAJOR(f_dentry->d_inode->i_sb->s_dev),
+			 MINOR(f_dentry->d_inode->i_sb->s_dev),
 			 f_dentry->d_inode->i_ino);
 	}
 	else {
@@ -110,11 +110,7 @@
 	/* Make the message string */
 	vsnprintf(msgstr,255,message,args);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
 	parent_pid = current->parent->pid;
-#else
-	parent_pid = current->p_pptr->pid,			
-#endif
 
 	/* Make the log string */
 	lids_print("LIDS: %s pid %d ppid %d uid/gid (%d/%d) on (%s) : %s %s\n", 

Index: lsm-2.5/security/lids/lids_lsm.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_lsm.c,v retrieving revision 1.1.1.6

security/lids/lids_lsm.c +107 -521

741 lines not on this page · raw message

Index: lsm-2.5/security/lids/lids_sysctl.c
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/lids_sysctl.c,v retrieving revision 1.1.1.3

security/lids/lids_sysctl.c +12 -9
diff -u -r1.1.1.3 lids_sysctl.c
@@ -45,9 +45,7 @@
 
 
 
-#ifndef CONFIG_LIDS_ALLOW_ANY_PROG_SWITCH
 struct allowed_ino lidsadm;
-#endif
 
 
 /***********************************************************************
@@ -115,17 +113,23 @@
 			lids_flag_lower(lids_flags,LIDS_FLAGS_LIDS_ON);
 	}
 	if ( lids_local_on != (lids_flag_raised(flags,LIDS_FLAGS_LIDS_LOCAL_ON) != 0) ) {
+	#if 1
+		lids_load=(lids_flag_raised(flags,LIDS_FLAGS_LIDS_LOCAL_ON) != 0);
+		lids_security_alert("LIDS switched to %i",lids_load);
+		if (lids_load)
+			lids_flag_raise(lids_flags,LIDS_FLAGS_LIDS_LOCAL_ON);
+		else
+			lids_flag_lower(lids_flags,LIDS_FLAGS_LIDS_LOCAL_ON);
+	#endif
+	#if 0
 		lids_local_on=(lids_flag_raised(flags,LIDS_FLAGS_LIDS_LOCAL_ON) != 0);   /* XXX: Race condition here. We must first assign the PID */
 		lids_security_alert("LIDS locally switched to %i",lids_local_on);
 		if (lids_local_on) {
 			lids_flag_raise(lids_flags,LIDS_FLAGS_LIDS_LOCAL_ON);
 		}
 		else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,7)
 			lids_local_pid=current->parent->pid;
-#else
-			lids_local_pid=current->p_pptr->pid;
-#endif
+
 			if (lids_local_pid == 1) {  /* this doesn't apply to init */
 				printk("Can't give local lids deactivation to init!!\n");
 				lids_flag_raise(lids_flags,LIDS_FLAGS_LIDS_LOCAL_ON);
@@ -134,6 +138,7 @@
 			else
 				lids_flag_lower(lids_flags,LIDS_FLAGS_LIDS_LOCAL_ON); /* should not be necessary */			
 		}
+	#endif
 	}
 #else
 	if  (!lids_flag_raised(flags,LIDS_FLAGS_LIDS_ON)) {
@@ -226,7 +231,6 @@
 	}
 #endif /* CONFIG_LIDS_RESTRICT_MODE_SWITCH */
 
-#ifndef CONFIG_LIDS_ALLOW_ANY_PROG_SWITCH
 	{
 		struct vm_area_struct * vma;
 		unsigned long ino;
@@ -241,7 +245,7 @@
 				    vma->vm_file && vma->vm_file->f_dentry && 
 				    vma->vm_file->f_dentry->d_inode) {
 					ino=vma->vm_file->f_dentry->d_inode->i_ino;
-					dev=HASHDEV(to_kdev_t(vma->vm_file->f_dentry->d_inode->i_dev));
+					dev=HASHDEV(to_kdev_t(vma->vm_file->f_dentry->d_inode->i_sb->s_dev));
 					break;
 				}
 				vma = vma->vm_next;
@@ -253,7 +257,6 @@
 			return -EPERM;
 		}
 	}
-#endif
 	/* second: check wether it is not a timeout period after two many failed attempts */
 
 	if (wait_after_fail) {

Index: lsm-2.5/security/lids/include/linux/lids.h
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/include/linux/lids.h,v retrieving revision 1.1.1.3

security/lids/include/linux/lids.h +2 -1
diff -u -r1.1.1.3 lids.h
@@ -10,6 +10,7 @@
 #include <linux/sysctl.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
+#include <linux/binfmts.h>
 
 #include "lidsext.h"
 #include "lidsif.h"
@@ -18,7 +19,7 @@
 #define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
 #endif
 
-#define LIDS_VERSION	"2.0.1pre4"
+#define LIDS_VERSION	"2.0.2pre2"
 /* FIXME: some more externals in kernel/signal.c and kernel/sysctl.c */
 
 typedef struct

Index: lsm-2.5/security/lids/include/linux/lidsext.h
===================================================================
RCS file: /cvsroot/selinux/nsa/lsm-2.5/security/lids/include/linux/lidsext.h,v retrieving revision 1.1.1.2

security/lids/include/linux/lidsext.h +1 -1
diff -u -r1.1.1.2 lidsext.h
@@ -29,7 +29,7 @@
 #define LIDS_STR(X) LIDS_STR2(X)
 
 #ifdef LIDS_DEBUG
-#define LIDS_DBG(format, args...)  printk(KERN_DEBUG "LIDS.%s.l" LIDS_STR(__LINE__) ": " format, __FUNCTION__ ,  ##args)
+#define LIDS_DBG(msg...)  printk(KERN_DEBUG "LIDS." __FUNCTION__ ".l" LIDS_STR(__LINE__) ": " ##msg)
 #else
 #define LIDS_DBG(msg...)
 #endif

Index: lsm-2.5/Makefile
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/Makefile,v
retrieving revision 1.42

Makefile +1 -1
diff -u -r1.42 Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 51
-EXTRAVERSION = -lsm1
+EXTRAVERSION = -selinux
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"

Index: lsm-2.5/arch/i386/defconfig
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/arch/i386/defconfig,v retrieving revision 1.1.1.18

arch/i386/defconfig +11 -1
diff -u -r1.1.1.18 defconfig
@@ -401,7 +401,7 @@
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 # CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
+CONFIG_NETFILTER=y
 # CONFIG_FILTER is not set
 CONFIG_UNIX=y
 CONFIG_INET=y
@@ -1169,3 +1169,13 @@
 CONFIG_X86_SMP=y
 CONFIG_X86_HT=y
 CONFIG_X86_BIOS_REBOOT=y
+
+#
+# Security options
+#
+CONFIG_SECURITY=y
+CONFIG_SECURITY_CAPABILITIES=y
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_NSID=y
+CONFIG_SECURITY_SELINUX_SELOPT=y

Index: lsm-2.5/fs/dcache.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/fs/dcache.c,v
retrieving revision 1.1.1.18

fs/dcache.c +3 -0
diff -u -r1.1.1.18 dcache.c
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/mount.h>
 #include <asm/uaccess.h>
+#include <linux/security.h>
 
 #define DCACHE_PARANOIA 1
 /* #define DCACHE_DEBUG 1 */
@@ -699,6 +700,8 @@
 void d_instantiate(struct dentry *entry, struct inode * inode)
 {
 	if (!list_empty(&entry->d_alias)) BUG();
+	if (inode)
+		security_inode_init(inode);
 	spin_lock(&dcache_lock);
 	if (inode)
 		list_add(&entry->d_alias, &inode->i_dentry);

Index: lsm-2.5/fs/pipe.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/fs/pipe.c,v
retrieving revision 1.1.1.12

fs/pipe.c +2 -0
diff -u -r1.1.1.12 pipe.c
@@ -15,6 +15,7 @@
 #include <linux/pipe_fs_i.h>
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
+#include <linux/security.h>
 
 /*
  * We use a start+len construction, which provides full use of the 
@@ -529,6 +530,7 @@
 	inode->i_gid = current->fsgid;
 	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 	inode->i_blksize = PAGE_SIZE;
+	security_inode_init(inode);
 	return inode;
 
 fail_iput:

Index: lsm-2.5/fs/devpts/inode.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/fs/devpts/inode.c,v retrieving revision 1.1.1.9

fs/devpts/inode.c +2 -0
diff -u -r1.1.1.9 inode.c
@@ -16,6 +16,7 @@
 #include <linux/sched.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
+#include <linux/security.h>
 
 #define DEVPTS_SUPER_MAGIC 0x1cd1
 
@@ -142,6 +143,7 @@
 	inode->i_gid = config.setgid ? config.gid : current->fsgid;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 	init_special_inode(inode, S_IFCHR|config.mode, device);
+	security_inode_init(inode);
 
 	dentry = get_node(number);
 	if (!IS_ERR(dentry) && !dentry->d_inode)

Index: lsm-2.5/include/linux/security.h
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/include/linux/security.h,v retrieving revision 1.30

include/linux/security.h +9 -0
diff -u -r1.30 security.h
@@ -1205,6 +1205,7 @@
 
 	int (*inode_alloc_security) (struct inode *inode);	
 	void (*inode_free_security) (struct inode *inode);
+ 	void (*inode_init) (struct inode * inode);
 	int (*inode_create) (struct inode *dir,
 	                     struct dentry *dentry, int mode);
 	void (*inode_post_create) (struct inode *dir,
@@ -1613,6 +1614,11 @@
 {
 	security_ops->inode_free_security (inode);
 }
+
+static inline void security_inode_init (struct inode *inode)
+{
+	security_ops->inode_init (inode);
+}
 	
 static inline int security_inode_create (struct inode *dir,
 					 struct dentry *dentry,
@@ -2480,6 +2486,9 @@
 }
 
 static inline void security_inode_free (struct inode *inode)
+{ }
+
+static inline void security_inode_init (struct inode *inode)
 { }
 	
 static inline int security_inode_create (struct inode *dir,

Index: lsm-2.5/init/main.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/init/main.c,v
retrieving revision 1.23

init/main.c +7 -0
diff -u -r1.23 main.c
@@ -370,6 +370,10 @@
  	cpu_idle();
 } 
 
+#ifdef CONFIG_SECURITY_SELINUX 
+extern void selinux_init(void);
+#endif
+
 /*
  *	Activate the first processor.
  */
@@ -425,6 +429,9 @@
 	fork_init(num_physpages);
 	proc_caches_init();
 	security_scaffolding_startup();
+#ifdef CONFIG_SECURITY_SELINUX
+	selinux_init();
+#endif
 	buffer_init();
 	vfs_caches_init(num_physpages);
 	radix_tree_init();

Index: lsm-2.5/mm/shmem.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/mm/shmem.c,v
retrieving revision 1.1.1.22

mm/shmem.c +2 -0
diff -u -r1.1.1.22 shmem.c
@@ -31,6 +31,7 @@
 #include <linux/backing-dev.h>
 #include <linux/shmem_fs.h>
 #include <linux/mount.h>
+#include <linux/security.h>
 
 #include <asm/uaccess.h>
 
@@ -1058,6 +1059,7 @@
 		case S_IFLNK:
 			break;
 		}
+ 		security_inode_init(inode);
 	}
 	return inode;
 }

Index: lsm-2.5/net/netsyms.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/net/netsyms.c,v
retrieving revision 1.1.1.18

net/netsyms.c +2 -1
diff -u -r1.1.1.18 netsyms.c
@@ -324,7 +324,8 @@
 EXPORT_SYMBOL(xfrm_policy_list);
 
 
-#if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_IP_SCTP_MODULE)
+#if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_IP_SCTP_MODULE) || defined (CONFIG_SECURITY_SELINUX_SELOPT_MODULE)
+extern struct tcp_func  ipv4_specific;
 /* inet functions common to v4 and v6 */
 EXPORT_SYMBOL(inet_release);
 EXPORT_SYMBOL(inet_stream_connect);

Index: lsm-2.5/security/dummy.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/security/dummy.c,v retrieving revision 1.30

security/dummy.c +6 -0
diff -u -r1.30 dummy.c
@@ -258,6 +258,11 @@
 	return;
 }
 
+static void dummy_inode_init (struct inode *inode)
+{
+	return;
+}
+
 static int dummy_inode_create (struct inode *inode, struct dentry *dentry,
 			       int mask)
 {
@@ -914,6 +919,7 @@
 	set_to_dummy_if_null(ops, sb_post_pivotroot);
 	set_to_dummy_if_null(ops, inode_alloc_security);
 	set_to_dummy_if_null(ops, inode_free_security);
+	set_to_dummy_if_null(ops, inode_init);
 	set_to_dummy_if_null(ops, inode_create);
 	set_to_dummy_if_null(ops, inode_post_create);
 	set_to_dummy_if_null(ops, inode_link);

Index: lsm-2.5/security/selinux/hooks.c
===================================================================
RCS file: /home/pal/CVS/lsm-2.5/security/selinux/hooks.c,v retrieving revision 1.84

security/selinux/hooks.c +15 -0
diff -u -r1.84 hooks.c
@@ -65,6 +65,8 @@
 #include "selinux_plug.h"
 #include "extsocket.h"
 
+#define _SELINUX_KERNEL_PATCH_
+
 #ifndef _SELINUX_KERNEL_PATCH_
 #warning "SELinux:  The separate SELinux kernel patch has not been applied.  Using SELinux without this patch is not recommended."
 #endif
@@ -1919,6 +1921,18 @@
 	inode_free_security(inode);
 }
 
+static void selinux_inode_init(struct inode *inode)
+{
+	struct super_block *sb = inode->i_sb;
+	if (sb) {
+		struct superblock_security_struct *sbsec = sb->s_security;
+		if (sbsec && sbsec->uses_genfs)
+			/* Defer to inode_post_lookup. */
+			return;
+	}
+	inode_doinit(inode);
+}
+
 static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask)
 {
 	return may_create(dir, dentry, SECCLASS_FILE);
@@ -4041,6 +4055,7 @@
 
 	inode_alloc_security:		selinux_inode_alloc_security,
 	inode_free_security:		selinux_inode_free_security,
+	inode_init:		        selinux_inode_init,
 	inode_create:			selinux_inode_create,
 	inode_post_create:		selinux_inode_post_create,
 	inode_link:			selinux_inode_link,