diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-11 14:29:11 -0700 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-11 14:29:11 -0700 | 
| commit | c4cc75c3321cad6f20d1e5325293890255c8a663 (patch) | |
| tree | f515d034c9d6947bed0467840678aff823747596 /kernel/audit.h | |
| parent | 2dbd3cac87250a0d44e07acc86c4224a08522709 (diff) | |
| parent | 2a0b4be6dd655e24990da1d0811e28b9277f8b12 (diff) | |
| download | olio-linux-3.10-c4cc75c3321cad6f20d1e5325293890255c8a663.tar.xz olio-linux-3.10-c4cc75c3321cad6f20d1e5325293890255c8a663.zip  | |
Merge git://git.infradead.org/users/eparis/audit
Pull audit changes from Eric Paris:
 "Al used to send pull requests every couple of years but he told me to
  just start pushing them to you directly.
  Our touching outside of core audit code is pretty straight forward.  A
  couple of interface changes which hit net/.  A simple argument bug
  calling audit functions in namei.c and the removal of some assembly
  branch prediction code on ppc"
* git://git.infradead.org/users/eparis/audit: (31 commits)
  audit: fix message spacing printing auid
  Revert "audit: move kaudit thread start from auditd registration to kaudit init"
  audit: vfs: fix audit_inode call in O_CREAT case of do_last
  audit: Make testing for a valid loginuid explicit.
  audit: fix event coverage of AUDIT_ANOM_LINK
  audit: use spin_lock in audit_receive_msg to process tty logging
  audit: do not needlessly take a lock in tty_audit_exit
  audit: do not needlessly take a spinlock in copy_signal
  audit: add an option to control logging of passwords with pam_tty_audit
  audit: use spin_lock_irqsave/restore in audit tty code
  helper for some session id stuff
  audit: use a consistent audit helper to log lsm information
  audit: push loginuid and sessionid processing down
  audit: stop pushing loginid, uid, sessionid as arguments
  audit: remove the old depricated kernel interface
  audit: make validity checking generic
  audit: allow checking the type of audit message in the user filter
  audit: fix build break when AUDIT_DEBUG == 2
  audit: remove duplicate export of audit_enabled
  Audit: do not print error when LSMs disabled
  ...
Diffstat (limited to 'kernel/audit.h')
| -rw-r--r-- | kernel/audit.h | 156 | 
1 files changed, 156 insertions, 0 deletions
diff --git a/kernel/audit.h b/kernel/audit.h index 11468d99dad..1c95131ef76 100644 --- a/kernel/audit.h +++ b/kernel/audit.h @@ -22,6 +22,7 @@  #include <linux/fs.h>  #include <linux/audit.h>  #include <linux/skbuff.h> +#include <uapi/linux/mqueue.h>  /* 0 = no checking     1 = put_count checking @@ -29,6 +30,11 @@  */  #define AUDIT_DEBUG 0 +/* AUDIT_NAMES is the number of slots we reserve in the audit_context + * for saving names from getname().  If we get more names we will allocate + * a name dynamically and also add those to the list anchored by names_list. */ +#define AUDIT_NAMES	5 +  /* At task start time, the audit_state is set in the audit_context using     a per-task filter.  At syscall entry, the audit_state is augmented by     the syscall filter. */ @@ -59,8 +65,158 @@ struct audit_entry {  	struct audit_krule	rule;  }; +struct audit_cap_data { +	kernel_cap_t		permitted; +	kernel_cap_t		inheritable; +	union { +		unsigned int	fE;		/* effective bit of file cap */ +		kernel_cap_t	effective;	/* effective set of process */ +	}; +}; + +/* When fs/namei.c:getname() is called, we store the pointer in name and + * we don't let putname() free it (instead we free all of the saved + * pointers at syscall exit time). + * + * Further, in fs/namei.c:path_lookup() we store the inode and device. + */ +struct audit_names { +	struct list_head	list;		/* audit_context->names_list */ + +	struct filename		*name; +	int			name_len;	/* number of chars to log */ +	bool			name_put;	/* call __putname()? */ + +	unsigned long		ino; +	dev_t			dev; +	umode_t			mode; +	kuid_t			uid; +	kgid_t			gid; +	dev_t			rdev; +	u32			osid; +	struct audit_cap_data	fcap; +	unsigned int		fcap_ver; +	unsigned char		type;		/* record type */ +	/* +	 * This was an allocated audit_names and not from the array of +	 * names allocated in the task audit context.  Thus this name +	 * should be freed on syscall exit. +	 */ +	bool			should_free; +}; + +/* The per-task audit context. */ +struct audit_context { +	int		    dummy;	/* must be the first element */ +	int		    in_syscall;	/* 1 if task is in a syscall */ +	enum audit_state    state, current_state; +	unsigned int	    serial;     /* serial number for record */ +	int		    major;      /* syscall number */ +	struct timespec	    ctime;      /* time of syscall entry */ +	unsigned long	    argv[4];    /* syscall arguments */ +	long		    return_code;/* syscall return code */ +	u64		    prio; +	int		    return_valid; /* return code is valid */ +	/* +	 * The names_list is the list of all audit_names collected during this +	 * syscall.  The first AUDIT_NAMES entries in the names_list will +	 * actually be from the preallocated_names array for performance +	 * reasons.  Except during allocation they should never be referenced +	 * through the preallocated_names array and should only be found/used +	 * by running the names_list. +	 */ +	struct audit_names  preallocated_names[AUDIT_NAMES]; +	int		    name_count; /* total records in names_list */ +	struct list_head    names_list;	/* struct audit_names->list anchor */ +	char		    *filterkey;	/* key for rule that triggered record */ +	struct path	    pwd; +	struct audit_aux_data *aux; +	struct audit_aux_data *aux_pids; +	struct sockaddr_storage *sockaddr; +	size_t sockaddr_len; +				/* Save things to print about task_struct */ +	pid_t		    pid, ppid; +	kuid_t		    uid, euid, suid, fsuid; +	kgid_t		    gid, egid, sgid, fsgid; +	unsigned long	    personality; +	int		    arch; + +	pid_t		    target_pid; +	kuid_t		    target_auid; +	kuid_t		    target_uid; +	unsigned int	    target_sessionid; +	u32		    target_sid; +	char		    target_comm[TASK_COMM_LEN]; + +	struct audit_tree_refs *trees, *first_trees; +	struct list_head killed_trees; +	int tree_count; + +	int type; +	union { +		struct { +			int nargs; +			long args[6]; +		} socketcall; +		struct { +			kuid_t			uid; +			kgid_t			gid; +			umode_t			mode; +			u32			osid; +			int			has_perm; +			uid_t			perm_uid; +			gid_t			perm_gid; +			umode_t			perm_mode; +			unsigned long		qbytes; +		} ipc; +		struct { +			mqd_t			mqdes; +			struct mq_attr		mqstat; +		} mq_getsetattr; +		struct { +			mqd_t			mqdes; +			int			sigev_signo; +		} mq_notify; +		struct { +			mqd_t			mqdes; +			size_t			msg_len; +			unsigned int		msg_prio; +			struct timespec		abs_timeout; +		} mq_sendrecv; +		struct { +			int			oflag; +			umode_t			mode; +			struct mq_attr		attr; +		} mq_open; +		struct { +			pid_t			pid; +			struct audit_cap_data	cap; +		} capset; +		struct { +			int			fd; +			int			flags; +		} mmap; +	}; +	int fds[2]; + +#if AUDIT_DEBUG +	int		    put_count; +	int		    ino_count; +#endif +}; +  extern int audit_ever_enabled; +extern void audit_copy_inode(struct audit_names *name, +			     const struct dentry *dentry, +			     const struct inode *inode); +extern void audit_log_cap(struct audit_buffer *ab, char *prefix, +			  kernel_cap_t *cap); +extern void audit_log_fcaps(struct audit_buffer *ab, struct audit_names *name); +extern void audit_log_name(struct audit_context *context, +			   struct audit_names *n, struct path *path, +			   int record_num, int *call_panic); +  extern int audit_pid;  #define AUDIT_INODE_BUCKETS	32  |