Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 85c8721 | 2005-04-29 16:23:29 +0100 | [diff] [blame] | 2 | /* audit.h -- Auditing support |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. |
| 5 | * All Rights Reserved. |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Written by Rickard E. (Rik) Faith <faith@redhat.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #ifndef _LINUX_AUDIT_H_ |
| 10 | #define _LINUX_AUDIT_H_ |
| 11 | |
David Woodhouse | f001e47 | 2006-04-27 00:11:01 +0100 | [diff] [blame] | 12 | #include <linux/sched.h> |
Mike Frysinger | c0a3a20 | 2013-01-11 14:32:13 -0800 | [diff] [blame] | 13 | #include <linux/ptrace.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 14 | #include <uapi/linux/audit.h> |
Richard Guy Briggs | 8e6cf36 | 2020-06-04 09:20:49 -0400 | [diff] [blame] | 15 | #include <uapi/linux/netfilter/nf_tables.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Richard Guy Briggs | 84cb777 | 2015-08-05 23:48:20 -0400 | [diff] [blame] | 17 | #define AUDIT_INO_UNSET ((unsigned long)-1) |
| 18 | #define AUDIT_DEV_UNSET ((dev_t)-1) |
| 19 | |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 20 | struct audit_sig_info { |
| 21 | uid_t uid; |
| 22 | pid_t pid; |
Gustavo A. R. Silva | 0090c1e | 2020-05-07 13:50:41 -0500 | [diff] [blame] | 23 | char ctx[]; |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 24 | }; |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | struct audit_buffer; |
| 27 | struct audit_context; |
| 28 | struct inode; |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 29 | struct netlink_skb_parms; |
Alexey Dobriyan | 37721e1 | 2011-01-10 08:17:10 +0200 | [diff] [blame] | 30 | struct path; |
Al Viro | 473ae30 | 2006-04-26 14:04:08 -0400 | [diff] [blame] | 31 | struct linux_binprm; |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 32 | struct mq_attr; |
| 33 | struct mqstat; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 34 | struct audit_watch; |
| 35 | struct audit_tree; |
Eric W. Biederman | 099dd23 | 2014-02-28 20:36:55 -0800 | [diff] [blame] | 36 | struct sk_buff; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 37 | |
| 38 | struct audit_krule { |
Richard Guy Briggs | 041d7b9 | 2014-12-23 13:02:04 -0500 | [diff] [blame] | 39 | u32 pflags; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 40 | u32 flags; |
| 41 | u32 listnr; |
| 42 | u32 action; |
| 43 | u32 mask[AUDIT_BITMASK_SIZE]; |
| 44 | u32 buflen; /* for data alloc on list rules */ |
| 45 | u32 field_count; |
| 46 | char *filterkey; /* ties events to rules */ |
| 47 | struct audit_field *fields; |
| 48 | struct audit_field *arch_f; /* quick access to arch field */ |
| 49 | struct audit_field *inode_f; /* quick access to an inode field */ |
| 50 | struct audit_watch *watch; /* associated watch */ |
| 51 | struct audit_tree *tree; /* associated watched tree */ |
Richard Guy Briggs | 34d99af5 | 2015-08-05 16:29:37 -0400 | [diff] [blame] | 52 | struct audit_fsnotify_mark *exe; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 53 | struct list_head rlist; /* entry in audit_{watch,tree}.rules list */ |
Al Viro | e45aa21 | 2008-12-15 01:17:50 -0500 | [diff] [blame] | 54 | struct list_head list; /* for AUDIT_LIST* purposes only */ |
Al Viro | 0590b93 | 2008-12-14 23:45:27 -0500 | [diff] [blame] | 55 | u64 prio; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
Richard Guy Briggs | 041d7b9 | 2014-12-23 13:02:04 -0500 | [diff] [blame] | 58 | /* Flag to indicate legacy AUDIT_LOGINUID unset usage */ |
| 59 | #define AUDIT_LOGINUID_LEGACY 0x1 |
| 60 | |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 61 | struct audit_field { |
| 62 | u32 type; |
Richard Guy Briggs | 219ca39 | 2014-03-26 07:26:47 -0400 | [diff] [blame] | 63 | union { |
| 64 | u32 val; |
| 65 | kuid_t uid; |
| 66 | kgid_t gid; |
| 67 | struct { |
| 68 | char *lsm_str; |
| 69 | void *lsm_rule; |
| 70 | }; |
| 71 | }; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 72 | u32 op; |
Ahmed S. Darwish | 9d57a7f | 2008-03-01 22:03:14 +0200 | [diff] [blame] | 73 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Ondrej Mosnacek | 7e8eda7 | 2019-04-10 11:14:20 +0200 | [diff] [blame] | 75 | enum audit_ntp_type { |
| 76 | AUDIT_NTP_OFFSET, |
| 77 | AUDIT_NTP_FREQ, |
| 78 | AUDIT_NTP_STATUS, |
| 79 | AUDIT_NTP_TAI, |
| 80 | AUDIT_NTP_TICK, |
| 81 | AUDIT_NTP_ADJUST, |
| 82 | |
| 83 | AUDIT_NTP_NVALS /* count */ |
| 84 | }; |
| 85 | |
| 86 | #ifdef CONFIG_AUDITSYSCALL |
| 87 | struct audit_ntp_val { |
| 88 | long long oldval, newval; |
| 89 | }; |
| 90 | |
| 91 | struct audit_ntp_data { |
| 92 | struct audit_ntp_val vals[AUDIT_NTP_NVALS]; |
| 93 | }; |
| 94 | #else |
| 95 | struct audit_ntp_data {}; |
| 96 | #endif |
| 97 | |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 98 | enum audit_nfcfgop { |
| 99 | AUDIT_XT_OP_REGISTER, |
| 100 | AUDIT_XT_OP_REPLACE, |
Richard Guy Briggs | a45d885 | 2020-04-22 17:39:29 -0400 | [diff] [blame] | 101 | AUDIT_XT_OP_UNREGISTER, |
Richard Guy Briggs | 8e6cf36 | 2020-06-04 09:20:49 -0400 | [diff] [blame] | 102 | AUDIT_NFT_OP_TABLE_REGISTER, |
| 103 | AUDIT_NFT_OP_TABLE_UNREGISTER, |
| 104 | AUDIT_NFT_OP_CHAIN_REGISTER, |
| 105 | AUDIT_NFT_OP_CHAIN_UNREGISTER, |
| 106 | AUDIT_NFT_OP_RULE_REGISTER, |
| 107 | AUDIT_NFT_OP_RULE_UNREGISTER, |
| 108 | AUDIT_NFT_OP_SET_REGISTER, |
| 109 | AUDIT_NFT_OP_SET_UNREGISTER, |
| 110 | AUDIT_NFT_OP_SETELEM_REGISTER, |
| 111 | AUDIT_NFT_OP_SETELEM_UNREGISTER, |
| 112 | AUDIT_NFT_OP_GEN_REGISTER, |
| 113 | AUDIT_NFT_OP_OBJ_REGISTER, |
| 114 | AUDIT_NFT_OP_OBJ_UNREGISTER, |
| 115 | AUDIT_NFT_OP_OBJ_RESET, |
| 116 | AUDIT_NFT_OP_FLOWTABLE_REGISTER, |
| 117 | AUDIT_NFT_OP_FLOWTABLE_UNREGISTER, |
| 118 | AUDIT_NFT_OP_INVALID, |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 119 | }; |
| 120 | |
Eric Paris | b0fed40 | 2013-05-22 12:54:49 -0400 | [diff] [blame] | 121 | extern int is_audit_feature_set(int which); |
| 122 | |
Al Viro | b915543 | 2006-07-01 03:56:16 -0400 | [diff] [blame] | 123 | extern int __init audit_register_class(int class, unsigned *list); |
Al Viro | 55669bf | 2006-08-31 19:26:40 -0400 | [diff] [blame] | 124 | extern int audit_classify_syscall(int abi, unsigned syscall); |
Amy Griffis | e54dc24 | 2007-03-29 18:01:04 -0400 | [diff] [blame] | 125 | extern int audit_classify_arch(int arch); |
AKASHI Takahiro | 4b58841 | 2014-03-15 14:48:00 +0900 | [diff] [blame] | 126 | /* only for compat system calls */ |
| 127 | extern unsigned compat_write_class[]; |
| 128 | extern unsigned compat_read_class[]; |
| 129 | extern unsigned compat_dir_class[]; |
| 130 | extern unsigned compat_chattr_class[]; |
| 131 | extern unsigned compat_signal_class[]; |
| 132 | |
Bjorn Helgaas | 9e8beeb | 2014-10-13 18:58:48 -0600 | [diff] [blame] | 133 | extern int audit_classify_compat_syscall(int abi, unsigned syscall); |
Jeff Layton | 78e2e80 | 2012-10-10 15:25:22 -0400 | [diff] [blame] | 134 | |
| 135 | /* audit_names->type values */ |
| 136 | #define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */ |
| 137 | #define AUDIT_TYPE_NORMAL 1 /* a "normal" audit record */ |
Jeff Layton | bfcec70 | 2012-10-10 15:25:23 -0400 | [diff] [blame] | 138 | #define AUDIT_TYPE_PARENT 2 /* a parent audit record */ |
Jeff Layton | 4fa6b5e | 2012-10-10 15:25:25 -0400 | [diff] [blame] | 139 | #define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */ |
| 140 | #define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */ |
Jeff Layton | 78e2e80 | 2012-10-10 15:25:22 -0400 | [diff] [blame] | 141 | |
Chen Gang | 2950fa9 | 2013-04-07 16:55:23 +0800 | [diff] [blame] | 142 | /* maximized args number that audit_socketcall can process */ |
| 143 | #define AUDITSC_ARGS 6 |
| 144 | |
Peter Hurley | 2e28d38 | 2016-01-09 22:55:33 -0800 | [diff] [blame] | 145 | /* bit values for ->signal->audit_tty */ |
| 146 | #define AUDIT_TTY_ENABLE BIT(0) |
| 147 | #define AUDIT_TTY_LOG_PASSWD BIT(1) |
| 148 | |
Jeff Layton | 91a27b2 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 149 | struct filename; |
| 150 | |
Richard Guy Briggs | f785959 | 2018-06-05 19:20:39 -0400 | [diff] [blame] | 151 | #define AUDIT_OFF 0 |
| 152 | #define AUDIT_ON 1 |
| 153 | #define AUDIT_LOCKED 2 |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 154 | #ifdef CONFIG_AUDIT |
| 155 | /* These are defined in audit.c */ |
| 156 | /* Public API */ |
| 157 | extern __printf(4, 5) |
| 158 | void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, |
| 159 | const char *fmt, ...); |
| 160 | |
| 161 | extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type); |
| 162 | extern __printf(2, 3) |
| 163 | void audit_log_format(struct audit_buffer *ab, const char *fmt, ...); |
| 164 | extern void audit_log_end(struct audit_buffer *ab); |
| 165 | extern bool audit_string_contains_control(const char *string, |
| 166 | size_t len); |
| 167 | extern void audit_log_n_hex(struct audit_buffer *ab, |
| 168 | const unsigned char *buf, |
| 169 | size_t len); |
| 170 | extern void audit_log_n_string(struct audit_buffer *ab, |
| 171 | const char *buf, |
| 172 | size_t n); |
| 173 | extern void audit_log_n_untrustedstring(struct audit_buffer *ab, |
| 174 | const char *string, |
| 175 | size_t n); |
| 176 | extern void audit_log_untrustedstring(struct audit_buffer *ab, |
| 177 | const char *string); |
| 178 | extern void audit_log_d_path(struct audit_buffer *ab, |
| 179 | const char *prefix, |
| 180 | const struct path *path); |
| 181 | extern void audit_log_key(struct audit_buffer *ab, |
| 182 | char *key); |
Kees Cook | 245d736 | 2019-10-02 16:41:58 -0700 | [diff] [blame] | 183 | extern void audit_log_path_denied(int type, |
| 184 | const char *operation); |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 185 | extern void audit_log_lost(const char *message); |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 186 | |
| 187 | extern int audit_log_task_context(struct audit_buffer *ab); |
Paul Moore | 2a1fe21 | 2018-11-26 18:40:07 -0500 | [diff] [blame] | 188 | extern void audit_log_task_info(struct audit_buffer *ab); |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 189 | |
| 190 | extern int audit_update_lsm_rules(void); |
| 191 | |
| 192 | /* Private API (for audit.c only) */ |
Paul Moore | 45a0642 | 2017-05-02 10:16:05 -0400 | [diff] [blame] | 193 | extern int audit_rule_change(int type, int seq, void *data, size_t datasz); |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 194 | extern int audit_list_rules_send(struct sk_buff *request_skb, int seq); |
| 195 | |
Richard Guy Briggs | 4b7d248 | 2019-01-22 17:06:39 -0500 | [diff] [blame] | 196 | extern int audit_set_loginuid(kuid_t loginuid); |
| 197 | |
| 198 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) |
| 199 | { |
| 200 | return tsk->loginuid; |
| 201 | } |
| 202 | |
| 203 | static inline unsigned int audit_get_sessionid(struct task_struct *tsk) |
| 204 | { |
| 205 | return tsk->sessionid; |
| 206 | } |
| 207 | |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 208 | extern u32 audit_enabled; |
Richard Guy Briggs | b48345a | 2019-05-10 12:21:49 -0400 | [diff] [blame] | 209 | |
| 210 | extern int audit_signal_info(int sig, struct task_struct *t); |
| 211 | |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 212 | #else /* CONFIG_AUDIT */ |
| 213 | static inline __printf(4, 5) |
| 214 | void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, |
| 215 | const char *fmt, ...) |
| 216 | { } |
| 217 | static inline struct audit_buffer *audit_log_start(struct audit_context *ctx, |
| 218 | gfp_t gfp_mask, int type) |
| 219 | { |
| 220 | return NULL; |
| 221 | } |
| 222 | static inline __printf(2, 3) |
| 223 | void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) |
| 224 | { } |
| 225 | static inline void audit_log_end(struct audit_buffer *ab) |
| 226 | { } |
| 227 | static inline void audit_log_n_hex(struct audit_buffer *ab, |
| 228 | const unsigned char *buf, size_t len) |
| 229 | { } |
| 230 | static inline void audit_log_n_string(struct audit_buffer *ab, |
| 231 | const char *buf, size_t n) |
| 232 | { } |
| 233 | static inline void audit_log_n_untrustedstring(struct audit_buffer *ab, |
| 234 | const char *string, size_t n) |
| 235 | { } |
| 236 | static inline void audit_log_untrustedstring(struct audit_buffer *ab, |
| 237 | const char *string) |
| 238 | { } |
| 239 | static inline void audit_log_d_path(struct audit_buffer *ab, |
| 240 | const char *prefix, |
| 241 | const struct path *path) |
| 242 | { } |
| 243 | static inline void audit_log_key(struct audit_buffer *ab, char *key) |
| 244 | { } |
Kees Cook | 245d736 | 2019-10-02 16:41:58 -0700 | [diff] [blame] | 245 | static inline void audit_log_path_denied(int type, const char *operation) |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 246 | { } |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 247 | static inline int audit_log_task_context(struct audit_buffer *ab) |
| 248 | { |
| 249 | return 0; |
| 250 | } |
Paul Moore | 2a1fe21 | 2018-11-26 18:40:07 -0500 | [diff] [blame] | 251 | static inline void audit_log_task_info(struct audit_buffer *ab) |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 252 | { } |
Richard Guy Briggs | 4b7d248 | 2019-01-22 17:06:39 -0500 | [diff] [blame] | 253 | |
| 254 | static inline kuid_t audit_get_loginuid(struct task_struct *tsk) |
| 255 | { |
| 256 | return INVALID_UID; |
| 257 | } |
| 258 | |
| 259 | static inline unsigned int audit_get_sessionid(struct task_struct *tsk) |
| 260 | { |
| 261 | return AUDIT_SID_UNSET; |
| 262 | } |
| 263 | |
Richard Guy Briggs | f785959 | 2018-06-05 19:20:39 -0400 | [diff] [blame] | 264 | #define audit_enabled AUDIT_OFF |
Richard Guy Briggs | b48345a | 2019-05-10 12:21:49 -0400 | [diff] [blame] | 265 | |
| 266 | static inline int audit_signal_info(int sig, struct task_struct *t) |
| 267 | { |
| 268 | return 0; |
| 269 | } |
| 270 | |
Paul Moore | 9636870 | 2016-01-13 09:18:55 -0500 | [diff] [blame] | 271 | #endif /* CONFIG_AUDIT */ |
| 272 | |
Chris Metcalf | 312103d | 2014-03-25 09:25:41 -0400 | [diff] [blame] | 273 | #ifdef CONFIG_AUDIT_COMPAT_GENERIC |
Eric Paris | 356750e | 2014-03-24 12:13:48 -0400 | [diff] [blame] | 274 | #define audit_is_compat(arch) (!((arch) & __AUDIT_ARCH_64BIT)) |
| 275 | #else |
| 276 | #define audit_is_compat(arch) false |
| 277 | #endif |
| 278 | |
Al Viro | c9b07ea | 2019-07-14 13:22:27 -0400 | [diff] [blame] | 279 | #define AUDIT_INODE_PARENT 1 /* dentry represents the parent */ |
| 280 | #define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */ |
| 281 | #define AUDIT_INODE_NOEVAL 4 /* audit record incomplete */ |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | #ifdef CONFIG_AUDITSYSCALL |
Eric Paris | a9ebe0b | 2014-04-22 11:46:16 -0400 | [diff] [blame] | 284 | #include <asm/syscall.h> /* for syscall_get_arch() */ |
| 285 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | /* These are defined in auditsc.c */ |
| 287 | /* Public API */ |
| 288 | extern int audit_alloc(struct task_struct *task); |
Eric Paris | a4ff8db | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 289 | extern void __audit_free(struct task_struct *task); |
Richard Guy Briggs | b4f0d37 | 2014-03-04 10:38:06 -0500 | [diff] [blame] | 290 | extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1, |
Eric Paris | b05d844 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 291 | unsigned long a2, unsigned long a3); |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 292 | extern void __audit_syscall_exit(int ret_success, long ret_value); |
Jeff Layton | 7ac8626 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 293 | extern struct filename *__audit_reusename(const __user char *uptr); |
Jeff Layton | 91a27b2 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 294 | extern void __audit_getname(struct filename *name); |
Richard Guy Briggs | d7481b2 | 2020-07-03 12:56:19 -0400 | [diff] [blame] | 295 | extern void __audit_getcwd(void); |
Jeff Layton | adb5c24 | 2012-10-10 16:43:13 -0400 | [diff] [blame] | 296 | extern void __audit_inode(struct filename *name, const struct dentry *dentry, |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 297 | unsigned int flags); |
Al Viro | 9f45f5b | 2014-10-31 17:44:57 -0400 | [diff] [blame] | 298 | extern void __audit_file(const struct file *); |
Andreas Gruenbacher | d6335d7 | 2015-12-24 11:09:39 -0500 | [diff] [blame] | 299 | extern void __audit_inode_child(struct inode *parent, |
Jeff Layton | 4fa6b5e | 2012-10-10 15:25:25 -0400 | [diff] [blame] | 300 | const struct dentry *dentry, |
| 301 | const unsigned char type); |
Tyler Hicks | 326bee0 | 2018-05-04 01:08:15 +0000 | [diff] [blame] | 302 | extern void audit_seccomp(unsigned long syscall, long signr, int code); |
Tyler Hicks | ea6eca7 | 2018-05-04 01:08:14 +0000 | [diff] [blame] | 303 | extern void audit_seccomp_actions_logged(const char *names, |
| 304 | const char *old_names, int res); |
Al Viro | a5cb013 | 2007-03-20 13:58:35 -0400 | [diff] [blame] | 305 | extern void __audit_ptrace(struct task_struct *t); |
| 306 | |
Richard Guy Briggs | c0b0ae8 | 2018-05-12 21:58:21 -0400 | [diff] [blame] | 307 | static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) |
| 308 | { |
| 309 | task->audit_context = ctx; |
| 310 | } |
| 311 | |
Richard Guy Briggs | cdfb6b3 | 2018-05-12 21:58:20 -0400 | [diff] [blame] | 312 | static inline struct audit_context *audit_context(void) |
| 313 | { |
| 314 | return current->audit_context; |
| 315 | } |
| 316 | |
Yaowei Bai | 3673481 | 2015-11-04 08:23:51 -0500 | [diff] [blame] | 317 | static inline bool audit_dummy_context(void) |
Al Viro | d51374a | 2006-08-03 10:59:26 -0400 | [diff] [blame] | 318 | { |
Richard Guy Briggs | cdfb6b3 | 2018-05-12 21:58:20 -0400 | [diff] [blame] | 319 | void *p = audit_context(); |
Al Viro | d51374a | 2006-08-03 10:59:26 -0400 | [diff] [blame] | 320 | return !p || *(int *)p; |
| 321 | } |
Eric Paris | a4ff8db | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 322 | static inline void audit_free(struct task_struct *task) |
| 323 | { |
| 324 | if (unlikely(task->audit_context)) |
| 325 | __audit_free(task); |
| 326 | } |
Eric Paris | 9139740 | 2014-03-11 13:29:28 -0400 | [diff] [blame] | 327 | static inline void audit_syscall_entry(int major, unsigned long a0, |
Eric Paris | b05d844 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 328 | unsigned long a1, unsigned long a2, |
| 329 | unsigned long a3) |
| 330 | { |
Richard Guy Briggs | cdfb6b3 | 2018-05-12 21:58:20 -0400 | [diff] [blame] | 331 | if (unlikely(audit_context())) |
Richard Guy Briggs | b4f0d37 | 2014-03-04 10:38:06 -0500 | [diff] [blame] | 332 | __audit_syscall_entry(major, a0, a1, a2, a3); |
Eric Paris | b05d844 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 333 | } |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 334 | static inline void audit_syscall_exit(void *pt_regs) |
| 335 | { |
Richard Guy Briggs | cdfb6b3 | 2018-05-12 21:58:20 -0400 | [diff] [blame] | 336 | if (unlikely(audit_context())) { |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 337 | int success = is_syscall_success(pt_regs); |
AKASHI Takahiro | 06bdadd | 2014-01-13 13:33:09 -0800 | [diff] [blame] | 338 | long return_code = regs_return_value(pt_regs); |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 339 | |
| 340 | __audit_syscall_exit(success, return_code); |
| 341 | } |
| 342 | } |
Jeff Layton | 7ac8626 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 343 | static inline struct filename *audit_reusename(const __user char *name) |
| 344 | { |
| 345 | if (unlikely(!audit_dummy_context())) |
| 346 | return __audit_reusename(name); |
| 347 | return NULL; |
| 348 | } |
Jeff Layton | 91a27b2 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 349 | static inline void audit_getname(struct filename *name) |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 350 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 351 | if (unlikely(!audit_dummy_context())) |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 352 | __audit_getname(name); |
| 353 | } |
Richard Guy Briggs | d7481b2 | 2020-07-03 12:56:19 -0400 | [diff] [blame] | 354 | static inline void audit_getcwd(void) |
| 355 | { |
| 356 | if (unlikely(audit_context())) |
| 357 | __audit_getcwd(); |
| 358 | } |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 359 | static inline void audit_inode(struct filename *name, |
| 360 | const struct dentry *dentry, |
Al Viro | c9b07ea | 2019-07-14 13:22:27 -0400 | [diff] [blame] | 361 | unsigned int aflags) { |
| 362 | if (unlikely(!audit_dummy_context())) |
Richard Guy Briggs | 57d4657 | 2019-01-23 13:35:00 -0500 | [diff] [blame] | 363 | __audit_inode(name, dentry, aflags); |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 364 | } |
Al Viro | 9f45f5b | 2014-10-31 17:44:57 -0400 | [diff] [blame] | 365 | static inline void audit_file(struct file *file) |
| 366 | { |
| 367 | if (unlikely(!audit_dummy_context())) |
| 368 | __audit_file(file); |
| 369 | } |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 370 | static inline void audit_inode_parent_hidden(struct filename *name, |
| 371 | const struct dentry *dentry) |
| 372 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 373 | if (unlikely(!audit_dummy_context())) |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 374 | __audit_inode(name, dentry, |
| 375 | AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN); |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 376 | } |
Andreas Gruenbacher | d6335d7 | 2015-12-24 11:09:39 -0500 | [diff] [blame] | 377 | static inline void audit_inode_child(struct inode *parent, |
Jeff Layton | 4fa6b5e | 2012-10-10 15:25:25 -0400 | [diff] [blame] | 378 | const struct dentry *dentry, |
| 379 | const unsigned char type) { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 380 | if (unlikely(!audit_dummy_context())) |
Jeff Layton | 4fa6b5e | 2012-10-10 15:25:25 -0400 | [diff] [blame] | 381 | __audit_inode_child(parent, dentry, type); |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 382 | } |
Steve Grubb | 0a4ff8c | 2007-04-19 10:28:21 -0400 | [diff] [blame] | 383 | void audit_core_dumps(long signr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | |
Al Viro | a5cb013 | 2007-03-20 13:58:35 -0400 | [diff] [blame] | 385 | static inline void audit_ptrace(struct task_struct *t) |
| 386 | { |
| 387 | if (unlikely(!audit_dummy_context())) |
| 388 | __audit_ptrace(t); |
| 389 | } |
| 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | /* Private API (for audit.c only) */ |
Al Viro | a33e675 | 2008-12-10 03:40:06 -0500 | [diff] [blame] | 392 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); |
Al Viro | 2570ebb | 2011-07-27 14:03:22 -0400 | [diff] [blame] | 393 | extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); |
Richard Guy Briggs | d9cfea9 | 2013-10-30 17:56:13 -0400 | [diff] [blame] | 394 | extern void __audit_bprm(struct linux_binprm *bprm); |
Chen Gang | 2950fa9 | 2013-04-07 16:55:23 +0800 | [diff] [blame] | 395 | extern int __audit_socketcall(int nargs, unsigned long *args); |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 396 | extern int __audit_sockaddr(int len, void *addr); |
Al Viro | 157cf64 | 2008-12-14 04:57:47 -0500 | [diff] [blame] | 397 | extern void __audit_fd_pair(int fd1, int fd2); |
Al Viro | df0a428 | 2011-07-26 05:26:10 -0400 | [diff] [blame] | 398 | extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); |
Deepa Dinamani | b904772 | 2017-08-02 19:51:11 -0700 | [diff] [blame] | 399 | extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout); |
Al Viro | 20114f7 | 2008-12-10 07:16:12 -0500 | [diff] [blame] | 400 | extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); |
Al Viro | 7392906 | 2008-12-10 06:58:59 -0500 | [diff] [blame] | 401 | extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 402 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, |
| 403 | const struct cred *new, |
| 404 | const struct cred *old); |
Eric W. Biederman | ca24a23 | 2013-03-19 00:02:25 -0700 | [diff] [blame] | 405 | extern void __audit_log_capset(const struct cred *new, const struct cred *old); |
Al Viro | 120a795 | 2010-10-30 02:54:44 -0400 | [diff] [blame] | 406 | extern void __audit_mmap_fd(int fd, int flags); |
Richard Guy Briggs | ca86cad | 2017-02-04 13:10:38 -0500 | [diff] [blame] | 407 | extern void __audit_log_kern_module(char *name); |
Steve Grubb | de8cd83 | 2017-10-02 20:21:39 -0400 | [diff] [blame] | 408 | extern void __audit_fanotify(unsigned int response); |
Ondrej Mosnacek | 2d87a06 | 2019-04-10 11:14:19 +0200 | [diff] [blame] | 409 | extern void __audit_tk_injoffset(struct timespec64 offset); |
Ondrej Mosnacek | 7e8eda7 | 2019-04-10 11:14:20 +0200 | [diff] [blame] | 410 | extern void __audit_ntp_log(const struct audit_ntp_data *ad); |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 411 | extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries, |
Richard Guy Briggs | 1422403 | 2020-06-27 23:24:19 -0400 | [diff] [blame] | 412 | enum audit_nfcfgop op, gfp_t gfp); |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 413 | |
Al Viro | a33e675 | 2008-12-10 03:40:06 -0500 | [diff] [blame] | 414 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 415 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 416 | if (unlikely(!audit_dummy_context())) |
Al Viro | a33e675 | 2008-12-10 03:40:06 -0500 | [diff] [blame] | 417 | __audit_ipc_obj(ipcp); |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 418 | } |
Al Viro | 157cf64 | 2008-12-14 04:57:47 -0500 | [diff] [blame] | 419 | static inline void audit_fd_pair(int fd1, int fd2) |
Al Viro | db34950 | 2007-02-07 01:48:00 -0500 | [diff] [blame] | 420 | { |
| 421 | if (unlikely(!audit_dummy_context())) |
Al Viro | 157cf64 | 2008-12-14 04:57:47 -0500 | [diff] [blame] | 422 | __audit_fd_pair(fd1, fd2); |
Al Viro | db34950 | 2007-02-07 01:48:00 -0500 | [diff] [blame] | 423 | } |
Al Viro | 2570ebb | 2011-07-27 14:03:22 -0400 | [diff] [blame] | 424 | static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode) |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 425 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 426 | if (unlikely(!audit_dummy_context())) |
Al Viro | e816f37 | 2008-12-10 03:47:15 -0500 | [diff] [blame] | 427 | __audit_ipc_set_perm(qbytes, uid, gid, mode); |
Al Viro | d8945bb5 | 2006-05-18 16:01:30 -0400 | [diff] [blame] | 428 | } |
Richard Guy Briggs | 9410d22 | 2013-10-30 18:05:24 -0400 | [diff] [blame] | 429 | static inline void audit_bprm(struct linux_binprm *bprm) |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 430 | { |
| 431 | if (unlikely(!audit_dummy_context())) |
Richard Guy Briggs | d9cfea9 | 2013-10-30 17:56:13 -0400 | [diff] [blame] | 432 | __audit_bprm(bprm); |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 433 | } |
Chen Gang | 2950fa9 | 2013-04-07 16:55:23 +0800 | [diff] [blame] | 434 | static inline int audit_socketcall(int nargs, unsigned long *args) |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 435 | { |
| 436 | if (unlikely(!audit_dummy_context())) |
Chen Gang | 2950fa9 | 2013-04-07 16:55:23 +0800 | [diff] [blame] | 437 | return __audit_socketcall(nargs, args); |
| 438 | return 0; |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 439 | } |
Richard Guy Briggs | 62bc306 | 2017-01-17 11:07:15 -0500 | [diff] [blame] | 440 | |
| 441 | static inline int audit_socketcall_compat(int nargs, u32 *args) |
| 442 | { |
| 443 | unsigned long a[AUDITSC_ARGS]; |
| 444 | int i; |
| 445 | |
| 446 | if (audit_dummy_context()) |
| 447 | return 0; |
| 448 | |
| 449 | for (i = 0; i < nargs; i++) |
| 450 | a[i] = (unsigned long)args[i]; |
| 451 | return __audit_socketcall(nargs, a); |
| 452 | } |
| 453 | |
Eric Paris | 07c4941 | 2012-01-03 14:23:07 -0500 | [diff] [blame] | 454 | static inline int audit_sockaddr(int len, void *addr) |
| 455 | { |
| 456 | if (unlikely(!audit_dummy_context())) |
| 457 | return __audit_sockaddr(len, addr); |
| 458 | return 0; |
| 459 | } |
Al Viro | df0a428 | 2011-07-26 05:26:10 -0400 | [diff] [blame] | 460 | static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 461 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 462 | if (unlikely(!audit_dummy_context())) |
Al Viro | 564f699 | 2008-12-14 04:02:26 -0500 | [diff] [blame] | 463 | __audit_mq_open(oflag, mode, attr); |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 464 | } |
Deepa Dinamani | b904772 | 2017-08-02 19:51:11 -0700 | [diff] [blame] | 465 | static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout) |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 466 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 467 | if (unlikely(!audit_dummy_context())) |
Al Viro | c32c8af | 2008-12-14 03:46:48 -0500 | [diff] [blame] | 468 | __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout); |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 469 | } |
Al Viro | 20114f7 | 2008-12-10 07:16:12 -0500 | [diff] [blame] | 470 | static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification) |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 471 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 472 | if (unlikely(!audit_dummy_context())) |
Al Viro | 20114f7 | 2008-12-10 07:16:12 -0500 | [diff] [blame] | 473 | __audit_mq_notify(mqdes, notification); |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 474 | } |
Al Viro | 7392906 | 2008-12-10 06:58:59 -0500 | [diff] [blame] | 475 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 476 | { |
Al Viro | 5ac3a9c | 2006-07-16 06:38:45 -0400 | [diff] [blame] | 477 | if (unlikely(!audit_dummy_context())) |
Al Viro | 7392906 | 2008-12-10 06:58:59 -0500 | [diff] [blame] | 478 | __audit_mq_getsetattr(mqdes, mqstat); |
George C. Wilson | 20ca73b | 2006-05-24 16:09:55 -0500 | [diff] [blame] | 479 | } |
Eric Paris | 3fc689e | 2008-11-11 21:48:18 +1100 | [diff] [blame] | 480 | |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 481 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, |
| 482 | const struct cred *new, |
| 483 | const struct cred *old) |
Eric Paris | 3fc689e | 2008-11-11 21:48:18 +1100 | [diff] [blame] | 484 | { |
| 485 | if (unlikely(!audit_dummy_context())) |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 486 | return __audit_log_bprm_fcaps(bprm, new, old); |
| 487 | return 0; |
Eric Paris | 3fc689e | 2008-11-11 21:48:18 +1100 | [diff] [blame] | 488 | } |
| 489 | |
Eric W. Biederman | ca24a23 | 2013-03-19 00:02:25 -0700 | [diff] [blame] | 490 | static inline void audit_log_capset(const struct cred *new, |
David Howells | d84f4f9 | 2008-11-14 10:39:23 +1100 | [diff] [blame] | 491 | const struct cred *old) |
Eric Paris | e68b75a0 | 2008-11-11 21:48:22 +1100 | [diff] [blame] | 492 | { |
| 493 | if (unlikely(!audit_dummy_context())) |
Eric W. Biederman | ca24a23 | 2013-03-19 00:02:25 -0700 | [diff] [blame] | 494 | __audit_log_capset(new, old); |
Eric Paris | e68b75a0 | 2008-11-11 21:48:22 +1100 | [diff] [blame] | 495 | } |
| 496 | |
Al Viro | 120a795 | 2010-10-30 02:54:44 -0400 | [diff] [blame] | 497 | static inline void audit_mmap_fd(int fd, int flags) |
| 498 | { |
| 499 | if (unlikely(!audit_dummy_context())) |
| 500 | __audit_mmap_fd(fd, flags); |
| 501 | } |
| 502 | |
Richard Guy Briggs | ca86cad | 2017-02-04 13:10:38 -0500 | [diff] [blame] | 503 | static inline void audit_log_kern_module(char *name) |
| 504 | { |
| 505 | if (!audit_dummy_context()) |
| 506 | __audit_log_kern_module(name); |
| 507 | } |
| 508 | |
Steve Grubb | de8cd83 | 2017-10-02 20:21:39 -0400 | [diff] [blame] | 509 | static inline void audit_fanotify(unsigned int response) |
| 510 | { |
| 511 | if (!audit_dummy_context()) |
| 512 | __audit_fanotify(response); |
| 513 | } |
| 514 | |
Ondrej Mosnacek | 2d87a06 | 2019-04-10 11:14:19 +0200 | [diff] [blame] | 515 | static inline void audit_tk_injoffset(struct timespec64 offset) |
| 516 | { |
| 517 | /* ignore no-op events */ |
| 518 | if (offset.tv_sec == 0 && offset.tv_nsec == 0) |
| 519 | return; |
| 520 | |
| 521 | if (!audit_dummy_context()) |
| 522 | __audit_tk_injoffset(offset); |
| 523 | } |
| 524 | |
Ondrej Mosnacek | 7e8eda7 | 2019-04-10 11:14:20 +0200 | [diff] [blame] | 525 | static inline void audit_ntp_init(struct audit_ntp_data *ad) |
| 526 | { |
| 527 | memset(ad, 0, sizeof(*ad)); |
| 528 | } |
| 529 | |
| 530 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, |
| 531 | enum audit_ntp_type type, long long val) |
| 532 | { |
| 533 | ad->vals[type].oldval = val; |
| 534 | } |
| 535 | |
| 536 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, |
| 537 | enum audit_ntp_type type, long long val) |
| 538 | { |
| 539 | ad->vals[type].newval = val; |
| 540 | } |
| 541 | |
| 542 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) |
| 543 | { |
| 544 | if (!audit_dummy_context()) |
| 545 | __audit_ntp_log(ad); |
| 546 | } |
| 547 | |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 548 | static inline void audit_log_nfcfg(const char *name, u8 af, |
| 549 | unsigned int nentries, |
Richard Guy Briggs | 1422403 | 2020-06-27 23:24:19 -0400 | [diff] [blame] | 550 | enum audit_nfcfgop op, gfp_t gfp) |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 551 | { |
| 552 | if (audit_enabled) |
Richard Guy Briggs | 1422403 | 2020-06-27 23:24:19 -0400 | [diff] [blame] | 553 | __audit_log_nfcfg(name, af, nentries, op, gfp); |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 554 | } |
| 555 | |
Al Viro | 471a5c7 | 2006-07-10 08:29:24 -0400 | [diff] [blame] | 556 | extern int audit_n_rules; |
Amy Griffis | e54dc24 | 2007-03-29 18:01:04 -0400 | [diff] [blame] | 557 | extern int audit_signals; |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 558 | #else /* CONFIG_AUDITSYSCALL */ |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 559 | static inline int audit_alloc(struct task_struct *task) |
| 560 | { |
| 561 | return 0; |
| 562 | } |
| 563 | static inline void audit_free(struct task_struct *task) |
| 564 | { } |
Eric Paris | 9139740 | 2014-03-11 13:29:28 -0400 | [diff] [blame] | 565 | static inline void audit_syscall_entry(int major, unsigned long a0, |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 566 | unsigned long a1, unsigned long a2, |
| 567 | unsigned long a3) |
| 568 | { } |
| 569 | static inline void audit_syscall_exit(void *pt_regs) |
| 570 | { } |
Yaowei Bai | 3673481 | 2015-11-04 08:23:51 -0500 | [diff] [blame] | 571 | static inline bool audit_dummy_context(void) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 572 | { |
Yaowei Bai | 3673481 | 2015-11-04 08:23:51 -0500 | [diff] [blame] | 573 | return true; |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 574 | } |
Richard Guy Briggs | c0b0ae8 | 2018-05-12 21:58:21 -0400 | [diff] [blame] | 575 | static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) |
| 576 | { } |
Richard Guy Briggs | cdfb6b3 | 2018-05-12 21:58:20 -0400 | [diff] [blame] | 577 | static inline struct audit_context *audit_context(void) |
| 578 | { |
| 579 | return NULL; |
| 580 | } |
Jeff Layton | 7ac8626 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 581 | static inline struct filename *audit_reusename(const __user char *name) |
| 582 | { |
| 583 | return NULL; |
| 584 | } |
Jeff Layton | 91a27b2 | 2012-10-10 15:25:28 -0400 | [diff] [blame] | 585 | static inline void audit_getname(struct filename *name) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 586 | { } |
Richard Guy Briggs | d7481b2 | 2020-07-03 12:56:19 -0400 | [diff] [blame] | 587 | static inline void audit_getcwd(void) |
| 588 | { } |
Jeff Layton | adb5c24 | 2012-10-10 16:43:13 -0400 | [diff] [blame] | 589 | static inline void audit_inode(struct filename *name, |
| 590 | const struct dentry *dentry, |
Al Viro | c9b07ea | 2019-07-14 13:22:27 -0400 | [diff] [blame] | 591 | unsigned int aflags) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 592 | { } |
Al Viro | 9f45f5b | 2014-10-31 17:44:57 -0400 | [diff] [blame] | 593 | static inline void audit_file(struct file *file) |
| 594 | { |
| 595 | } |
Jeff Layton | 79f6530 | 2013-07-08 15:59:36 -0700 | [diff] [blame] | 596 | static inline void audit_inode_parent_hidden(struct filename *name, |
| 597 | const struct dentry *dentry) |
| 598 | { } |
Andreas Gruenbacher | d6335d7 | 2015-12-24 11:09:39 -0500 | [diff] [blame] | 599 | static inline void audit_inode_child(struct inode *parent, |
Jeff Layton | 4fa6b5e | 2012-10-10 15:25:25 -0400 | [diff] [blame] | 600 | const struct dentry *dentry, |
| 601 | const unsigned char type) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 602 | { } |
| 603 | static inline void audit_core_dumps(long signr) |
| 604 | { } |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 605 | static inline void audit_seccomp(unsigned long syscall, long signr, int code) |
| 606 | { } |
Tyler Hicks | ea6eca7 | 2018-05-04 01:08:14 +0000 | [diff] [blame] | 607 | static inline void audit_seccomp_actions_logged(const char *names, |
| 608 | const char *old_names, int res) |
| 609 | { } |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 610 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
| 611 | { } |
| 612 | static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, |
| 613 | gid_t gid, umode_t mode) |
| 614 | { } |
Richard Guy Briggs | 9410d22 | 2013-10-30 18:05:24 -0400 | [diff] [blame] | 615 | static inline void audit_bprm(struct linux_binprm *bprm) |
| 616 | { } |
Chen Gang | 2950fa9 | 2013-04-07 16:55:23 +0800 | [diff] [blame] | 617 | static inline int audit_socketcall(int nargs, unsigned long *args) |
| 618 | { |
| 619 | return 0; |
| 620 | } |
Richard Guy Briggs | 62bc306 | 2017-01-17 11:07:15 -0500 | [diff] [blame] | 621 | |
| 622 | static inline int audit_socketcall_compat(int nargs, u32 *args) |
| 623 | { |
| 624 | return 0; |
| 625 | } |
| 626 | |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 627 | static inline void audit_fd_pair(int fd1, int fd2) |
| 628 | { } |
| 629 | static inline int audit_sockaddr(int len, void *addr) |
| 630 | { |
| 631 | return 0; |
| 632 | } |
| 633 | static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) |
| 634 | { } |
| 635 | static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, |
| 636 | unsigned int msg_prio, |
Deepa Dinamani | b904772 | 2017-08-02 19:51:11 -0700 | [diff] [blame] | 637 | const struct timespec64 *abs_timeout) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 638 | { } |
| 639 | static inline void audit_mq_notify(mqd_t mqdes, |
| 640 | const struct sigevent *notification) |
| 641 | { } |
| 642 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
| 643 | { } |
| 644 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, |
| 645 | const struct cred *new, |
| 646 | const struct cred *old) |
| 647 | { |
| 648 | return 0; |
| 649 | } |
Eric W. Biederman | ca24a23 | 2013-03-19 00:02:25 -0700 | [diff] [blame] | 650 | static inline void audit_log_capset(const struct cred *new, |
| 651 | const struct cred *old) |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 652 | { } |
| 653 | static inline void audit_mmap_fd(int fd, int flags) |
| 654 | { } |
Richard Guy Briggs | ca86cad | 2017-02-04 13:10:38 -0500 | [diff] [blame] | 655 | |
| 656 | static inline void audit_log_kern_module(char *name) |
| 657 | { |
| 658 | } |
| 659 | |
Steve Grubb | de8cd83 | 2017-10-02 20:21:39 -0400 | [diff] [blame] | 660 | static inline void audit_fanotify(unsigned int response) |
| 661 | { } |
| 662 | |
Ondrej Mosnacek | 2d87a06 | 2019-04-10 11:14:19 +0200 | [diff] [blame] | 663 | static inline void audit_tk_injoffset(struct timespec64 offset) |
| 664 | { } |
| 665 | |
Ondrej Mosnacek | 7e8eda7 | 2019-04-10 11:14:20 +0200 | [diff] [blame] | 666 | static inline void audit_ntp_init(struct audit_ntp_data *ad) |
| 667 | { } |
| 668 | |
| 669 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, |
| 670 | enum audit_ntp_type type, long long val) |
| 671 | { } |
| 672 | |
| 673 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, |
| 674 | enum audit_ntp_type type, long long val) |
| 675 | { } |
| 676 | |
| 677 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) |
| 678 | { } |
| 679 | |
Kees Cook | 9321d52 | 2012-10-04 17:11:11 -0700 | [diff] [blame] | 680 | static inline void audit_ptrace(struct task_struct *t) |
| 681 | { } |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 682 | |
| 683 | static inline void audit_log_nfcfg(const char *name, u8 af, |
| 684 | unsigned int nentries, |
Richard Guy Briggs | 1422403 | 2020-06-27 23:24:19 -0400 | [diff] [blame] | 685 | enum audit_nfcfgop op, gfp_t gfp) |
Richard Guy Briggs | c4dad0a | 2020-04-22 17:39:28 -0400 | [diff] [blame] | 686 | { } |
| 687 | |
Al Viro | 471a5c7 | 2006-07-10 08:29:24 -0400 | [diff] [blame] | 688 | #define audit_n_rules 0 |
Amy Griffis | e54dc24 | 2007-03-29 18:01:04 -0400 | [diff] [blame] | 689 | #define audit_signals 0 |
Eric Paris | d7e7528 | 2012-01-03 14:23:06 -0500 | [diff] [blame] | 690 | #endif /* CONFIG_AUDITSYSCALL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
Eric W. Biederman | 780a765 | 2013-04-09 02:22:10 -0700 | [diff] [blame] | 692 | static inline bool audit_loginuid_set(struct task_struct *tsk) |
| 693 | { |
| 694 | return uid_valid(audit_get_loginuid(tsk)); |
| 695 | } |
| 696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | #endif |