Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* audit -- definition of audit_context structure and supporting types 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright 2003-2004 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2005 Hewlett-Packard Development Company, L.P.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright 2005 IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/audit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <uapi/linux/mqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* AUDIT_NAMES is the number of slots we reserve in the audit_context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * for saving names from getname().  If we get more names we will allocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * a name dynamically and also add those to the list anchored by names_list. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define AUDIT_NAMES	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /* At task start time, the audit_state is set in the audit_context using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)    a per-task filter.  At syscall entry, the audit_state is augmented by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)    the syscall filter. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) enum audit_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	AUDIT_DISABLED,		/* Do not create per-task audit_context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 				 * No syscall-specific audit records can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 				 * be generated. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	AUDIT_BUILD_CONTEXT,	/* Create the per-task audit_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 				 * and fill it in at syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 				 * entry time.  This makes a full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 				 * syscall record available if some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 				 * other part of the kernel decides it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 				 * should be recorded. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	AUDIT_RECORD_CONTEXT	/* Create the per-task audit_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 				 * always fill it in at syscall entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 				 * time, and always write out the audit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 				 * record at syscall exit time.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /* Rule lists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) struct audit_watch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) struct audit_fsnotify_mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) struct audit_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct audit_chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct audit_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct rcu_head		rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct audit_krule	rule;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct audit_cap_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	kernel_cap_t		permitted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	kernel_cap_t		inheritable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		unsigned int	fE;		/* effective bit of file cap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		kernel_cap_t	effective;	/* effective set of process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	kernel_cap_t		ambient;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	kuid_t			rootid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* When fs/namei.c:getname() is called, we store the pointer in name and bump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * the refcnt in the associated filename struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * Further, in fs/namei.c:path_lookup() we store the inode and device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct audit_names {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct list_head	list;		/* audit_context->names_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct filename		*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	int			name_len;	/* number of chars to log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	bool			hidden;		/* don't log this record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	unsigned long		ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	dev_t			dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	umode_t			mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	kuid_t			uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	kgid_t			gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	dev_t			rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u32			osid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct audit_cap_data	fcap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	unsigned int		fcap_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	unsigned char		type;		/* record type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 * This was an allocated audit_names and not from the array of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * names allocated in the task audit context.  Thus this name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * should be freed on syscall exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	bool			should_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) struct audit_proctitle {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	int	len;	/* length of the cmdline field. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	char	*value;	/* the cmdline field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /* The per-task audit context. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct audit_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	int		    dummy;	/* must be the first element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	int		    in_syscall;	/* 1 if task is in a syscall */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	enum audit_state    state, current_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	unsigned int	    serial;     /* serial number for record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int		    major;      /* syscall number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct timespec64   ctime;      /* time of syscall entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	unsigned long	    argv[4];    /* syscall arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	long		    return_code;/* syscall return code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	u64		    prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	int		    return_valid; /* return code is valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 * The names_list is the list of all audit_names collected during this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	 * syscall.  The first AUDIT_NAMES entries in the names_list will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	 * actually be from the preallocated_names array for performance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	 * reasons.  Except during allocation they should never be referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	 * through the preallocated_names array and should only be found/used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	 * by running the names_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct audit_names  preallocated_names[AUDIT_NAMES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	int		    name_count; /* total records in names_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct list_head    names_list;	/* struct audit_names->list anchor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	char		    *filterkey;	/* key for rule that triggered record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct path	    pwd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct audit_aux_data *aux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct audit_aux_data *aux_pids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct sockaddr_storage *sockaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	size_t sockaddr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 				/* Save things to print about task_struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	pid_t		    pid, ppid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	kuid_t		    uid, euid, suid, fsuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	kgid_t		    gid, egid, sgid, fsgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	unsigned long	    personality;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int		    arch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	pid_t		    target_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	kuid_t		    target_auid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	kuid_t		    target_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	unsigned int	    target_sessionid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	u32		    target_sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	char		    target_comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct audit_tree_refs *trees, *first_trees;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct list_head killed_trees;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	int tree_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			int nargs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			long args[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		} socketcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			kuid_t			uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			kgid_t			gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			umode_t			mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			u32			osid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			int			has_perm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 			uid_t			perm_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			gid_t			perm_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			umode_t			perm_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			unsigned long		qbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		} ipc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			mqd_t			mqdes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			struct mq_attr		mqstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		} mq_getsetattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			mqd_t			mqdes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			int			sigev_signo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		} mq_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			mqd_t			mqdes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			size_t			msg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			unsigned int		msg_prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			struct timespec64	abs_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		} mq_sendrecv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			int			oflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			umode_t			mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			struct mq_attr		attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		} mq_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			pid_t			pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			struct audit_cap_data	cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		} capset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			int			fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			int			flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		} mmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			int			argc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		} execve;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			char			*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		} module;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			struct audit_ntp_data	ntp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			struct timespec64	tk_injoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		} time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	int fds[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct audit_proctitle proctitle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) extern bool audit_ever_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) extern void audit_log_session_info(struct audit_buffer *ab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) extern int auditd_test_task(struct task_struct *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #define AUDIT_INODE_BUCKETS	32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) extern struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static inline int audit_hash_ino(u32 ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return (ino & (AUDIT_INODE_BUCKETS-1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* Indicates that audit should log the full pathname. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #define AUDIT_NAME_FULL -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) extern int audit_match_class(int class, unsigned syscall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) extern int audit_comparator(const u32 left, const u32 op, const u32 right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) extern int audit_uid_comparator(kuid_t left, u32 op, kuid_t right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) extern int audit_gid_comparator(kgid_t left, u32 op, kgid_t right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) extern int parent_len(const char *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) extern int audit_compare_dname_path(const struct qstr *dname, const char *path, int plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) extern struct sk_buff *audit_make_reply(int seq, int type, int done, int multi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					const void *payload, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) extern void		    audit_panic(const char *message);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct audit_netlink_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	__u32 portid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	struct net *net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct sk_buff_head q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int audit_send_list_thread(void *_dest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) extern int selinux_audit_rule_update(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) extern struct mutex audit_filter_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) extern int audit_del_rule(struct audit_entry *entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) extern void audit_free_rule_rcu(struct rcu_head *head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) extern struct list_head audit_filter_list[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern struct audit_entry *audit_dupe_rule(struct audit_krule *old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) extern void audit_log_d_path_exe(struct audit_buffer *ab,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				 struct mm_struct *mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) extern struct tty_struct *audit_get_tty(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) extern void audit_put_tty(struct tty_struct *tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* audit watch/mark/tree functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #ifdef CONFIG_AUDITSYSCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) extern unsigned int audit_serial(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) extern int auditsc_get_stamp(struct audit_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			      struct timespec64 *t, unsigned int *serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) extern void audit_put_watch(struct audit_watch *watch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) extern void audit_get_watch(struct audit_watch *watch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) extern int audit_to_watch(struct audit_krule *krule, char *path, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			  u32 op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) extern int audit_add_watch(struct audit_krule *krule, struct list_head **list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) extern void audit_remove_watch_rule(struct audit_krule *krule);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) extern char *audit_watch_path(struct audit_watch *watch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) extern int audit_watch_compare(struct audit_watch *watch, unsigned long ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			       dev_t dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) extern struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 						    char *pathname, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) extern char *audit_mark_path(struct audit_fsnotify_mark *mark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) extern void audit_remove_mark(struct audit_fsnotify_mark *audit_mark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) extern void audit_remove_mark_rule(struct audit_krule *krule);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) extern int audit_mark_compare(struct audit_fsnotify_mark *mark,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			      unsigned long ino, dev_t dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) extern int audit_dupe_exe(struct audit_krule *new, struct audit_krule *old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) extern int audit_exe_compare(struct task_struct *tsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			     struct audit_fsnotify_mark *mark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) extern struct audit_chunk *audit_tree_lookup(const struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) extern void audit_put_chunk(struct audit_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) extern bool audit_tree_match(struct audit_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			     struct audit_tree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) extern int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) extern int audit_add_tree_rule(struct audit_krule *rule);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) extern int audit_remove_tree_rule(struct audit_krule *rule);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) extern void audit_trim_trees(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) extern int audit_tag_tree(char *old, char *new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) extern const char *audit_tree_path(struct audit_tree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) extern void audit_put_tree(struct audit_tree *tree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) extern void audit_kill_trees(struct audit_context *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) extern int audit_signal_info_syscall(struct task_struct *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) extern void audit_filter_inodes(struct task_struct *tsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				struct audit_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) extern struct list_head *audit_killed_trees(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #else /* CONFIG_AUDITSYSCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) #define auditsc_get_stamp(c, t, s) 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #define audit_put_watch(w) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define audit_get_watch(w) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) #define audit_to_watch(k, p, l, o) (-EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #define audit_add_watch(k, l) (-EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) #define audit_remove_watch_rule(k) BUG()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #define audit_watch_path(w) ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) #define audit_watch_compare(w, i, d) 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #define audit_alloc_mark(k, p, l) (ERR_PTR(-EINVAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) #define audit_mark_path(m) ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #define audit_remove_mark(m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #define audit_remove_mark_rule(k)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #define audit_mark_compare(m, i, d) 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define audit_exe_compare(t, m) (-EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #define audit_dupe_exe(n, o) (-EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define audit_remove_tree_rule(rule) BUG()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #define audit_add_tree_rule(rule) -EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define audit_make_tree(rule, str, op) -EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #define audit_trim_trees() (void)0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) #define audit_put_tree(tree) (void)0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define audit_tag_tree(old, new) -EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) #define audit_tree_path(rule) ""	/* never called */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #define audit_kill_trees(context) BUG()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) static inline int audit_signal_info_syscall(struct task_struct *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #define audit_filter_inodes(t, c) AUDIT_DISABLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #endif /* CONFIG_AUDITSYSCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) extern char *audit_unpack_string(void **bufp, size_t *remain, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) extern int audit_filter(int msgtype, unsigned int listtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) extern void audit_ctl_lock(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) extern void audit_ctl_unlock(void);