All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Reporting file descriptors created by pipe and socketpair
@ 2006-09-12 16:07 John D. Ramsdell
  2006-09-12 16:21 ` Alexander Viro
  0 siblings, 1 reply; 7+ messages in thread
From: John D. Ramsdell @ 2006-09-12 16:07 UTC (permalink / raw)
  To: Linux Audit

The polgen tools suggest SELinux policy by analyzing dynamic traces of
a running set of related programs.  It derives information flow by
tracking file descriptors used by a set of programs, and notes which
processes performs reads and writes.  We would very much like to get
our raw data from autrace, however, the current traces it generates
lacks some crucial information.  The record for the pipe and
socketpair system call does not include the file descriptors created
upon success.  Enclosed is a patch by Mark Workman that remedies this
problem. 

John

Signed-off-by: John D. Ramsdell <ramsdell@mitre.org>
*** a/kernel/auditsc.c	2006-03-20 00:53:29.000000000 -0500
--- b/kernel/auditsc.c	2006-06-26 08:21:56.000000000 -0400
***************
*** 820,825 ****
--- 820,846 ----
  		audit_log_format(ab, " success=%s exit=%ld", 
  				 (context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
  				 context->return_code);
+ 
+         printk(KERN_INFO "%s  auditing what?\n", __FUNCTION__);
+ 
+ 	switch (context->major) {
+ 		case __NR_socketcall:
+ 			if (context->argv[0] == SYS_SOCKETPAIR)
+ 				audit_log_format(ab, " descriptor pair=%d,%d",
+ 						current->audit_pids[0],
+ 						current->audit_pids[1]);
+ 			break;
+ 
+ 		case __NR_pipe:
+ 			audit_log_format(ab, " descriptor pair=%d,%d",
+ 					current->audit_pids[0],
+ 					current->audit_pids[1]);
+ 			break;
+ 
+ 		default: break;
+ 	}
+ 
+ 
  	audit_log_format(ab,
  		  " a0=%lx a1=%lx a2=%lx a3=%lx items=%d"
  		  " pid=%d auid=%u uid=%u gid=%u"
*** a/fs/pipe.c	2006-03-20 00:53:29.000000000 -0500
--- b/fs/pipe.c	2006-06-26 10:10:15.000000000 -0400
***************
*** 779,786 ****
  
  	fd_install(i, f1);
  	fd_install(j, f2);
! 	fd[0] = i;
! 	fd[1] = j;
  	return 0;
  
  close_f12_inode_i_j:
--- 779,786 ----
  
  	fd_install(i, f1);
  	fd_install(j, f2);
! 	current->audit_pids[0] = fd[0] = i;
! 	current->audit_pids[1] = fd[1] = j;
  	return 0;
  
  close_f12_inode_i_j:
*** a/include/linux/sched.h	2006-03-20 00:53:29.000000000 -0500
--- b/include/linux/sched.h	2006-06-26 08:19:23.000000000 -0400
***************
*** 819,824 ****
--- 819,825 ----
  	void *security;
  	struct audit_context *audit_context;
  	seccomp_t seccomp;
+ 	int audit_pids [3];
  
  /* Thread group tracking */
     	u32 parent_exec_id;
*** a/net/socket.c	2006-03-20 00:53:29.000000000 -0500
--- b/net/socket.c	2006-06-26 12:35:23.000000000 -0400
***************
*** 1256,1263 ****
  	err = put_user(fd1, &usockvec[0]); 
  	if (!err)
  		err = put_user(fd2, &usockvec[1]);
! 	if (!err)
  		return 0;
  
  	sys_close(fd2);
  	sys_close(fd1);
--- 1256,1266 ----
  	err = put_user(fd1, &usockvec[0]); 
  	if (!err)
  		err = put_user(fd2, &usockvec[1]);
! 	if (!err) {
! 		current->audit_pids[0] = fd1;
! 		current->audit_pids[1] = fd2;
  		return 0;
+ 	}
  
  	sys_close(fd2);
  	sys_close(fd1);

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-09-12 21:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-12 16:07 [PATCH] Reporting file descriptors created by pipe and socketpair John D. Ramsdell
2006-09-12 16:21 ` Alexander Viro
2006-09-12 17:41   ` Steve Grubb
2006-09-12 18:25   ` John D. Ramsdell
2006-09-12 19:12     ` Alexander Viro
2006-09-12 21:05       ` John D. Ramsdell
2006-09-12 19:22   ` John D. Ramsdell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.