| @@ -160,6 +160,7 @@ static const struct audit_nfcfgop_tab audit_nfcfgs[] = { · 159 unmodified lines |
| 160 | 160 | static int audit_match_perm(struct audit_context *ctx, int mask) |
| 161 | 161 | { |
| 162 | 162 | unsigned n; |
| 163 | + |
| 163 | 164 | if (unlikely(!ctx)) |
| 164 | 165 | return 0; |
| 165 | 166 | n = ctx->major; |
| @@ -231,7 +232,7 @@ static void audit_set_auditable(struct audit_context *ctx) · 65 unmodified lines |
| 231 | 232 | { |
| 232 | 233 | if (!ctx->prio) { |
| 233 | 234 | ctx->prio = 1; |
| 234 | | − ctx->current_state = AUDIT_RECORD_CONTEXT; |
| 235 | + ctx->current_state = AUDIT_STATE_RECORD; |
| 235 | 236 | } |
| 236 | 237 | } |
| 237 | 238 | |
| @@ -239,6 +240,7 @@ static int put_tree_ref(struct audit_context *ctx, struct audit_chunk *chunk) · 1 unmodified line |
| 239 | 240 | { |
| 240 | 241 | struct audit_tree_refs *p = ctx->trees; |
| 241 | 242 | int left = ctx->tree_count; |
| 243 | + |
| 242 | 244 | if (likely(left)) { |
| 243 | 245 | p->c[--left] = chunk; |
| 244 | 246 | ctx->tree_count = left; |
| @@ -259,6 +261,7 @@ static int put_tree_ref(struct audit_context *ctx, struct audit_chunk *chunk) · 14 unmodified lines |
| 259 | 261 | static int grow_tree_refs(struct audit_context *ctx) |
| 260 | 262 | { |
| 261 | 263 | struct audit_tree_refs *p = ctx->trees; |
| 264 | + |
| 262 | 265 | ctx->trees = kzalloc(sizeof(struct audit_tree_refs), GFP_KERNEL); |
| 263 | 266 | if (!ctx->trees) { |
| 264 | 267 | ctx->trees = p; |
| @@ -277,6 +280,7 @@ static void unroll_tree_refs(struct audit_context *ctx, · 12 unmodified lines |
| 277 | 280 | { |
| 278 | 281 | struct audit_tree_refs *q; |
| 279 | 282 | int n; |
| 283 | + |
| 280 | 284 | if (!p) { |
| 281 | 285 | /* we started with empty chain */ |
| 282 | 286 | p = ctx->first_trees; |
| @@ -303,6 +307,7 @@ static void unroll_tree_refs(struct audit_context *ctx, · 20 unmodified lines |
| 303 | 307 | static void free_tree_refs(struct audit_context *ctx) |
| 304 | 308 | { |
| 305 | 309 | struct audit_tree_refs *p, *q; |
| 310 | + |
| 306 | 311 | for (p = ctx->first_trees; p; p = q) { |
| 307 | 312 | q = p->next; |
| 308 | 313 | kfree(p); |
| @@ -313,6 +318,7 @@ static int match_tree_refs(struct audit_context *ctx, struct audit_tree *tree) · 4 unmodified lines |
| 313 | 318 | { |
| 314 | 319 | struct audit_tree_refs *p; |
| 315 | 320 | int n; |
| 321 | + |
| 316 | 322 | if (!tree) |
| 317 | 323 | return 0; |
| 318 | 324 | /* full ones */ |
| @@ -337,13 +343,13 @@ static int audit_compare_uid(kuid_t uid, · 18 unmodified lines |
| 337 | 343 | { |
| 338 | 344 | struct audit_names *n; |
| 339 | 345 | int rc; |
| 340 | | − |
| 346 | + |
| 341 | 347 | if (name) { |
| 342 | 348 | rc = audit_uid_comparator(uid, f->op, name->uid); |
| 343 | 349 | if (rc) |
| 344 | 350 | return rc; |
| 345 | 351 | } |
| 346 | | − |
| 352 | + |
| 347 | 353 | if (ctx) { |
| 348 | 354 | list_for_each_entry(n, &ctx->names_list, list) { |
| 349 | 355 | rc = audit_uid_comparator(uid, f->op, n->uid); |
| @@ -361,13 +367,13 @@ static int audit_compare_gid(kgid_t gid, · 11 unmodified lines |
| 361 | 367 | { |
| 362 | 368 | struct audit_names *n; |
| 363 | 369 | int rc; |
| 364 | | − |
| 370 | + |
| 365 | 371 | if (name) { |
| 366 | 372 | rc = audit_gid_comparator(gid, f->op, name->gid); |
| 367 | 373 | if (rc) |
| 368 | 374 | return rc; |
| 369 | 375 | } |
| 370 | | − |
| 376 | + |
| 371 | 377 | if (ctx) { |
| 372 | 378 | list_for_each_entry(n, &ctx->names_list, list) { |
| 373 | 379 | rc = audit_gid_comparator(gid, f->op, n->gid); |
| @@ -751,10 +757,10 @@ static int audit_filter_rules(struct task_struct *tsk, · 377 unmodified lines |
| 751 | 757 | } |
| 752 | 758 | switch (rule->action) { |
| 753 | 759 | case AUDIT_NEVER: |
| 754 | | − *state = AUDIT_DISABLED; |
| 760 | + *state = AUDIT_STATE_DISABLED; |
| 755 | 761 | break; |
| 756 | 762 | case AUDIT_ALWAYS: |
| 757 | | − *state = AUDIT_RECORD_CONTEXT; |
| 763 | + *state = AUDIT_STATE_RECORD; |
| 758 | 764 | break; |
| 759 | 765 | } |
| 760 | 766 | return 1; |
| @@ -773,14 +779,14 @@ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key) · 12 unmodified lines |
| 773 | 779 | list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) { |
| 774 | 780 | if (audit_filter_rules(tsk, &e->rule, NULL, NULL, |
| 775 | 781 | &state, true)) { |
| 776 | | − if (state == AUDIT_RECORD_CONTEXT) |
| 782 | + if (state == AUDIT_STATE_RECORD) |
| 777 | 783 | *key = kstrdup(e->rule.filterkey, GFP_ATOMIC); |
| 778 | 784 | rcu_read_unlock(); |
| 779 | 785 | return state; |
| 780 | 786 | } |
| 781 | 787 | } |
| 782 | 788 | rcu_read_unlock(); |
| 783 | | − return AUDIT_BUILD_CONTEXT; |
| 789 | + return AUDIT_STATE_BUILD; |
| 784 | 790 | } |
| 785 | 791 | |
| 786 | 792 | static int audit_in_mask(const struct audit_krule *rule, unsigned long val) |
| @@ -802,7 +808,7 @@ static int audit_in_mask(const struct audit_krule *rule, unsigned long val) · 15 unmodified lines |
| 802 | 808 | /* At syscall exit time, this filter is called if the audit_state is |
| 803 | 809 | * not low enough that auditing cannot take place, but is also not |
| 804 | 810 | * high enough that we already know we have to write an audit record |
| 805 | | − * (i.e., the state is AUDIT_SETUP_CONTEXT or AUDIT_BUILD_CONTEXT). |
| 811 | + * (i.e., the state is AUDIT_STATE_BUILD). |
| 806 | 812 | */ |
| 807 | 813 | static void audit_filter_syscall(struct task_struct *tsk, |
| 808 | 814 | struct audit_context *ctx) |
| @@ -923,7 +929,7 @@ static inline struct audit_context *audit_alloc_context(enum audit_state state) · 114 unmodified lines |
| 923 | 929 | if (!context) |
| 924 | 930 | return NULL; |
| 925 | 931 | context->state = state; |
| 926 | | − context->prio = state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0; |
| 932 | + context->prio = state == AUDIT_STATE_RECORD ? ~0ULL : 0; |
| 927 | 933 | INIT_LIST_HEAD(&context->killed_trees); |
| 928 | 934 | INIT_LIST_HEAD(&context->names_list); |
| 929 | 935 | context->fds[0] = -1; |
| @@ -950,7 +956,7 @@ int audit_alloc(struct task_struct *tsk) · 20 unmodified lines |
| 950 | 956 | return 0; /* Return if not auditing. */ |
| 951 | 957 | |
| 952 | 958 | state = audit_filter_task(tsk, &key); |
| 953 | | − if (state == AUDIT_DISABLED) { |
| 959 | + if (state == AUDIT_STATE_DISABLED) { |
| 954 | 960 | clear_task_syscall_work(tsk, SYSCALL_AUDIT); |
| 955 | 961 | return 0; |
| 956 | 962 | } |
| @@ -1225,6 +1231,7 @@ static void show_special(struct audit_context *context, int *call_panic) · 268 unmodified lines |
| 1225 | 1231 | switch (context->type) { |
| 1226 | 1232 | case AUDIT_SOCKETCALL: { |
| 1227 | 1233 | int nargs = context->socketcall.nargs; |
| 1234 | + |
| 1228 | 1235 | audit_log_format(ab, "nargs=%d", nargs); |
| 1229 | 1236 | for (i = 0; i < nargs; i++) |
| 1230 | 1237 | audit_log_format(ab, " a%d=%lx", i, |
| @@ -1240,6 +1247,7 @@ static void show_special(struct audit_context *context, int *call_panic) · 9 unmodified lines |
| 1240 | 1247 | if (osid) { |
| 1241 | 1248 | char *ctx = NULL; |
| 1242 | 1249 | u32 len; |
| 1250 | + |
| 1243 | 1251 | if (security_secid_to_secctx(osid, &ctx, &len)) { |
| 1244 | 1252 | audit_log_format(ab, " osid=%u", osid); |
| 1245 | 1253 | *call_panic = 1; |
| @@ -1289,6 +1297,7 @@ static void show_special(struct audit_context *context, int *call_panic) · 43 unmodified lines |
| 1289 | 1297 | break; |
| 1290 | 1298 | case AUDIT_MQ_GETSETATTR: { |
| 1291 | 1299 | struct mq_attr *attr = &context->mq_getsetattr.mqstat; |
| 1300 | + |
| 1292 | 1301 | audit_log_format(ab, |
| 1293 | 1302 | "mqdes=%d mq_flags=0x%lx mq_maxmsg=%ld mq_msgsize=%ld " |
| 1294 | 1303 | "mq_curmsgs=%ld ", |
| @@ -1325,6 +1334,7 @@ static void show_special(struct audit_context *context, int *call_panic) · 30 unmodified lines |
| 1325 | 1334 | static inline int audit_proctitle_rtrim(char *proctitle, int len) |
| 1326 | 1335 | { |
| 1327 | 1336 | char *end = proctitle + len - 1; |
| 1337 | + |
| 1328 | 1338 | while (end > proctitle && !isprint(*end)) |
| 1329 | 1339 | end--; |
| 1330 | 1340 | |
| @@ -1513,6 +1523,7 @@ static void audit_log_exit(void) · 182 unmodified lines |
| 1513 | 1523 | |
| 1514 | 1524 | case AUDIT_BPRM_FCAPS: { |
| 1515 | 1525 | struct audit_aux_data_bprm_fcaps *axs = (void *)aux; |
| 1526 | + |
| 1516 | 1527 | audit_log_format(ab, "fver=%x", axs->fcap_ver); |
| 1517 | 1528 | audit_log_cap(ab, "fp", &axs->fcap.permitted); |
| 1518 | 1529 | audit_log_cap(ab, "fi", &axs->fcap.inheritable); |
| @@ -1628,7 +1639,7 @@ void __audit_free(struct task_struct *tsk) · 109 unmodified lines |
| 1628 | 1639 | |
| 1629 | 1640 | audit_filter_syscall(tsk, context); |
| 1630 | 1641 | audit_filter_inodes(tsk, context); |
| 1631 | | − if (context->current_state == AUDIT_RECORD_CONTEXT) |
| 1642 | + if (context->current_state == AUDIT_STATE_RECORD) |
| 1632 | 1643 | audit_log_exit(); |
| 1633 | 1644 | } |
| 1634 | 1645 | |
| @@ -1647,7 +1658,7 @@ void __audit_free(struct task_struct *tsk) · 12 unmodified lines |
| 1647 | 1658 | * Fill in audit context at syscall entry. This only happens if the |
| 1648 | 1659 | * audit context was created when the task was created and the state or |
| 1649 | 1660 | * filters demand the audit context be built. If the state from the |
| 1650 | | − * per-task filter or from the per-syscall filter is AUDIT_RECORD_CONTEXT, |
| 1661 | + * per-task filter or from the per-syscall filter is AUDIT_STATE_RECORD, |
| 1651 | 1662 | * then the record will be written at syscall exit time (otherwise, it |
| 1652 | 1663 | * will only be written if another part of the kernel requests that it |
| 1653 | 1664 | * be written). |
| @@ -1664,11 +1675,11 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2, · 10 unmodified lines |
| 1664 | 1675 | BUG_ON(context->in_syscall || context->name_count); |
| 1665 | 1676 | |
| 1666 | 1677 | state = context->state; |
| 1667 | | − if (state == AUDIT_DISABLED) |
| 1678 | + if (state == AUDIT_STATE_DISABLED) |
| 1668 | 1679 | return; |
| 1669 | 1680 | |
| 1670 | 1681 | context->dummy = !audit_n_rules; |
| 1671 | | − if (!context->dummy && state == AUDIT_BUILD_CONTEXT) { |
| 1682 | + if (!context->dummy && state == AUDIT_STATE_BUILD) { |
| 1672 | 1683 | context->prio = 0; |
| 1673 | 1684 | if (auditd_test_task(current)) |
| 1674 | 1685 | return; |
| @@ -1693,7 +1704,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2, · 18 unmodified lines |
| 1693 | 1704 | * @return_code: return value of the syscall |
| 1694 | 1705 | * |
| 1695 | 1706 | * Tear down after system call. If the audit context has been marked as |
| 1696 | | − * auditable (either because of the AUDIT_RECORD_CONTEXT state from |
| 1707 | + * auditable (either because of the AUDIT_STATE_RECORD state from |
| 1697 | 1708 | * filtering, or because some other part of the kernel wrote an audit |
| 1698 | 1709 | * message), then write out the syscall information. In call cases, |
| 1699 | 1710 | * free the names stored from getname(). |
| @@ -1735,12 +1746,12 @@ void __audit_syscall_exit(int success, long return_code) · 35 unmodified lines |
| 1735 | 1746 | |
| 1736 | 1747 | audit_filter_syscall(current, context); |
| 1737 | 1748 | audit_filter_inodes(current, context); |
| 1738 | | − if (context->current_state == AUDIT_RECORD_CONTEXT) |
| 1749 | + if (context->current_state == AUDIT_STATE_RECORD) |
| 1739 | 1750 | audit_log_exit(); |
| 1740 | 1751 | } |
| 1741 | 1752 | |
| 1742 | 1753 | context->in_syscall = 0; |
| 1743 | | − context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0; |
| 1754 | + context->prio = context->state == AUDIT_STATE_RECORD ? ~0ULL : 0; |
| 1744 | 1755 | |
| 1745 | 1756 | audit_free_module(context); |
| 1746 | 1757 | audit_free_names(context); |
| @@ -1753,7 +1764,7 @@ void __audit_syscall_exit(int success, long return_code) · 6 unmodified lines |
| 1753 | 1764 | context->sockaddr_len = 0; |
| 1754 | 1765 | context->type = 0; |
| 1755 | 1766 | context->fds[0] = -1; |
| 1756 | | − if (context->state != AUDIT_RECORD_CONTEXT) { |
| 1767 | + if (context->state != AUDIT_STATE_RECORD) { |
| 1757 | 1768 | kfree(context->filterkey); |
| 1758 | 1769 | context->filterkey = NULL; |
| 1759 | 1770 | } |
| @@ -1765,6 +1776,7 @@ static inline void handle_one(const struct inode *inode) · 5 unmodified lines |
| 1765 | 1776 | struct audit_tree_refs *p; |
| 1766 | 1777 | struct audit_chunk *chunk; |
| 1767 | 1778 | int count; |
| 1779 | + |
| 1768 | 1780 | if (likely(!inode->i_fsnotify_marks)) |
| 1769 | 1781 | return; |
| 1770 | 1782 | context = audit_context(); |
| @@ -1806,8 +1818,10 @@ retry: · 35 unmodified lines |
| 1806 | 1818 | seq = read_seqbegin(&rename_lock); |
| 1807 | 1819 | for(;;) { |
| 1808 | 1820 | struct inode *inode = d_backing_inode(d); |
| 1821 | + |
| 1809 | 1822 | if (inode && unlikely(inode->i_fsnotify_marks)) { |
| 1810 | 1823 | struct audit_chunk *chunk; |
| 1824 | + |
| 1811 | 1825 | chunk = audit_tree_lookup(inode); |
| 1812 | 1826 | if (chunk) { |
| 1813 | 1827 | if (unlikely(!put_tree_ref(context, chunk))) { |
| @@ -2203,7 +2217,7 @@ int auditsc_get_stamp(struct audit_context *ctx, · 389 unmodified lines |
| 2203 | 2217 | *serial = ctx->serial; |
| 2204 | 2218 | if (!ctx->prio) { |
| 2205 | 2219 | ctx->prio = 1; |
| 2206 | | − ctx->current_state = AUDIT_RECORD_CONTEXT; |
| 2220 | + ctx->current_state = AUDIT_STATE_RECORD; |
| 2207 | 2221 | } |
| 2208 | 2222 | return 1; |
| 2209 | 2223 | } |
| @@ -2285,6 +2299,7 @@ void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification) · 75 unmodified lines |
| 2285 | 2299 | void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
| 2286 | 2300 | { |
| 2287 | 2301 | struct audit_context *context = audit_context(); |
| 2302 | + |
| 2288 | 2303 | context->mq_getsetattr.mqdes = mqdes; |
| 2289 | 2304 | context->mq_getsetattr.mqstat = *mqstat; |
| 2290 | 2305 | context->type = AUDIT_MQ_GETSETATTR; |
| @@ -2298,6 +2313,7 @@ void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) · 7 unmodified lines |
| 2298 | 2313 | void __audit_ipc_obj(struct kern_ipc_perm *ipcp) |
| 2299 | 2314 | { |
| 2300 | 2315 | struct audit_context *context = audit_context(); |
| 2316 | + |
| 2301 | 2317 | context->ipc.uid = ipcp->uid; |
| 2302 | 2318 | context->ipc.gid = ipcp->gid; |
| 2303 | 2319 | context->ipc.mode = ipcp->mode; |
| @@ -2362,6 +2378,7 @@ int __audit_socketcall(int nargs, unsigned long *args) · 58 unmodified lines |
| 2362 | 2378 | void __audit_fd_pair(int fd1, int fd2) |
| 2363 | 2379 | { |
| 2364 | 2380 | struct audit_context *context = audit_context(); |
| 2381 | + |
| 2365 | 2382 | context->fds[0] = fd1; |
| 2366 | 2383 | context->fds[1] = fd2; |
| 2367 | 2384 | } |
| @@ -2379,6 +2396,7 @@ int __audit_sockaddr(int len, void *a) · 11 unmodified lines |
| 2379 | 2396 | |
| 2380 | 2397 | if (!context->sockaddr) { |
| 2381 | 2398 | void *p = kmalloc(sizeof(struct sockaddr_storage), GFP_KERNEL); |
| 2399 | + |
| 2382 | 2400 | if (!p) |
| 2383 | 2401 | return -ENOMEM; |
| 2384 | 2402 | context->sockaddr = p; |
| @@ -2510,6 +2528,7 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm, · 125 unmodified lines |
| 2510 | 2528 | void __audit_log_capset(const struct cred *new, const struct cred *old) |
| 2511 | 2529 | { |
| 2512 | 2530 | struct audit_context *context = audit_context(); |
| 2531 | + |
| 2513 | 2532 | context->capset.pid = task_tgid_nr(current); |
| 2514 | 2533 | context->capset.cap.effective = new->cap_effective; |
| 2515 | 2534 | context->capset.cap.inheritable = new->cap_effective; |
| @@ -2521,6 +2540,7 @@ void __audit_log_capset(const struct cred *new, const struct cred *old) · 5 unmodified lines |
| 2521 | 2540 | void __audit_mmap_fd(int fd, int flags) |
| 2522 | 2541 | { |
| 2523 | 2542 | struct audit_context *context = audit_context(); |
| 2543 | + |
| 2524 | 2544 | context->mmap.fd = fd; |
| 2525 | 2545 | context->mmap.flags = flags; |
| 2526 | 2546 | context->type = AUDIT_MMAP; |
| @@ -2686,6 +2706,7 @@ void audit_seccomp_actions_logged(const char *names, const char *old_names, · 159 unmodified lines |
| 2686 | 2706 | struct list_head *audit_killed_trees(void) |
| 2687 | 2707 | { |
| 2688 | 2708 | struct audit_context *ctx = audit_context(); |
| 2709 | + |
| 2689 | 2710 | if (likely(!ctx || !ctx->in_syscall)) |
| 2690 | 2711 | return NULL; |
| 2691 | 2712 | return &ctx->killed_trees; |