| 85c8721 | 2005-04-29 16:23:29 +0100 | [diff] [blame] | 1 | /* auditsc.c -- System-call auditing support |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Handles all system-call specific auditing features. |
| 3 | * |
| 4 | * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 5 | * Copyright 2005 Hewlett-Packard Development Company, L.P. |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 6 | * Copyright (C) 2005 IBM Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * All Rights Reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * Written by Rickard E. (Rik) Faith <faith@redhat.com> |
| 24 | * |
| 25 | * Many of the ideas implemented here are from Stephen C. Tweedie, |
| 26 | * especially the idea of avoiding a copy by using getname. |
| 27 | * |
| 28 | * The method for actual interception of syscall entry and exit (not in |
| 29 | * this file -- see entry.S) is based on a GPL'd patch written by |
| 30 | * okir@suse.de and Copyright 2003 SuSE Linux AG. |
| 31 | * |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 32 | * The support of additional filter rules compares (>, <, >=, <=) was |
| 33 | * added by Dustin Kirkland <dustin.kirkland@us.ibm.com>, 2005. |
| 34 | * |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 35 | * Modified by Amy Griffis <amy.griffis@hp.com> to collect additional |
| 36 | * filesystem information. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | */ |
| 38 | |
| 39 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <asm/types.h> |
Alan Cox | 715b49e | 2006-01-18 17:44:07 -0800 | [diff] [blame] | 41 | #include <asm/atomic.h> |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 42 | #include <asm/types.h> |
| 43 | #include <linux/fs.h> |
| 44 | #include <linux/namei.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/mm.h> |
| 46 | #include <linux/module.h> |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 47 | #include <linux/mount.h> |
David Woodhouse | 3ec3b2f | 2005-05-17 12:08:48 +0100 | [diff] [blame] | 48 | #include <linux/socket.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/audit.h> |
| 50 | #include <linux/personality.h> |
| 51 | #include <linux/time.h> |
David Woodhouse | f6a789d | 2005-06-21 16:22:01 +0100 | [diff] [blame] | 52 | #include <linux/kthread.h> |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 53 | #include <linux/netlink.h> |
David Woodhouse | f556196 | 2005-07-13 22:47:07 +0100 | [diff] [blame] | 54 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #include <asm/unistd.h> |
| 56 | |
| 57 | /* 0 = no checking |
| 58 | 1 = put_count checking |
| 59 | 2 = verbose put_count checking |
| 60 | */ |
| 61 | #define AUDIT_DEBUG 0 |
| 62 | |
| 63 | /* No syscall auditing will take place unless audit_enabled != 0. */ |
| 64 | extern int audit_enabled; |
| 65 | |
| 66 | /* AUDIT_NAMES is the number of slots we reserve in the audit_context |
| 67 | * for saving names from getname(). */ |
| 68 | #define AUDIT_NAMES 20 |
| 69 | |
| 70 | /* AUDIT_NAMES_RESERVED is the number of slots we reserve in the |
| 71 | * audit_context from being used for nameless inodes from |
| 72 | * path_lookup. */ |
| 73 | #define AUDIT_NAMES_RESERVED 7 |
| 74 | |
| 75 | /* At task start time, the audit_state is set in the audit_context using |
| 76 | a per-task filter. At syscall entry, the audit_state is augmented by |
| 77 | the syscall filter. */ |
| 78 | enum audit_state { |
| 79 | AUDIT_DISABLED, /* Do not create per-task audit_context. |
| 80 | * No syscall-specific audit records can |
| 81 | * be generated. */ |
| 82 | AUDIT_SETUP_CONTEXT, /* Create the per-task audit_context, |
| 83 | * but don't necessarily fill it in at |
| 84 | * syscall entry time (i.e., filter |
| 85 | * instead). */ |
| 86 | AUDIT_BUILD_CONTEXT, /* Create the per-task audit_context, |
| 87 | * and always fill it in at syscall |
| 88 | * entry time. This makes a full |
| 89 | * syscall record available if some |
| 90 | * other part of the kernel decides it |
| 91 | * should be recorded. */ |
| 92 | AUDIT_RECORD_CONTEXT /* Create the per-task audit_context, |
| 93 | * always fill it in at syscall entry |
| 94 | * time, and always write out the audit |
| 95 | * record at syscall exit time. */ |
| 96 | }; |
| 97 | |
| 98 | /* When fs/namei.c:getname() is called, we store the pointer in name and |
| 99 | * we don't let putname() free it (instead we free all of the saved |
| 100 | * pointers at syscall exit time). |
| 101 | * |
| 102 | * Further, in fs/namei.c:path_lookup() we store the inode and device. */ |
| 103 | struct audit_names { |
| 104 | const char *name; |
| 105 | unsigned long ino; |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 106 | unsigned long pino; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | dev_t dev; |
| 108 | umode_t mode; |
| 109 | uid_t uid; |
| 110 | gid_t gid; |
| 111 | dev_t rdev; |
| 112 | }; |
| 113 | |
| 114 | struct audit_aux_data { |
| 115 | struct audit_aux_data *next; |
| 116 | int type; |
| 117 | }; |
| 118 | |
| 119 | #define AUDIT_AUX_IPCPERM 0 |
| 120 | |
| 121 | struct audit_aux_data_ipcctl { |
| 122 | struct audit_aux_data d; |
| 123 | struct ipc_perm p; |
| 124 | unsigned long qbytes; |
| 125 | uid_t uid; |
| 126 | gid_t gid; |
| 127 | mode_t mode; |
| 128 | }; |
| 129 | |
David Woodhouse | 3ec3b2f | 2005-05-17 12:08:48 +0100 | [diff] [blame] | 130 | struct audit_aux_data_socketcall { |
| 131 | struct audit_aux_data d; |
| 132 | int nargs; |
| 133 | unsigned long args[0]; |
| 134 | }; |
| 135 | |
| 136 | struct audit_aux_data_sockaddr { |
| 137 | struct audit_aux_data d; |
| 138 | int len; |
| 139 | char a[0]; |
| 140 | }; |
| 141 | |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 142 | struct audit_aux_data_path { |
| 143 | struct audit_aux_data d; |
| 144 | struct dentry *dentry; |
| 145 | struct vfsmount *mnt; |
| 146 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | /* The per-task audit context. */ |
| 149 | struct audit_context { |
| 150 | int in_syscall; /* 1 if task is in a syscall */ |
| 151 | enum audit_state state; |
| 152 | unsigned int serial; /* serial number for record */ |
| 153 | struct timespec ctime; /* time of syscall entry */ |
| 154 | uid_t loginuid; /* login uid (identity) */ |
| 155 | int major; /* syscall number */ |
| 156 | unsigned long argv[4]; /* syscall arguments */ |
| 157 | int return_valid; /* return code is valid */ |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 158 | long return_code;/* syscall return code */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | int auditable; /* 1 if record should be written */ |
| 160 | int name_count; |
| 161 | struct audit_names names[AUDIT_NAMES]; |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 162 | struct dentry * pwd; |
| 163 | struct vfsmount * pwdmnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | struct audit_context *previous; /* For nested syscalls */ |
| 165 | struct audit_aux_data *aux; |
| 166 | |
| 167 | /* Save things to print about task_struct */ |
| 168 | pid_t pid; |
| 169 | uid_t uid, euid, suid, fsuid; |
| 170 | gid_t gid, egid, sgid, fsgid; |
| 171 | unsigned long personality; |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 172 | int arch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | #if AUDIT_DEBUG |
| 175 | int put_count; |
| 176 | int ino_count; |
| 177 | #endif |
| 178 | }; |
| 179 | |
| 180 | /* Public API */ |
| 181 | /* There are three lists of rules -- one to search at task creation |
| 182 | * time, one to search at syscall entry time, and another to search at |
| 183 | * syscall exit time. */ |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 184 | static struct list_head audit_filter_list[AUDIT_NR_FILTERS] = { |
| 185 | LIST_HEAD_INIT(audit_filter_list[0]), |
| 186 | LIST_HEAD_INIT(audit_filter_list[1]), |
| 187 | LIST_HEAD_INIT(audit_filter_list[2]), |
| 188 | LIST_HEAD_INIT(audit_filter_list[3]), |
| 189 | LIST_HEAD_INIT(audit_filter_list[4]), |
| 190 | #if AUDIT_NR_FILTERS != 5 |
| 191 | #error Fix audit_filter_list initialiser |
| 192 | #endif |
| 193 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | struct audit_entry { |
| 196 | struct list_head list; |
| 197 | struct rcu_head rcu; |
| 198 | struct audit_rule rule; |
| 199 | }; |
| 200 | |
David Woodhouse | 7ca0026 | 2005-05-19 11:23:13 +0100 | [diff] [blame] | 201 | extern int audit_pid; |
| 202 | |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 203 | /* Copy rule from user-space to kernel-space. Called from |
| 204 | * audit_add_rule during AUDIT_ADD. */ |
| 205 | static inline int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) |
| 206 | { |
| 207 | int i; |
| 208 | |
| 209 | if (s->action != AUDIT_NEVER |
| 210 | && s->action != AUDIT_POSSIBLE |
| 211 | && s->action != AUDIT_ALWAYS) |
| 212 | return -1; |
| 213 | if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS) |
| 214 | return -1; |
| 215 | if ((s->flags & ~AUDIT_FILTER_PREPEND) >= AUDIT_NR_FILTERS) |
| 216 | return -1; |
| 217 | |
| 218 | d->flags = s->flags; |
| 219 | d->action = s->action; |
| 220 | d->field_count = s->field_count; |
| 221 | for (i = 0; i < d->field_count; i++) { |
| 222 | d->fields[i] = s->fields[i]; |
| 223 | d->values[i] = s->values[i]; |
| 224 | } |
| 225 | for (i = 0; i < AUDIT_BITMASK_SIZE; i++) d->mask[i] = s->mask[i]; |
| 226 | return 0; |
| 227 | } |
| 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | /* Check to see if two rules are identical. It is called from |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 230 | * audit_add_rule during AUDIT_ADD and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | * audit_del_rule during AUDIT_DEL. */ |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 232 | static inline int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
| 234 | int i; |
| 235 | |
| 236 | if (a->flags != b->flags) |
| 237 | return 1; |
| 238 | |
| 239 | if (a->action != b->action) |
| 240 | return 1; |
| 241 | |
| 242 | if (a->field_count != b->field_count) |
| 243 | return 1; |
| 244 | |
| 245 | for (i = 0; i < a->field_count; i++) { |
| 246 | if (a->fields[i] != b->fields[i] |
| 247 | || a->values[i] != b->values[i]) |
| 248 | return 1; |
| 249 | } |
| 250 | |
| 251 | for (i = 0; i < AUDIT_BITMASK_SIZE; i++) |
| 252 | if (a->mask[i] != b->mask[i]) |
| 253 | return 1; |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | /* Note that audit_add_rule and audit_del_rule are called via |
| 259 | * audit_receive() in audit.c, and are protected by |
| 260 | * audit_netlink_sem. */ |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 261 | static inline int audit_add_rule(struct audit_rule *rule, |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 262 | struct list_head *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | { |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 264 | struct audit_entry *entry; |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 265 | int i; |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 266 | |
| 267 | /* Do not use the _rcu iterator here, since this is the only |
| 268 | * addition routine. */ |
| 269 | list_for_each_entry(entry, list, list) { |
| 270 | if (!audit_compare_rule(rule, &entry->rule)) { |
| 271 | return -EEXIST; |
| 272 | } |
| 273 | } |
| 274 | |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 275 | for (i = 0; i < rule->field_count; i++) { |
| 276 | if (rule->fields[i] & AUDIT_UNUSED_BITS) |
| 277 | return -EINVAL; |
| 278 | if ( rule->fields[i] & AUDIT_NEGATE ) |
| 279 | rule->fields[i] |= AUDIT_NOT_EQUAL; |
| 280 | else if ( (rule->fields[i] & AUDIT_OPERATORS) == 0 ) |
| 281 | rule->fields[i] |= AUDIT_EQUAL; |
| 282 | rule->fields[i] &= (~AUDIT_NEGATE); |
| 283 | } |
| 284 | |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 285 | if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL))) |
| 286 | return -ENOMEM; |
| 287 | if (audit_copy_rule(&entry->rule, rule)) { |
| 288 | kfree(entry); |
| 289 | return -EINVAL; |
| 290 | } |
| 291 | |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 292 | if (entry->rule.flags & AUDIT_FILTER_PREPEND) { |
| 293 | entry->rule.flags &= ~AUDIT_FILTER_PREPEND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | list_add_rcu(&entry->list, list); |
| 295 | } else { |
| 296 | list_add_tail_rcu(&entry->list, list); |
| 297 | } |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 298 | |
| 299 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } |
| 301 | |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 302 | static inline void audit_free_rule(struct rcu_head *head) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | { |
| 304 | struct audit_entry *e = container_of(head, struct audit_entry, rcu); |
| 305 | kfree(e); |
| 306 | } |
| 307 | |
| 308 | /* Note that audit_add_rule and audit_del_rule are called via |
| 309 | * audit_receive() in audit.c, and are protected by |
| 310 | * audit_netlink_sem. */ |
| 311 | static inline int audit_del_rule(struct audit_rule *rule, |
| 312 | struct list_head *list) |
| 313 | { |
| 314 | struct audit_entry *e; |
| 315 | |
| 316 | /* Do not use the _rcu iterator here, since this is the only |
| 317 | * deletion routine. */ |
| 318 | list_for_each_entry(e, list, list) { |
| 319 | if (!audit_compare_rule(rule, &e->rule)) { |
| 320 | list_del_rcu(&e->list); |
| 321 | call_rcu(&e->rcu, audit_free_rule); |
| 322 | return 0; |
| 323 | } |
| 324 | } |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 325 | return -ENOENT; /* No matching rule */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
| 327 | |
David Woodhouse | f6a789d | 2005-06-21 16:22:01 +0100 | [diff] [blame] | 328 | static int audit_list_rules(void *_dest) |
| 329 | { |
| 330 | int pid, seq; |
| 331 | int *dest = _dest; |
| 332 | struct audit_entry *entry; |
| 333 | int i; |
| 334 | |
| 335 | pid = dest[0]; |
| 336 | seq = dest[1]; |
| 337 | kfree(dest); |
| 338 | |
| 339 | down(&audit_netlink_sem); |
| 340 | |
| 341 | /* The *_rcu iterators not needed here because we are |
| 342 | always called with audit_netlink_sem held. */ |
| 343 | for (i=0; i<AUDIT_NR_FILTERS; i++) { |
| 344 | list_for_each_entry(entry, &audit_filter_list[i], list) |
| 345 | audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, |
| 346 | &entry->rule, sizeof(entry->rule)); |
| 347 | } |
| 348 | audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0); |
| 349 | |
| 350 | up(&audit_netlink_sem); |
| 351 | return 0; |
| 352 | } |
| 353 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 354 | /** |
| 355 | * audit_receive_filter - apply all rules to the specified message type |
| 356 | * @type: audit message type |
| 357 | * @pid: target pid for netlink audit messages |
| 358 | * @uid: target uid for netlink audit messages |
| 359 | * @seq: netlink audit message sequence (serial) number |
| 360 | * @data: payload data |
| 361 | * @loginuid: loginuid of sender |
| 362 | */ |
Serge Hallyn | c94c257 | 2005-04-29 16:27:17 +0100 | [diff] [blame] | 363 | int audit_receive_filter(int type, int pid, int uid, int seq, void *data, |
| 364 | uid_t loginuid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | { |
David Woodhouse | f6a789d | 2005-06-21 16:22:01 +0100 | [diff] [blame] | 366 | struct task_struct *tsk; |
| 367 | int *dest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | int err = 0; |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 369 | unsigned listnr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
| 371 | switch (type) { |
| 372 | case AUDIT_LIST: |
David Woodhouse | f6a789d | 2005-06-21 16:22:01 +0100 | [diff] [blame] | 373 | /* We can't just spew out the rules here because we might fill |
| 374 | * the available socket buffer space and deadlock waiting for |
| 375 | * auditctl to read from it... which isn't ever going to |
| 376 | * happen if we're actually running in the context of auditctl |
| 377 | * trying to _send_ the stuff */ |
| 378 | |
| 379 | dest = kmalloc(2 * sizeof(int), GFP_KERNEL); |
| 380 | if (!dest) |
| 381 | return -ENOMEM; |
| 382 | dest[0] = pid; |
| 383 | dest[1] = seq; |
| 384 | |
| 385 | tsk = kthread_run(audit_list_rules, dest, "audit_list_rules"); |
| 386 | if (IS_ERR(tsk)) { |
| 387 | kfree(dest); |
| 388 | err = PTR_ERR(tsk); |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 389 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | break; |
| 391 | case AUDIT_ADD: |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 392 | listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND; |
| 393 | if (listnr >= AUDIT_NR_FILTERS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | return -EINVAL; |
Amy Griffis | 3c789a1 | 2005-08-17 16:05:35 +0100 | [diff] [blame] | 395 | |
| 396 | err = audit_add_rule(data, &audit_filter_list[listnr]); |
| 397 | if (!err) |
| 398 | audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, |
| 399 | "auid=%u added an audit rule\n", loginuid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | break; |
| 401 | case AUDIT_DEL: |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 402 | listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND; |
| 403 | if (listnr >= AUDIT_NR_FILTERS) |
| 404 | return -EINVAL; |
| 405 | |
| 406 | err = audit_del_rule(data, &audit_filter_list[listnr]); |
| 407 | if (!err) |
David Woodhouse | 9ad9ad3 | 2005-06-22 15:04:33 +0100 | [diff] [blame] | 408 | audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 409 | "auid=%u removed an audit rule\n", loginuid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | break; |
| 411 | default: |
| 412 | return -EINVAL; |
| 413 | } |
| 414 | |
| 415 | return err; |
| 416 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 418 | static int audit_comparator(const u32 left, const u32 op, const u32 right) |
| 419 | { |
| 420 | switch (op) { |
| 421 | case AUDIT_EQUAL: |
| 422 | return (left == right); |
| 423 | case AUDIT_NOT_EQUAL: |
| 424 | return (left != right); |
| 425 | case AUDIT_LESS_THAN: |
| 426 | return (left < right); |
| 427 | case AUDIT_LESS_THAN_OR_EQUAL: |
| 428 | return (left <= right); |
| 429 | case AUDIT_GREATER_THAN: |
| 430 | return (left > right); |
| 431 | case AUDIT_GREATER_THAN_OR_EQUAL: |
| 432 | return (left >= right); |
| 433 | default: |
| 434 | return -EINVAL; |
| 435 | } |
| 436 | } |
| 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | /* Compare a task_struct with an audit_rule. Return 1 on match, 0 |
| 439 | * otherwise. */ |
| 440 | static int audit_filter_rules(struct task_struct *tsk, |
| 441 | struct audit_rule *rule, |
| 442 | struct audit_context *ctx, |
| 443 | enum audit_state *state) |
| 444 | { |
| 445 | int i, j; |
| 446 | |
| 447 | for (i = 0; i < rule->field_count; i++) { |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 448 | u32 field = rule->fields[i] & ~AUDIT_OPERATORS; |
| 449 | u32 op = rule->fields[i] & AUDIT_OPERATORS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | u32 value = rule->values[i]; |
| 451 | int result = 0; |
| 452 | |
| 453 | switch (field) { |
| 454 | case AUDIT_PID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 455 | result = audit_comparator(tsk->pid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | break; |
| 457 | case AUDIT_UID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 458 | result = audit_comparator(tsk->uid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | break; |
| 460 | case AUDIT_EUID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 461 | result = audit_comparator(tsk->euid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | break; |
| 463 | case AUDIT_SUID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 464 | result = audit_comparator(tsk->suid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | break; |
| 466 | case AUDIT_FSUID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 467 | result = audit_comparator(tsk->fsuid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | break; |
| 469 | case AUDIT_GID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 470 | result = audit_comparator(tsk->gid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | break; |
| 472 | case AUDIT_EGID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 473 | result = audit_comparator(tsk->egid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | break; |
| 475 | case AUDIT_SGID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 476 | result = audit_comparator(tsk->sgid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | break; |
| 478 | case AUDIT_FSGID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 479 | result = audit_comparator(tsk->fsgid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | break; |
| 481 | case AUDIT_PERS: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 482 | result = audit_comparator(tsk->personality, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | break; |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 484 | case AUDIT_ARCH: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 485 | if (ctx) |
| 486 | result = audit_comparator(ctx->arch, op, value); |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 487 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | case AUDIT_EXIT: |
| 490 | if (ctx && ctx->return_valid) |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 491 | result = audit_comparator(ctx->return_code, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | break; |
| 493 | case AUDIT_SUCCESS: |
David Woodhouse | b01f2cc | 2005-08-27 10:25:43 +0100 | [diff] [blame] | 494 | if (ctx && ctx->return_valid) { |
| 495 | if (value) |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 496 | result = audit_comparator(ctx->return_valid, op, AUDITSC_SUCCESS); |
David Woodhouse | b01f2cc | 2005-08-27 10:25:43 +0100 | [diff] [blame] | 497 | else |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 498 | result = audit_comparator(ctx->return_valid, op, AUDITSC_FAILURE); |
David Woodhouse | b01f2cc | 2005-08-27 10:25:43 +0100 | [diff] [blame] | 499 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | break; |
| 501 | case AUDIT_DEVMAJOR: |
| 502 | if (ctx) { |
| 503 | for (j = 0; j < ctx->name_count; j++) { |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 504 | if (audit_comparator(MAJOR(ctx->names[j].dev), op, value)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | ++result; |
| 506 | break; |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | break; |
| 511 | case AUDIT_DEVMINOR: |
| 512 | if (ctx) { |
| 513 | for (j = 0; j < ctx->name_count; j++) { |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 514 | if (audit_comparator(MINOR(ctx->names[j].dev), op, value)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | ++result; |
| 516 | break; |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | break; |
| 521 | case AUDIT_INODE: |
| 522 | if (ctx) { |
| 523 | for (j = 0; j < ctx->name_count; j++) { |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 524 | if (audit_comparator(ctx->names[j].ino, op, value) || |
| 525 | audit_comparator(ctx->names[j].pino, op, value)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | ++result; |
| 527 | break; |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | break; |
| 532 | case AUDIT_LOGINUID: |
| 533 | result = 0; |
| 534 | if (ctx) |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 535 | result = audit_comparator(ctx->loginuid, op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | break; |
| 537 | case AUDIT_ARG0: |
| 538 | case AUDIT_ARG1: |
| 539 | case AUDIT_ARG2: |
| 540 | case AUDIT_ARG3: |
| 541 | if (ctx) |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 542 | result = audit_comparator(ctx->argv[field-AUDIT_ARG0], op, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | break; |
| 544 | } |
| 545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | if (!result) |
| 547 | return 0; |
| 548 | } |
| 549 | switch (rule->action) { |
| 550 | case AUDIT_NEVER: *state = AUDIT_DISABLED; break; |
| 551 | case AUDIT_POSSIBLE: *state = AUDIT_BUILD_CONTEXT; break; |
| 552 | case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break; |
| 553 | } |
| 554 | return 1; |
| 555 | } |
| 556 | |
| 557 | /* At process creation time, we can determine if system-call auditing is |
| 558 | * completely disabled for this task. Since we only have the task |
| 559 | * structure at this point, we can only check uid and gid. |
| 560 | */ |
| 561 | static enum audit_state audit_filter_task(struct task_struct *tsk) |
| 562 | { |
| 563 | struct audit_entry *e; |
| 564 | enum audit_state state; |
| 565 | |
| 566 | rcu_read_lock(); |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 567 | list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { |
| 569 | rcu_read_unlock(); |
| 570 | return state; |
| 571 | } |
| 572 | } |
| 573 | rcu_read_unlock(); |
| 574 | return AUDIT_BUILD_CONTEXT; |
| 575 | } |
| 576 | |
| 577 | /* At syscall entry and exit time, this filter is called if the |
| 578 | * audit_state is not low enough that auditing cannot take place, but is |
Steve Grubb | 23f32d1 | 2005-05-13 18:35:15 +0100 | [diff] [blame] | 579 | * also not high enough that we already know we have to write an audit |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 580 | * record (i.e., the state is AUDIT_SETUP_CONTEXT or AUDIT_BUILD_CONTEXT). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | */ |
| 582 | static enum audit_state audit_filter_syscall(struct task_struct *tsk, |
| 583 | struct audit_context *ctx, |
| 584 | struct list_head *list) |
| 585 | { |
| 586 | struct audit_entry *e; |
David Woodhouse | c389649 | 2005-08-17 14:49:57 +0100 | [diff] [blame] | 587 | enum audit_state state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
David Woodhouse | 351bb72 | 2005-07-14 14:40:06 +0100 | [diff] [blame] | 589 | if (audit_pid && tsk->tgid == audit_pid) |
David Woodhouse | f7056d6 | 2005-06-20 16:07:33 +0100 | [diff] [blame] | 590 | return AUDIT_DISABLED; |
| 591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | rcu_read_lock(); |
David Woodhouse | c389649 | 2005-08-17 14:49:57 +0100 | [diff] [blame] | 593 | if (!list_empty(list)) { |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 594 | int word = AUDIT_WORD(ctx->major); |
| 595 | int bit = AUDIT_BIT(ctx->major); |
David Woodhouse | c389649 | 2005-08-17 14:49:57 +0100 | [diff] [blame] | 596 | |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 597 | list_for_each_entry_rcu(e, list, list) { |
| 598 | if ((e->rule.mask[word] & bit) == bit |
| 599 | && audit_filter_rules(tsk, &e->rule, ctx, &state)) { |
| 600 | rcu_read_unlock(); |
| 601 | return state; |
| 602 | } |
| 603 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } |
| 605 | rcu_read_unlock(); |
| 606 | return AUDIT_BUILD_CONTEXT; |
| 607 | } |
| 608 | |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 609 | static int audit_filter_user_rules(struct netlink_skb_parms *cb, |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 610 | struct audit_rule *rule, |
| 611 | enum audit_state *state) |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 612 | { |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 613 | int i; |
| 614 | |
| 615 | for (i = 0; i < rule->field_count; i++) { |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 616 | u32 field = rule->fields[i] & ~AUDIT_OPERATORS; |
| 617 | u32 op = rule->fields[i] & AUDIT_OPERATORS; |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 618 | u32 value = rule->values[i]; |
| 619 | int result = 0; |
| 620 | |
| 621 | switch (field) { |
| 622 | case AUDIT_PID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 623 | result = audit_comparator(cb->creds.pid, op, value); |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 624 | break; |
| 625 | case AUDIT_UID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 626 | result = audit_comparator(cb->creds.uid, op, value); |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 627 | break; |
| 628 | case AUDIT_GID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 629 | result = audit_comparator(cb->creds.gid, op, value); |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 630 | break; |
| 631 | case AUDIT_LOGINUID: |
Dustin Kirkland | b63862f | 2005-11-03 15:41:46 +0000 | [diff] [blame] | 632 | result = audit_comparator(cb->loginuid, op, value); |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 633 | break; |
| 634 | } |
| 635 | |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 636 | if (!result) |
| 637 | return 0; |
| 638 | } |
| 639 | switch (rule->action) { |
| 640 | case AUDIT_NEVER: *state = AUDIT_DISABLED; break; |
| 641 | case AUDIT_POSSIBLE: *state = AUDIT_BUILD_CONTEXT; break; |
| 642 | case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break; |
| 643 | } |
| 644 | return 1; |
| 645 | } |
| 646 | |
| 647 | int audit_filter_user(struct netlink_skb_parms *cb, int type) |
| 648 | { |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 649 | struct audit_entry *e; |
| 650 | enum audit_state state; |
David Woodhouse | 4a4cd63 | 2005-06-22 14:56:47 +0100 | [diff] [blame] | 651 | int ret = 1; |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 652 | |
| 653 | rcu_read_lock(); |
| 654 | list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) { |
David Woodhouse | 5bb289b | 2005-06-24 14:14:05 +0100 | [diff] [blame] | 655 | if (audit_filter_user_rules(cb, &e->rule, &state)) { |
David Woodhouse | 4a4cd63 | 2005-06-22 14:56:47 +0100 | [diff] [blame] | 656 | if (state == AUDIT_DISABLED) |
| 657 | ret = 0; |
| 658 | break; |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | rcu_read_unlock(); |
David Woodhouse | 4a4cd63 | 2005-06-22 14:56:47 +0100 | [diff] [blame] | 662 | |
David Woodhouse | 993e2d4 | 2005-06-24 08:21:49 +0100 | [diff] [blame] | 663 | return ret; /* Audit by default */ |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 664 | } |
| 665 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | /* This should be called with task_lock() held. */ |
| 667 | static inline struct audit_context *audit_get_context(struct task_struct *tsk, |
| 668 | int return_valid, |
| 669 | int return_code) |
| 670 | { |
| 671 | struct audit_context *context = tsk->audit_context; |
| 672 | |
| 673 | if (likely(!context)) |
| 674 | return NULL; |
| 675 | context->return_valid = return_valid; |
| 676 | context->return_code = return_code; |
| 677 | |
David Woodhouse | 21af6c4 | 2005-07-02 14:10:46 +0100 | [diff] [blame] | 678 | if (context->in_syscall && !context->auditable) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | enum audit_state state; |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 680 | state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | if (state == AUDIT_RECORD_CONTEXT) |
| 682 | context->auditable = 1; |
| 683 | } |
| 684 | |
| 685 | context->pid = tsk->pid; |
| 686 | context->uid = tsk->uid; |
| 687 | context->gid = tsk->gid; |
| 688 | context->euid = tsk->euid; |
| 689 | context->suid = tsk->suid; |
| 690 | context->fsuid = tsk->fsuid; |
| 691 | context->egid = tsk->egid; |
| 692 | context->sgid = tsk->sgid; |
| 693 | context->fsgid = tsk->fsgid; |
| 694 | context->personality = tsk->personality; |
| 695 | tsk->audit_context = NULL; |
| 696 | return context; |
| 697 | } |
| 698 | |
| 699 | static inline void audit_free_names(struct audit_context *context) |
| 700 | { |
| 701 | int i; |
| 702 | |
| 703 | #if AUDIT_DEBUG == 2 |
| 704 | if (context->auditable |
| 705 | ||context->put_count + context->ino_count != context->name_count) { |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 706 | printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | " name_count=%d put_count=%d" |
| 708 | " ino_count=%d [NOT freeing]\n", |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 709 | __FILE__, __LINE__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | context->serial, context->major, context->in_syscall, |
| 711 | context->name_count, context->put_count, |
| 712 | context->ino_count); |
| 713 | for (i = 0; i < context->name_count; i++) |
| 714 | printk(KERN_ERR "names[%d] = %p = %s\n", i, |
| 715 | context->names[i].name, |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 716 | context->names[i].name ?: "(null)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | dump_stack(); |
| 718 | return; |
| 719 | } |
| 720 | #endif |
| 721 | #if AUDIT_DEBUG |
| 722 | context->put_count = 0; |
| 723 | context->ino_count = 0; |
| 724 | #endif |
| 725 | |
| 726 | for (i = 0; i < context->name_count; i++) |
| 727 | if (context->names[i].name) |
| 728 | __putname(context->names[i].name); |
| 729 | context->name_count = 0; |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 730 | if (context->pwd) |
| 731 | dput(context->pwd); |
| 732 | if (context->pwdmnt) |
| 733 | mntput(context->pwdmnt); |
| 734 | context->pwd = NULL; |
| 735 | context->pwdmnt = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | static inline void audit_free_aux(struct audit_context *context) |
| 739 | { |
| 740 | struct audit_aux_data *aux; |
| 741 | |
| 742 | while ((aux = context->aux)) { |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 743 | if (aux->type == AUDIT_AVC_PATH) { |
| 744 | struct audit_aux_data_path *axi = (void *)aux; |
| 745 | dput(axi->dentry); |
| 746 | mntput(axi->mnt); |
| 747 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | context->aux = aux->next; |
| 749 | kfree(aux); |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | static inline void audit_zero_context(struct audit_context *context, |
| 754 | enum audit_state state) |
| 755 | { |
| 756 | uid_t loginuid = context->loginuid; |
| 757 | |
| 758 | memset(context, 0, sizeof(*context)); |
| 759 | context->state = state; |
| 760 | context->loginuid = loginuid; |
| 761 | } |
| 762 | |
| 763 | static inline struct audit_context *audit_alloc_context(enum audit_state state) |
| 764 | { |
| 765 | struct audit_context *context; |
| 766 | |
| 767 | if (!(context = kmalloc(sizeof(*context), GFP_KERNEL))) |
| 768 | return NULL; |
| 769 | audit_zero_context(context, state); |
| 770 | return context; |
| 771 | } |
| 772 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 773 | /** |
| 774 | * audit_alloc - allocate an audit context block for a task |
| 775 | * @tsk: task |
| 776 | * |
| 777 | * Filter on the task information and allocate a per-task audit context |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | * if necessary. Doing so turns on system call auditing for the |
| 779 | * specified task. This is called from copy_process, so no lock is |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 780 | * needed. |
| 781 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | int audit_alloc(struct task_struct *tsk) |
| 783 | { |
| 784 | struct audit_context *context; |
| 785 | enum audit_state state; |
| 786 | |
| 787 | if (likely(!audit_enabled)) |
| 788 | return 0; /* Return if not auditing. */ |
| 789 | |
| 790 | state = audit_filter_task(tsk); |
| 791 | if (likely(state == AUDIT_DISABLED)) |
| 792 | return 0; |
| 793 | |
| 794 | if (!(context = audit_alloc_context(state))) { |
| 795 | audit_log_lost("out of memory in audit_alloc"); |
| 796 | return -ENOMEM; |
| 797 | } |
| 798 | |
| 799 | /* Preserve login uid */ |
| 800 | context->loginuid = -1; |
| 801 | if (current->audit_context) |
| 802 | context->loginuid = current->audit_context->loginuid; |
| 803 | |
| 804 | tsk->audit_context = context; |
| 805 | set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT); |
| 806 | return 0; |
| 807 | } |
| 808 | |
| 809 | static inline void audit_free_context(struct audit_context *context) |
| 810 | { |
| 811 | struct audit_context *previous; |
| 812 | int count = 0; |
| 813 | |
| 814 | do { |
| 815 | previous = context->previous; |
| 816 | if (previous || (count && count < 10)) { |
| 817 | ++count; |
| 818 | printk(KERN_ERR "audit(:%d): major=%d name_count=%d:" |
| 819 | " freeing multiple contexts (%d)\n", |
| 820 | context->serial, context->major, |
| 821 | context->name_count, count); |
| 822 | } |
| 823 | audit_free_names(context); |
| 824 | audit_free_aux(context); |
| 825 | kfree(context); |
| 826 | context = previous; |
| 827 | } while (context); |
| 828 | if (count >= 10) |
| 829 | printk(KERN_ERR "audit: freed %d contexts\n", count); |
| 830 | } |
| 831 | |
Stephen Smalley | 219f081 | 2005-04-18 10:47:35 -0700 | [diff] [blame] | 832 | static void audit_log_task_info(struct audit_buffer *ab) |
| 833 | { |
| 834 | char name[sizeof(current->comm)]; |
| 835 | struct mm_struct *mm = current->mm; |
| 836 | struct vm_area_struct *vma; |
| 837 | |
| 838 | get_task_comm(name, current); |
David Woodhouse | 99e45ee | 2005-05-23 21:57:41 +0100 | [diff] [blame] | 839 | audit_log_format(ab, " comm="); |
| 840 | audit_log_untrustedstring(ab, name); |
Stephen Smalley | 219f081 | 2005-04-18 10:47:35 -0700 | [diff] [blame] | 841 | |
| 842 | if (!mm) |
| 843 | return; |
| 844 | |
| 845 | down_read(&mm->mmap_sem); |
| 846 | vma = mm->mmap; |
| 847 | while (vma) { |
| 848 | if ((vma->vm_flags & VM_EXECUTABLE) && |
| 849 | vma->vm_file) { |
| 850 | audit_log_d_path(ab, "exe=", |
| 851 | vma->vm_file->f_dentry, |
| 852 | vma->vm_file->f_vfsmnt); |
| 853 | break; |
| 854 | } |
| 855 | vma = vma->vm_next; |
| 856 | } |
| 857 | up_read(&mm->mmap_sem); |
| 858 | } |
| 859 | |
Al Viro | 9796fdd | 2005-10-21 03:22:03 -0400 | [diff] [blame] | 860 | static void audit_log_exit(struct audit_context *context, gfp_t gfp_mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | { |
| 862 | int i; |
| 863 | struct audit_buffer *ab; |
David Woodhouse | 7551ced | 2005-05-26 12:04:57 +0100 | [diff] [blame] | 864 | struct audit_aux_data *aux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | |
David Woodhouse | f556196 | 2005-07-13 22:47:07 +0100 | [diff] [blame] | 866 | ab = audit_log_start(context, gfp_mask, AUDIT_SYSCALL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | if (!ab) |
| 868 | return; /* audit_panic has been called */ |
David Woodhouse | bccf6ae | 2005-05-23 21:35:28 +0100 | [diff] [blame] | 869 | audit_log_format(ab, "arch=%x syscall=%d", |
| 870 | context->arch, context->major); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | if (context->personality != PER_LINUX) |
| 872 | audit_log_format(ab, " per=%lx", context->personality); |
| 873 | if (context->return_valid) |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 874 | audit_log_format(ab, " success=%s exit=%ld", |
| 875 | (context->return_valid==AUDITSC_SUCCESS)?"yes":"no", |
| 876 | context->return_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | audit_log_format(ab, |
| 878 | " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" |
Steve Grubb | 326e9c8 | 2005-05-21 00:22:31 +0100 | [diff] [blame] | 879 | " pid=%d auid=%u uid=%u gid=%u" |
| 880 | " euid=%u suid=%u fsuid=%u" |
| 881 | " egid=%u sgid=%u fsgid=%u", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | context->argv[0], |
| 883 | context->argv[1], |
| 884 | context->argv[2], |
| 885 | context->argv[3], |
| 886 | context->name_count, |
| 887 | context->pid, |
| 888 | context->loginuid, |
| 889 | context->uid, |
| 890 | context->gid, |
| 891 | context->euid, context->suid, context->fsuid, |
| 892 | context->egid, context->sgid, context->fsgid); |
Stephen Smalley | 219f081 | 2005-04-18 10:47:35 -0700 | [diff] [blame] | 893 | audit_log_task_info(ab); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | audit_log_end(ab); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | |
David Woodhouse | 7551ced | 2005-05-26 12:04:57 +0100 | [diff] [blame] | 896 | for (aux = context->aux; aux; aux = aux->next) { |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 897 | |
Al Viro | ef20c8c | 2006-02-18 15:41:50 -0500 | [diff] [blame] | 898 | ab = audit_log_start(context, gfp_mask, aux->type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | if (!ab) |
| 900 | continue; /* audit_panic has been called */ |
| 901 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | switch (aux->type) { |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 903 | case AUDIT_IPC: { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | struct audit_aux_data_ipcctl *axi = (void *)aux; |
| 905 | audit_log_format(ab, |
Steve Grubb | 326e9c8 | 2005-05-21 00:22:31 +0100 | [diff] [blame] | 906 | " qbytes=%lx iuid=%u igid=%u mode=%x", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | axi->qbytes, axi->uid, axi->gid, axi->mode); |
David Woodhouse | 3ec3b2f | 2005-05-17 12:08:48 +0100 | [diff] [blame] | 908 | break; } |
| 909 | |
| 910 | case AUDIT_SOCKETCALL: { |
| 911 | int i; |
| 912 | struct audit_aux_data_socketcall *axs = (void *)aux; |
| 913 | audit_log_format(ab, "nargs=%d", axs->nargs); |
| 914 | for (i=0; i<axs->nargs; i++) |
| 915 | audit_log_format(ab, " a%d=%lx", i, axs->args[i]); |
| 916 | break; } |
| 917 | |
| 918 | case AUDIT_SOCKADDR: { |
| 919 | struct audit_aux_data_sockaddr *axs = (void *)aux; |
| 920 | |
| 921 | audit_log_format(ab, "saddr="); |
| 922 | audit_log_hex(ab, axs->a, axs->len); |
| 923 | break; } |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 924 | |
| 925 | case AUDIT_AVC_PATH: { |
| 926 | struct audit_aux_data_path *axi = (void *)aux; |
| 927 | audit_log_d_path(ab, "path=", axi->dentry, axi->mnt); |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 928 | break; } |
| 929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | } |
| 931 | audit_log_end(ab); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | } |
| 933 | |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 934 | if (context->pwd && context->pwdmnt) { |
Al Viro | ef20c8c | 2006-02-18 15:41:50 -0500 | [diff] [blame] | 935 | ab = audit_log_start(context, gfp_mask, AUDIT_CWD); |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 936 | if (ab) { |
| 937 | audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt); |
| 938 | audit_log_end(ab); |
| 939 | } |
| 940 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | for (i = 0; i < context->name_count; i++) { |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 942 | unsigned long ino = context->names[i].ino; |
| 943 | unsigned long pino = context->names[i].pino; |
| 944 | |
Al Viro | ef20c8c | 2006-02-18 15:41:50 -0500 | [diff] [blame] | 945 | ab = audit_log_start(context, gfp_mask, AUDIT_PATH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | if (!ab) |
| 947 | continue; /* audit_panic has been called */ |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 948 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | audit_log_format(ab, "item=%d", i); |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 950 | |
| 951 | audit_log_format(ab, " name="); |
| 952 | if (context->names[i].name) |
| 83c7d09 | 2005-04-29 15:54:44 +0100 | [diff] [blame] | 953 | audit_log_untrustedstring(ab, context->names[i].name); |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 954 | else |
| 955 | audit_log_format(ab, "(null)"); |
| 956 | |
| 957 | if (pino != (unsigned long)-1) |
| 958 | audit_log_format(ab, " parent=%lu", pino); |
| 959 | if (ino != (unsigned long)-1) |
| 960 | audit_log_format(ab, " inode=%lu", ino); |
| 961 | if ((pino != (unsigned long)-1) || (ino != (unsigned long)-1)) |
| 962 | audit_log_format(ab, " dev=%02x:%02x mode=%#o" |
| 963 | " ouid=%u ogid=%u rdev=%02x:%02x", |
| 964 | MAJOR(context->names[i].dev), |
| 965 | MINOR(context->names[i].dev), |
| 966 | context->names[i].mode, |
| 967 | context->names[i].uid, |
| 968 | context->names[i].gid, |
| 969 | MAJOR(context->names[i].rdev), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | MINOR(context->names[i].rdev)); |
| 971 | audit_log_end(ab); |
| 972 | } |
| 973 | } |
| 974 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 975 | /** |
| 976 | * audit_free - free a per-task audit context |
| 977 | * @tsk: task whose audit context block to free |
| 978 | * |
| 979 | * Called from copy_process and __put_task_struct. |
| 980 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | void audit_free(struct task_struct *tsk) |
| 982 | { |
| 983 | struct audit_context *context; |
| 984 | |
| 985 | task_lock(tsk); |
| 986 | context = audit_get_context(tsk, 0, 0); |
| 987 | task_unlock(tsk); |
| 988 | |
| 989 | if (likely(!context)) |
| 990 | return; |
| 991 | |
| 992 | /* Check for system calls that do not go through the exit |
David Woodhouse | f556196 | 2005-07-13 22:47:07 +0100 | [diff] [blame] | 993 | * function (e.g., exit_group), then free context block. |
| 994 | * We use GFP_ATOMIC here because we might be doing this |
| 995 | * in the context of the idle thread */ |
David Woodhouse | f7056d6 | 2005-06-20 16:07:33 +0100 | [diff] [blame] | 996 | if (context->in_syscall && context->auditable) |
David Woodhouse | f556196 | 2005-07-13 22:47:07 +0100 | [diff] [blame] | 997 | audit_log_exit(context, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
| 999 | audit_free_context(context); |
| 1000 | } |
| 1001 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1002 | /** |
| 1003 | * audit_syscall_entry - fill in an audit record at syscall entry |
| 1004 | * @tsk: task being audited |
| 1005 | * @arch: architecture type |
| 1006 | * @major: major syscall type (function) |
| 1007 | * @a1: additional syscall register 1 |
| 1008 | * @a2: additional syscall register 2 |
| 1009 | * @a3: additional syscall register 3 |
| 1010 | * @a4: additional syscall register 4 |
| 1011 | * |
| 1012 | * Fill in audit context at syscall entry. This only happens if the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | * audit context was created when the task was created and the state or |
| 1014 | * filters demand the audit context be built. If the state from the |
| 1015 | * per-task filter or from the per-syscall filter is AUDIT_RECORD_CONTEXT, |
| 1016 | * then the record will be written at syscall exit time (otherwise, it |
| 1017 | * will only be written if another part of the kernel requests that it |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1018 | * be written). |
| 1019 | */ |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 1020 | void audit_syscall_entry(struct task_struct *tsk, int arch, int major, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | unsigned long a1, unsigned long a2, |
| 1022 | unsigned long a3, unsigned long a4) |
| 1023 | { |
| 1024 | struct audit_context *context = tsk->audit_context; |
| 1025 | enum audit_state state; |
| 1026 | |
| 1027 | BUG_ON(!context); |
| 1028 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1029 | /* |
| 1030 | * This happens only on certain architectures that make system |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | * calls in kernel_thread via the entry.S interface, instead of |
| 1032 | * with direct calls. (If you are porting to a new |
| 1033 | * architecture, hitting this condition can indicate that you |
| 1034 | * got the _exit/_leave calls backward in entry.S.) |
| 1035 | * |
| 1036 | * i386 no |
| 1037 | * x86_64 no |
| 1038 | * ppc64 yes (see arch/ppc64/kernel/misc.S) |
| 1039 | * |
| 1040 | * This also happens with vm86 emulation in a non-nested manner |
| 1041 | * (entries without exits), so this case must be caught. |
| 1042 | */ |
| 1043 | if (context->in_syscall) { |
| 1044 | struct audit_context *newctx; |
| 1045 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | #if AUDIT_DEBUG |
| 1047 | printk(KERN_ERR |
| 1048 | "audit(:%d) pid=%d in syscall=%d;" |
| 1049 | " entering syscall=%d\n", |
| 1050 | context->serial, tsk->pid, context->major, major); |
| 1051 | #endif |
| 1052 | newctx = audit_alloc_context(context->state); |
| 1053 | if (newctx) { |
| 1054 | newctx->previous = context; |
| 1055 | context = newctx; |
| 1056 | tsk->audit_context = newctx; |
| 1057 | } else { |
| 1058 | /* If we can't alloc a new context, the best we |
| 1059 | * can do is to leak memory (any pending putname |
| 1060 | * will be lost). The only other alternative is |
| 1061 | * to abandon auditing. */ |
| 1062 | audit_zero_context(context, context->state); |
| 1063 | } |
| 1064 | } |
| 1065 | BUG_ON(context->in_syscall || context->name_count); |
| 1066 | |
| 1067 | if (!audit_enabled) |
| 1068 | return; |
| 1069 | |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 1070 | context->arch = arch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | context->major = major; |
| 1072 | context->argv[0] = a1; |
| 1073 | context->argv[1] = a2; |
| 1074 | context->argv[2] = a3; |
| 1075 | context->argv[3] = a4; |
| 1076 | |
| 1077 | state = context->state; |
| 1078 | if (state == AUDIT_SETUP_CONTEXT || state == AUDIT_BUILD_CONTEXT) |
David Woodhouse | 0f45aa1 | 2005-06-19 19:35:50 +0100 | [diff] [blame] | 1079 | state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_ENTRY]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | if (likely(state == AUDIT_DISABLED)) |
| 1081 | return; |
| 1082 | |
David Woodhouse | ce625a8 | 2005-07-18 14:24:46 -0400 | [diff] [blame] | 1083 | context->serial = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | context->ctime = CURRENT_TIME; |
| 1085 | context->in_syscall = 1; |
| 1086 | context->auditable = !!(state == AUDIT_RECORD_CONTEXT); |
| 1087 | } |
| 1088 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1089 | /** |
| 1090 | * audit_syscall_exit - deallocate audit context after a system call |
| 1091 | * @tsk: task being audited |
| 1092 | * @valid: success/failure flag |
| 1093 | * @return_code: syscall return value |
| 1094 | * |
| 1095 | * Tear down after system call. If the audit context has been marked as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | * auditable (either because of the AUDIT_RECORD_CONTEXT state from |
| 1097 | * filtering, or because some other part of the kernel write an audit |
| 1098 | * message), then write out the syscall information. In call cases, |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1099 | * free the names stored from getname(). |
| 1100 | */ |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 1101 | void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | { |
| 1103 | struct audit_context *context; |
| 1104 | |
| 1105 | get_task_struct(tsk); |
| 1106 | task_lock(tsk); |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 1107 | context = audit_get_context(tsk, valid, return_code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | task_unlock(tsk); |
| 1109 | |
| 1110 | /* Not having a context here is ok, since the parent may have |
| 1111 | * called __put_task_struct. */ |
| 1112 | if (likely(!context)) |
David Woodhouse | 413a1c7 | 2005-08-17 14:45:55 +0100 | [diff] [blame] | 1113 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
David Woodhouse | f7056d6 | 2005-06-20 16:07:33 +0100 | [diff] [blame] | 1115 | if (context->in_syscall && context->auditable) |
David Woodhouse | f556196 | 2005-07-13 22:47:07 +0100 | [diff] [blame] | 1116 | audit_log_exit(context, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | |
| 1118 | context->in_syscall = 0; |
| 1119 | context->auditable = 0; |
| 2fd6f58 | 2005-04-29 16:08:28 +0100 | [diff] [blame] | 1120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | if (context->previous) { |
| 1122 | struct audit_context *new_context = context->previous; |
| 1123 | context->previous = NULL; |
| 1124 | audit_free_context(context); |
| 1125 | tsk->audit_context = new_context; |
| 1126 | } else { |
| 1127 | audit_free_names(context); |
| 1128 | audit_free_aux(context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | tsk->audit_context = context; |
| 1130 | } |
David Woodhouse | 413a1c7 | 2005-08-17 14:45:55 +0100 | [diff] [blame] | 1131 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | put_task_struct(tsk); |
| 1133 | } |
| 1134 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1135 | /** |
| 1136 | * audit_getname - add a name to the list |
| 1137 | * @name: name to add |
| 1138 | * |
| 1139 | * Add a name to the list of audit names for this context. |
| 1140 | * Called from fs/namei.c:getname(). |
| 1141 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | void audit_getname(const char *name) |
| 1143 | { |
| 1144 | struct audit_context *context = current->audit_context; |
| 1145 | |
| 1146 | if (!context || IS_ERR(name) || !name) |
| 1147 | return; |
| 1148 | |
| 1149 | if (!context->in_syscall) { |
| 1150 | #if AUDIT_DEBUG == 2 |
| 1151 | printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n", |
| 1152 | __FILE__, __LINE__, context->serial, name); |
| 1153 | dump_stack(); |
| 1154 | #endif |
| 1155 | return; |
| 1156 | } |
| 1157 | BUG_ON(context->name_count >= AUDIT_NAMES); |
| 1158 | context->names[context->name_count].name = name; |
| 1159 | context->names[context->name_count].ino = (unsigned long)-1; |
| 1160 | ++context->name_count; |
David Woodhouse | 8f37d47 | 2005-05-27 12:17:28 +0100 | [diff] [blame] | 1161 | if (!context->pwd) { |
| 1162 | read_lock(¤t->fs->lock); |
| 1163 | context->pwd = dget(current->fs->pwd); |
| 1164 | context->pwdmnt = mntget(current->fs->pwdmnt); |
| 1165 | read_unlock(¤t->fs->lock); |
| 1166 | } |
| 1167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | } |
| 1169 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1170 | /* audit_putname - intercept a putname request |
| 1171 | * @name: name to intercept and delay for putname |
| 1172 | * |
| 1173 | * If we have stored the name from getname in the audit context, |
| 1174 | * then we delay the putname until syscall exit. |
| 1175 | * Called from include/linux/fs.h:putname(). |
| 1176 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | void audit_putname(const char *name) |
| 1178 | { |
| 1179 | struct audit_context *context = current->audit_context; |
| 1180 | |
| 1181 | BUG_ON(!context); |
| 1182 | if (!context->in_syscall) { |
| 1183 | #if AUDIT_DEBUG == 2 |
| 1184 | printk(KERN_ERR "%s:%d(:%d): __putname(%p)\n", |
| 1185 | __FILE__, __LINE__, context->serial, name); |
| 1186 | if (context->name_count) { |
| 1187 | int i; |
| 1188 | for (i = 0; i < context->name_count; i++) |
| 1189 | printk(KERN_ERR "name[%d] = %p = %s\n", i, |
| 1190 | context->names[i].name, |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 1191 | context->names[i].name ?: "(null)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | } |
| 1193 | #endif |
| 1194 | __putname(name); |
| 1195 | } |
| 1196 | #if AUDIT_DEBUG |
| 1197 | else { |
| 1198 | ++context->put_count; |
| 1199 | if (context->put_count > context->name_count) { |
| 1200 | printk(KERN_ERR "%s:%d(:%d): major=%d" |
| 1201 | " in_syscall=%d putname(%p) name_count=%d" |
| 1202 | " put_count=%d\n", |
| 1203 | __FILE__, __LINE__, |
| 1204 | context->serial, context->major, |
| 1205 | context->in_syscall, name, context->name_count, |
| 1206 | context->put_count); |
| 1207 | dump_stack(); |
| 1208 | } |
| 1209 | } |
| 1210 | #endif |
| 1211 | } |
| 1212 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1213 | /** |
| 1214 | * audit_inode - store the inode and device from a lookup |
| 1215 | * @name: name being audited |
| 1216 | * @inode: inode being audited |
| 1217 | * @flags: lookup flags (as used in path_lookup()) |
| 1218 | * |
| 1219 | * Called from fs/namei.c:path_lookup(). |
| 1220 | */ |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 1221 | void __audit_inode(const char *name, const struct inode *inode, unsigned flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | { |
| 1223 | int idx; |
| 1224 | struct audit_context *context = current->audit_context; |
| 1225 | |
| 1226 | if (!context->in_syscall) |
| 1227 | return; |
| 1228 | if (context->name_count |
| 1229 | && context->names[context->name_count-1].name |
| 1230 | && context->names[context->name_count-1].name == name) |
| 1231 | idx = context->name_count - 1; |
| 1232 | else if (context->name_count > 1 |
| 1233 | && context->names[context->name_count-2].name |
| 1234 | && context->names[context->name_count-2].name == name) |
| 1235 | idx = context->name_count - 2; |
| 1236 | else { |
| 1237 | /* FIXME: how much do we care about inodes that have no |
| 1238 | * associated name? */ |
| 1239 | if (context->name_count >= AUDIT_NAMES - AUDIT_NAMES_RESERVED) |
| 1240 | return; |
| 1241 | idx = context->name_count++; |
| 1242 | context->names[idx].name = NULL; |
| 1243 | #if AUDIT_DEBUG |
| 1244 | ++context->ino_count; |
| 1245 | #endif |
| 1246 | } |
David Woodhouse | ae7b961 | 2005-06-20 16:11:05 +0100 | [diff] [blame] | 1247 | context->names[idx].dev = inode->i_sb->s_dev; |
| 1248 | context->names[idx].mode = inode->i_mode; |
| 1249 | context->names[idx].uid = inode->i_uid; |
| 1250 | context->names[idx].gid = inode->i_gid; |
| 1251 | context->names[idx].rdev = inode->i_rdev; |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame^] | 1252 | if ((flags & LOOKUP_PARENT) && (strcmp(name, "/") != 0) && |
| 1253 | (strcmp(name, ".") != 0)) { |
| 1254 | context->names[idx].ino = (unsigned long)-1; |
| 1255 | context->names[idx].pino = inode->i_ino; |
| 1256 | } else { |
| 1257 | context->names[idx].ino = inode->i_ino; |
| 1258 | context->names[idx].pino = (unsigned long)-1; |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | /** |
| 1263 | * audit_inode_child - collect inode info for created/removed objects |
| 1264 | * @dname: inode's dentry name |
| 1265 | * @inode: inode being audited |
| 1266 | * @pino: inode number of dentry parent |
| 1267 | * |
| 1268 | * For syscalls that create or remove filesystem objects, audit_inode |
| 1269 | * can only collect information for the filesystem object's parent. |
| 1270 | * This call updates the audit context with the child's information. |
| 1271 | * Syscalls that create a new filesystem object must be hooked after |
| 1272 | * the object is created. Syscalls that remove a filesystem object |
| 1273 | * must be hooked prior, in order to capture the target inode during |
| 1274 | * unsuccessful attempts. |
| 1275 | */ |
| 1276 | void __audit_inode_child(const char *dname, const struct inode *inode, |
| 1277 | unsigned long pino) |
| 1278 | { |
| 1279 | int idx; |
| 1280 | struct audit_context *context = current->audit_context; |
| 1281 | |
| 1282 | if (!context->in_syscall) |
| 1283 | return; |
| 1284 | |
| 1285 | /* determine matching parent */ |
| 1286 | if (dname) |
| 1287 | for (idx = 0; idx < context->name_count; idx++) |
| 1288 | if (context->names[idx].pino == pino) { |
| 1289 | const char *n; |
| 1290 | const char *name = context->names[idx].name; |
| 1291 | int dlen = strlen(dname); |
| 1292 | int nlen = name ? strlen(name) : 0; |
| 1293 | |
| 1294 | if (nlen < dlen) |
| 1295 | continue; |
| 1296 | |
| 1297 | /* disregard trailing slashes */ |
| 1298 | n = name + nlen - 1; |
| 1299 | while ((*n == '/') && (n > name)) |
| 1300 | n--; |
| 1301 | |
| 1302 | /* find last path component */ |
| 1303 | n = n - dlen + 1; |
| 1304 | if (n < name) |
| 1305 | continue; |
| 1306 | else if (n > name) { |
| 1307 | if (*--n != '/') |
| 1308 | continue; |
| 1309 | else |
| 1310 | n++; |
| 1311 | } |
| 1312 | |
| 1313 | if (strncmp(n, dname, dlen) == 0) |
| 1314 | goto update_context; |
| 1315 | } |
| 1316 | |
| 1317 | /* catch-all in case match not found */ |
| 1318 | idx = context->name_count++; |
| 1319 | context->names[idx].name = NULL; |
| 1320 | context->names[idx].pino = pino; |
| 1321 | #if AUDIT_DEBUG |
| 1322 | context->ino_count++; |
| 1323 | #endif |
| 1324 | |
| 1325 | update_context: |
| 1326 | if (inode) { |
| 1327 | context->names[idx].ino = inode->i_ino; |
| 1328 | context->names[idx].dev = inode->i_sb->s_dev; |
| 1329 | context->names[idx].mode = inode->i_mode; |
| 1330 | context->names[idx].uid = inode->i_uid; |
| 1331 | context->names[idx].gid = inode->i_gid; |
| 1332 | context->names[idx].rdev = inode->i_rdev; |
| 1333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | } |
| 1335 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1336 | /** |
| 1337 | * auditsc_get_stamp - get local copies of audit_context values |
| 1338 | * @ctx: audit_context for the task |
| 1339 | * @t: timespec to store time recorded in the audit_context |
| 1340 | * @serial: serial value that is recorded in the audit_context |
| 1341 | * |
| 1342 | * Also sets the context as auditable. |
| 1343 | */ |
David Woodhouse | bfb4496 | 2005-05-21 21:08:09 +0100 | [diff] [blame] | 1344 | void auditsc_get_stamp(struct audit_context *ctx, |
| 1345 | struct timespec *t, unsigned int *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | { |
David Woodhouse | ce625a8 | 2005-07-18 14:24:46 -0400 | [diff] [blame] | 1347 | if (!ctx->serial) |
| 1348 | ctx->serial = audit_serial(); |
David Woodhouse | bfb4496 | 2005-05-21 21:08:09 +0100 | [diff] [blame] | 1349 | t->tv_sec = ctx->ctime.tv_sec; |
| 1350 | t->tv_nsec = ctx->ctime.tv_nsec; |
| 1351 | *serial = ctx->serial; |
| 1352 | ctx->auditable = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | } |
| 1354 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1355 | /** |
| 1356 | * audit_set_loginuid - set a task's audit_context loginuid |
| 1357 | * @task: task whose audit context is being modified |
| 1358 | * @loginuid: loginuid value |
| 1359 | * |
| 1360 | * Returns 0. |
| 1361 | * |
| 1362 | * Called (set) from fs/proc/base.c::proc_loginuid_write(). |
| 1363 | */ |
Steve Grubb | 456be6c | 2005-04-29 17:30:07 +0100 | [diff] [blame] | 1364 | int audit_set_loginuid(struct task_struct *task, uid_t loginuid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | { |
Steve Grubb | 456be6c | 2005-04-29 17:30:07 +0100 | [diff] [blame] | 1366 | if (task->audit_context) { |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 1367 | struct audit_buffer *ab; |
| 1368 | |
David Woodhouse | 9ad9ad3 | 2005-06-22 15:04:33 +0100 | [diff] [blame] | 1369 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 1370 | if (ab) { |
| 1371 | audit_log_format(ab, "login pid=%d uid=%u " |
Steve Grubb | 326e9c8 | 2005-05-21 00:22:31 +0100 | [diff] [blame] | 1372 | "old auid=%u new auid=%u", |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 1373 | task->pid, task->uid, |
| 1374 | task->audit_context->loginuid, loginuid); |
| 1375 | audit_log_end(ab); |
| 1376 | } |
Steve Grubb | 456be6c | 2005-04-29 17:30:07 +0100 | [diff] [blame] | 1377 | task->audit_context->loginuid = loginuid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | } |
| 1379 | return 0; |
| 1380 | } |
| 1381 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1382 | /** |
| 1383 | * audit_get_loginuid - get the loginuid for an audit_context |
| 1384 | * @ctx: the audit_context |
| 1385 | * |
| 1386 | * Returns the context's loginuid or -1 if @ctx is NULL. |
| 1387 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | uid_t audit_get_loginuid(struct audit_context *ctx) |
| 1389 | { |
| 1390 | return ctx ? ctx->loginuid : -1; |
| 1391 | } |
| 1392 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1393 | /** |
| 1394 | * audit_ipc_perms - record audit data for ipc |
| 1395 | * @qbytes: msgq bytes |
| 1396 | * @uid: msgq user id |
| 1397 | * @gid: msgq group id |
| 1398 | * @mode: msgq mode (permissions) |
| 1399 | * |
| 1400 | * Returns 0 for success or NULL context or < 0 on error. |
| 1401 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) |
| 1403 | { |
| 1404 | struct audit_aux_data_ipcctl *ax; |
| 1405 | struct audit_context *context = current->audit_context; |
| 1406 | |
| 1407 | if (likely(!context)) |
| 1408 | return 0; |
| 1409 | |
| 1410 | ax = kmalloc(sizeof(*ax), GFP_KERNEL); |
| 1411 | if (!ax) |
| 1412 | return -ENOMEM; |
| 1413 | |
| 1414 | ax->qbytes = qbytes; |
| 1415 | ax->uid = uid; |
| 1416 | ax->gid = gid; |
| 1417 | ax->mode = mode; |
| 1418 | |
Steve Grubb | c040499 | 2005-05-13 18:17:42 +0100 | [diff] [blame] | 1419 | ax->d.type = AUDIT_IPC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | ax->d.next = context->aux; |
| 1421 | context->aux = (void *)ax; |
| 1422 | return 0; |
| 1423 | } |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 1424 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1425 | /** |
| 1426 | * audit_socketcall - record audit data for sys_socketcall |
| 1427 | * @nargs: number of args |
| 1428 | * @args: args array |
| 1429 | * |
| 1430 | * Returns 0 for success or NULL context or < 0 on error. |
| 1431 | */ |
David Woodhouse | 3ec3b2f | 2005-05-17 12:08:48 +0100 | [diff] [blame] | 1432 | int audit_socketcall(int nargs, unsigned long *args) |
| 1433 | { |
| 1434 | struct audit_aux_data_socketcall *ax; |
| 1435 | struct audit_context *context = current->audit_context; |
| 1436 | |
| 1437 | if (likely(!context)) |
| 1438 | return 0; |
| 1439 | |
| 1440 | ax = kmalloc(sizeof(*ax) + nargs * sizeof(unsigned long), GFP_KERNEL); |
| 1441 | if (!ax) |
| 1442 | return -ENOMEM; |
| 1443 | |
| 1444 | ax->nargs = nargs; |
| 1445 | memcpy(ax->args, args, nargs * sizeof(unsigned long)); |
| 1446 | |
| 1447 | ax->d.type = AUDIT_SOCKETCALL; |
| 1448 | ax->d.next = context->aux; |
| 1449 | context->aux = (void *)ax; |
| 1450 | return 0; |
| 1451 | } |
| 1452 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1453 | /** |
| 1454 | * audit_sockaddr - record audit data for sys_bind, sys_connect, sys_sendto |
| 1455 | * @len: data length in user space |
| 1456 | * @a: data address in kernel space |
| 1457 | * |
| 1458 | * Returns 0 for success or NULL context or < 0 on error. |
| 1459 | */ |
David Woodhouse | 3ec3b2f | 2005-05-17 12:08:48 +0100 | [diff] [blame] | 1460 | int audit_sockaddr(int len, void *a) |
| 1461 | { |
| 1462 | struct audit_aux_data_sockaddr *ax; |
| 1463 | struct audit_context *context = current->audit_context; |
| 1464 | |
| 1465 | if (likely(!context)) |
| 1466 | return 0; |
| 1467 | |
| 1468 | ax = kmalloc(sizeof(*ax) + len, GFP_KERNEL); |
| 1469 | if (!ax) |
| 1470 | return -ENOMEM; |
| 1471 | |
| 1472 | ax->len = len; |
| 1473 | memcpy(ax->a, a, len); |
| 1474 | |
| 1475 | ax->d.type = AUDIT_SOCKADDR; |
| 1476 | ax->d.next = context->aux; |
| 1477 | context->aux = (void *)ax; |
| 1478 | return 0; |
| 1479 | } |
| 1480 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1481 | /** |
| 1482 | * audit_avc_path - record the granting or denial of permissions |
| 1483 | * @dentry: dentry to record |
| 1484 | * @mnt: mnt to record |
| 1485 | * |
| 1486 | * Returns 0 for success or NULL context or < 0 on error. |
| 1487 | * |
| 1488 | * Called from security/selinux/avc.c::avc_audit() |
| 1489 | */ |
Stephen Smalley | 0111610 | 2005-05-21 00:15:52 +0100 | [diff] [blame] | 1490 | int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt) |
| 1491 | { |
| 1492 | struct audit_aux_data_path *ax; |
| 1493 | struct audit_context *context = current->audit_context; |
| 1494 | |
| 1495 | if (likely(!context)) |
| 1496 | return 0; |
| 1497 | |
| 1498 | ax = kmalloc(sizeof(*ax), GFP_ATOMIC); |
| 1499 | if (!ax) |
| 1500 | return -ENOMEM; |
| 1501 | |
| 1502 | ax->dentry = dget(dentry); |
| 1503 | ax->mnt = mntget(mnt); |
| 1504 | |
| 1505 | ax->d.type = AUDIT_AVC_PATH; |
| 1506 | ax->d.next = context->aux; |
| 1507 | context->aux = (void *)ax; |
| 1508 | return 0; |
| 1509 | } |
| 1510 | |
Randy Dunlap | b0dd25a | 2005-09-13 12:47:11 -0700 | [diff] [blame] | 1511 | /** |
| 1512 | * audit_signal_info - record signal info for shutting down audit subsystem |
| 1513 | * @sig: signal value |
| 1514 | * @t: task being signaled |
| 1515 | * |
| 1516 | * If the audit subsystem is being terminated, record the task (pid) |
| 1517 | * and uid that is doing that. |
| 1518 | */ |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 1519 | void audit_signal_info(int sig, struct task_struct *t) |
| 1520 | { |
| 1521 | extern pid_t audit_sig_pid; |
| 1522 | extern uid_t audit_sig_uid; |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 1523 | |
David Woodhouse | 582edda | 2005-07-13 22:39:34 +0100 | [diff] [blame] | 1524 | if (unlikely(audit_pid && t->tgid == audit_pid)) { |
Steve Grubb | c2f0c7c | 2005-05-06 12:38:39 +0100 | [diff] [blame] | 1525 | if (sig == SIGTERM || sig == SIGHUP) { |
| 1526 | struct audit_context *ctx = current->audit_context; |
| 1527 | audit_sig_pid = current->pid; |
| 1528 | if (ctx) |
| 1529 | audit_sig_uid = ctx->loginuid; |
| 1530 | else |
| 1531 | audit_sig_uid = current->uid; |
| 1532 | } |
| 1533 | } |
| 1534 | } |