diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/audit.c | 93 | ||||
| -rw-r--r-- | kernel/auditsc.c | 47 |
2 files changed, 91 insertions, 49 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index ac26d4d960d3..9c4f1af0c794 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* audit.c -- Auditing support -*- linux-c -*- | 1 | /* audit.c -- Auditing support |
| 2 | * Gateway between the kernel (e.g., selinux) and the user-space audit daemon. | 2 | * Gateway between the kernel (e.g., selinux) and the user-space audit daemon. |
| 3 | * System-call specific features have moved to auditsc.c | 3 | * System-call specific features have moved to auditsc.c |
| 4 | * | 4 | * |
| @@ -38,7 +38,7 @@ | |||
| 38 | * 6) Support low-overhead kernel-based filtering to minimize the | 38 | * 6) Support low-overhead kernel-based filtering to minimize the |
| 39 | * information that must be passed to user-space. | 39 | * information that must be passed to user-space. |
| 40 | * | 40 | * |
| 41 | * Example user-space utilities: http://people.redhat.com/faith/audit/ | 41 | * Example user-space utilities: http://people.redhat.com/sgrubb/audit/ |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
| @@ -142,7 +142,6 @@ struct audit_buffer { | |||
| 142 | int total; | 142 | int total; |
| 143 | int type; | 143 | int type; |
| 144 | int pid; | 144 | int pid; |
| 145 | int count; /* Times requeued */ | ||
| 146 | }; | 145 | }; |
| 147 | 146 | ||
| 148 | void audit_set_type(struct audit_buffer *ab, int type) | 147 | void audit_set_type(struct audit_buffer *ab, int type) |
| @@ -239,36 +238,36 @@ void audit_log_lost(const char *message) | |||
| 239 | 238 | ||
| 240 | } | 239 | } |
| 241 | 240 | ||
| 242 | static int audit_set_rate_limit(int limit) | 241 | static int audit_set_rate_limit(int limit, uid_t loginuid) |
| 243 | { | 242 | { |
| 244 | int old = audit_rate_limit; | 243 | int old = audit_rate_limit; |
| 245 | audit_rate_limit = limit; | 244 | audit_rate_limit = limit; |
| 246 | audit_log(current->audit_context, "audit_rate_limit=%d old=%d", | 245 | audit_log(NULL, "audit_rate_limit=%d old=%d by auid %u", |
| 247 | audit_rate_limit, old); | 246 | audit_rate_limit, old, loginuid); |
| 248 | return old; | 247 | return old; |
| 249 | } | 248 | } |
| 250 | 249 | ||
| 251 | static int audit_set_backlog_limit(int limit) | 250 | static int audit_set_backlog_limit(int limit, uid_t loginuid) |
| 252 | { | 251 | { |
| 253 | int old = audit_backlog_limit; | 252 | int old = audit_backlog_limit; |
| 254 | audit_backlog_limit = limit; | 253 | audit_backlog_limit = limit; |
| 255 | audit_log(current->audit_context, "audit_backlog_limit=%d old=%d", | 254 | audit_log(NULL, "audit_backlog_limit=%d old=%d by auid %u", |
| 256 | audit_backlog_limit, old); | 255 | audit_backlog_limit, old, loginuid); |
| 257 | return old; | 256 | return old; |
| 258 | } | 257 | } |
| 259 | 258 | ||
| 260 | static int audit_set_enabled(int state) | 259 | static int audit_set_enabled(int state, uid_t loginuid) |
| 261 | { | 260 | { |
| 262 | int old = audit_enabled; | 261 | int old = audit_enabled; |
| 263 | if (state != 0 && state != 1) | 262 | if (state != 0 && state != 1) |
| 264 | return -EINVAL; | 263 | return -EINVAL; |
| 265 | audit_enabled = state; | 264 | audit_enabled = state; |
| 266 | audit_log(current->audit_context, "audit_enabled=%d old=%d", | 265 | audit_log(NULL, "audit_enabled=%d old=%d by auid %u", |
| 267 | audit_enabled, old); | 266 | audit_enabled, old, loginuid); |
| 268 | return old; | 267 | return old; |
| 269 | } | 268 | } |
| 270 | 269 | ||
| 271 | static int audit_set_failure(int state) | 270 | static int audit_set_failure(int state, uid_t loginuid) |
| 272 | { | 271 | { |
| 273 | int old = audit_failure; | 272 | int old = audit_failure; |
| 274 | if (state != AUDIT_FAIL_SILENT | 273 | if (state != AUDIT_FAIL_SILENT |
| @@ -276,8 +275,8 @@ static int audit_set_failure(int state) | |||
| 276 | && state != AUDIT_FAIL_PANIC) | 275 | && state != AUDIT_FAIL_PANIC) |
| 277 | return -EINVAL; | 276 | return -EINVAL; |
| 278 | audit_failure = state; | 277 | audit_failure = state; |
| 279 | audit_log(current->audit_context, "audit_failure=%d old=%d", | 278 | audit_log(NULL, "audit_failure=%d old=%d by auid %u", |
| 280 | audit_failure, old); | 279 | audit_failure, old, loginuid); |
| 281 | return old; | 280 | return old; |
| 282 | } | 281 | } |
| 283 | 282 | ||
| @@ -344,6 +343,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 344 | int err; | 343 | int err; |
| 345 | struct audit_buffer *ab; | 344 | struct audit_buffer *ab; |
| 346 | u16 msg_type = nlh->nlmsg_type; | 345 | u16 msg_type = nlh->nlmsg_type; |
| 346 | uid_t loginuid; /* loginuid of sender */ | ||
| 347 | 347 | ||
| 348 | err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); | 348 | err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); |
| 349 | if (err) | 349 | if (err) |
| @@ -351,6 +351,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 351 | 351 | ||
| 352 | pid = NETLINK_CREDS(skb)->pid; | 352 | pid = NETLINK_CREDS(skb)->pid; |
| 353 | uid = NETLINK_CREDS(skb)->uid; | 353 | uid = NETLINK_CREDS(skb)->uid; |
| 354 | loginuid = NETLINK_CB(skb).loginuid; | ||
| 354 | seq = nlh->nlmsg_seq; | 355 | seq = nlh->nlmsg_seq; |
| 355 | data = NLMSG_DATA(nlh); | 356 | data = NLMSG_DATA(nlh); |
| 356 | 357 | ||
| @@ -371,34 +372,36 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 371 | return -EINVAL; | 372 | return -EINVAL; |
| 372 | status_get = (struct audit_status *)data; | 373 | status_get = (struct audit_status *)data; |
| 373 | if (status_get->mask & AUDIT_STATUS_ENABLED) { | 374 | if (status_get->mask & AUDIT_STATUS_ENABLED) { |
| 374 | err = audit_set_enabled(status_get->enabled); | 375 | err = audit_set_enabled(status_get->enabled, loginuid); |
| 375 | if (err < 0) return err; | 376 | if (err < 0) return err; |
| 376 | } | 377 | } |
| 377 | if (status_get->mask & AUDIT_STATUS_FAILURE) { | 378 | if (status_get->mask & AUDIT_STATUS_FAILURE) { |
| 378 | err = audit_set_failure(status_get->failure); | 379 | err = audit_set_failure(status_get->failure, loginuid); |
| 379 | if (err < 0) return err; | 380 | if (err < 0) return err; |
| 380 | } | 381 | } |
| 381 | if (status_get->mask & AUDIT_STATUS_PID) { | 382 | if (status_get->mask & AUDIT_STATUS_PID) { |
| 382 | int old = audit_pid; | 383 | int old = audit_pid; |
| 383 | audit_pid = status_get->pid; | 384 | audit_pid = status_get->pid; |
| 384 | audit_log(current->audit_context, | 385 | audit_log(NULL, "audit_pid=%d old=%d by auid %u", |
| 385 | "audit_pid=%d old=%d", audit_pid, old); | 386 | audit_pid, old, loginuid); |
| 386 | } | 387 | } |
| 387 | if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) | 388 | if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) |
| 388 | audit_set_rate_limit(status_get->rate_limit); | 389 | audit_set_rate_limit(status_get->rate_limit, loginuid); |
| 389 | if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) | 390 | if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) |
| 390 | audit_set_backlog_limit(status_get->backlog_limit); | 391 | audit_set_backlog_limit(status_get->backlog_limit, |
| 392 | loginuid); | ||
| 391 | break; | 393 | break; |
| 392 | case AUDIT_USER: | 394 | case AUDIT_USER: |
| 393 | ab = audit_log_start(NULL); | 395 | ab = audit_log_start(NULL); |
| 394 | if (!ab) | 396 | if (!ab) |
| 395 | break; /* audit_panic has been called */ | 397 | break; /* audit_panic has been called */ |
| 396 | audit_log_format(ab, | 398 | audit_log_format(ab, |
| 397 | "user pid=%d uid=%d length=%d msg='%.1024s'", | 399 | "user pid=%d uid=%d length=%d loginuid=%u" |
| 400 | " msg='%.1024s'", | ||
| 398 | pid, uid, | 401 | pid, uid, |
| 399 | (int)(nlh->nlmsg_len | 402 | (int)(nlh->nlmsg_len |
| 400 | - ((char *)data - (char *)nlh)), | 403 | - ((char *)data - (char *)nlh)), |
| 401 | (char *)data); | 404 | loginuid, (char *)data); |
| 402 | ab->type = AUDIT_USER; | 405 | ab->type = AUDIT_USER; |
| 403 | ab->pid = pid; | 406 | ab->pid = pid; |
| 404 | audit_log_end(ab); | 407 | audit_log_end(ab); |
| @@ -411,7 +414,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 411 | case AUDIT_LIST: | 414 | case AUDIT_LIST: |
| 412 | #ifdef CONFIG_AUDITSYSCALL | 415 | #ifdef CONFIG_AUDITSYSCALL |
| 413 | err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid, | 416 | err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid, |
| 414 | uid, seq, data); | 417 | uid, seq, data, loginuid); |
| 415 | #else | 418 | #else |
| 416 | err = -EOPNOTSUPP; | 419 | err = -EOPNOTSUPP; |
| 417 | #endif | 420 | #endif |
| @@ -480,7 +483,7 @@ static void audit_log_move(struct audit_buffer *ab) | |||
| 480 | if (ab->len == 0) | 483 | if (ab->len == 0) |
| 481 | return; | 484 | return; |
| 482 | 485 | ||
| 483 | skb = skb_peek(&ab->sklist); | 486 | skb = skb_peek_tail(&ab->sklist); |
| 484 | if (!skb || skb_tailroom(skb) <= ab->len + extra) { | 487 | if (!skb || skb_tailroom(skb) <= ab->len + extra) { |
| 485 | skb = alloc_skb(2 * ab->len + extra, GFP_ATOMIC); | 488 | skb = alloc_skb(2 * ab->len + extra, GFP_ATOMIC); |
| 486 | if (!skb) { | 489 | if (!skb) { |
| @@ -519,9 +522,9 @@ static inline int audit_log_drain(struct audit_buffer *ab) | |||
| 519 | retval = netlink_unicast(audit_sock, skb, audit_pid, | 522 | retval = netlink_unicast(audit_sock, skb, audit_pid, |
| 520 | MSG_DONTWAIT); | 523 | MSG_DONTWAIT); |
| 521 | } | 524 | } |
| 522 | if (retval == -EAGAIN && ab->count < 5) { | 525 | if (retval == -EAGAIN && |
| 523 | ++ab->count; | 526 | (atomic_read(&audit_backlog)) < audit_backlog_limit) { |
| 524 | skb_queue_tail(&ab->sklist, skb); | 527 | skb_queue_head(&ab->sklist, skb); |
| 525 | audit_log_end_irq(ab); | 528 | audit_log_end_irq(ab); |
| 526 | return 1; | 529 | return 1; |
| 527 | } | 530 | } |
| @@ -537,8 +540,8 @@ static inline int audit_log_drain(struct audit_buffer *ab) | |||
| 537 | if (!audit_pid) { /* No daemon */ | 540 | if (!audit_pid) { /* No daemon */ |
| 538 | int offset = ab->nlh ? NLMSG_SPACE(0) : 0; | 541 | int offset = ab->nlh ? NLMSG_SPACE(0) : 0; |
| 539 | int len = skb->len - offset; | 542 | int len = skb->len - offset; |
| 540 | printk(KERN_ERR "%*.*s\n", | 543 | skb->data[offset + len] = '\0'; |
| 541 | len, len, skb->data + offset); | 544 | printk(KERN_ERR "%s\n", skb->data + offset); |
| 542 | } | 545 | } |
| 543 | kfree_skb(skb); | 546 | kfree_skb(skb); |
| 544 | ab->nlh = NULL; | 547 | ab->nlh = NULL; |
| @@ -617,7 +620,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx) | |||
| 617 | struct audit_buffer *ab = NULL; | 620 | struct audit_buffer *ab = NULL; |
| 618 | unsigned long flags; | 621 | unsigned long flags; |
| 619 | struct timespec t; | 622 | struct timespec t; |
| 620 | int serial = 0; | 623 | unsigned int serial; |
| 621 | 624 | ||
| 622 | if (!audit_initialized) | 625 | if (!audit_initialized) |
| 623 | return NULL; | 626 | return NULL; |
| @@ -659,15 +662,16 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx) | |||
| 659 | ab->total = 0; | 662 | ab->total = 0; |
| 660 | ab->type = AUDIT_KERNEL; | 663 | ab->type = AUDIT_KERNEL; |
| 661 | ab->pid = 0; | 664 | ab->pid = 0; |
| 662 | ab->count = 0; | ||
| 663 | 665 | ||
| 664 | #ifdef CONFIG_AUDITSYSCALL | 666 | #ifdef CONFIG_AUDITSYSCALL |
| 665 | if (ab->ctx) | 667 | if (ab->ctx) |
| 666 | audit_get_stamp(ab->ctx, &t, &serial); | 668 | audit_get_stamp(ab->ctx, &t, &serial); |
| 667 | else | 669 | else |
| 668 | #endif | 670 | #endif |
| 671 | { | ||
| 669 | t = CURRENT_TIME; | 672 | t = CURRENT_TIME; |
| 670 | 673 | serial = 0; | |
| 674 | } | ||
| 671 | audit_log_format(ab, "audit(%lu.%03lu:%u): ", | 675 | audit_log_format(ab, "audit(%lu.%03lu:%u): ", |
| 672 | t.tv_sec, t.tv_nsec/1000000, serial); | 676 | t.tv_sec, t.tv_nsec/1000000, serial); |
| 673 | return ab; | 677 | return ab; |
| @@ -717,6 +721,29 @@ void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) | |||
| 717 | va_end(args); | 721 | va_end(args); |
| 718 | } | 722 | } |
| 719 | 723 | ||
| 724 | void audit_log_hex(struct audit_buffer *ab, const unsigned char *buf, size_t len) | ||
| 725 | { | ||
| 726 | int i; | ||
| 727 | |||
| 728 | for (i=0; i<len; i++) | ||
| 729 | audit_log_format(ab, "%02x", buf[i]); | ||
| 730 | } | ||
| 731 | |||
| 732 | void audit_log_untrustedstring(struct audit_buffer *ab, const char *string) | ||
| 733 | { | ||
| 734 | const unsigned char *p = string; | ||
| 735 | |||
| 736 | while (*p) { | ||
| 737 | if (*p == '"' || *p == ' ' || *p < 0x20 || *p > 0x7f) { | ||
| 738 | audit_log_hex(ab, string, strlen(string)); | ||
| 739 | return; | ||
| 740 | } | ||
| 741 | p++; | ||
| 742 | } | ||
| 743 | audit_log_format(ab, "\"%s\"", string); | ||
| 744 | } | ||
| 745 | |||
| 746 | |||
| 720 | /* This is a helper-function to print the d_path without using a static | 747 | /* This is a helper-function to print the d_path without using a static |
| 721 | * buffer or allocating another buffer in addition to the one in | 748 | * buffer or allocating another buffer in addition to the one in |
| 722 | * audit_buffer. */ | 749 | * audit_buffer. */ |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 6f1931381bc9..37b3ac94bc47 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* auditsc.c -- System-call auditing support -*- linux-c -*- | 1 | /* auditsc.c -- System-call auditing support |
| 2 | * Handles all system-call specific auditing features. | 2 | * Handles all system-call specific auditing features. |
| 3 | * | 3 | * |
| 4 | * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. | 4 | * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. |
| @@ -123,7 +123,7 @@ struct audit_context { | |||
| 123 | int major; /* syscall number */ | 123 | int major; /* syscall number */ |
| 124 | unsigned long argv[4]; /* syscall arguments */ | 124 | unsigned long argv[4]; /* syscall arguments */ |
| 125 | int return_valid; /* return code is valid */ | 125 | int return_valid; /* return code is valid */ |
| 126 | int return_code;/* syscall return code */ | 126 | long return_code;/* syscall return code */ |
| 127 | int auditable; /* 1 if record should be written */ | 127 | int auditable; /* 1 if record should be written */ |
| 128 | int name_count; | 128 | int name_count; |
| 129 | struct audit_names names[AUDIT_NAMES]; | 129 | struct audit_names names[AUDIT_NAMES]; |
| @@ -135,6 +135,7 @@ struct audit_context { | |||
| 135 | uid_t uid, euid, suid, fsuid; | 135 | uid_t uid, euid, suid, fsuid; |
| 136 | gid_t gid, egid, sgid, fsgid; | 136 | gid_t gid, egid, sgid, fsgid; |
| 137 | unsigned long personality; | 137 | unsigned long personality; |
| 138 | int arch; | ||
| 138 | 139 | ||
| 139 | #if AUDIT_DEBUG | 140 | #if AUDIT_DEBUG |
| 140 | int put_count; | 141 | int put_count; |
| @@ -250,7 +251,8 @@ static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) | |||
| 250 | return 0; | 251 | return 0; |
| 251 | } | 252 | } |
| 252 | 253 | ||
| 253 | int audit_receive_filter(int type, int pid, int uid, int seq, void *data) | 254 | int audit_receive_filter(int type, int pid, int uid, int seq, void *data, |
| 255 | uid_t loginuid) | ||
| 254 | { | 256 | { |
| 255 | u32 flags; | 257 | u32 flags; |
| 256 | struct audit_entry *entry; | 258 | struct audit_entry *entry; |
| @@ -285,6 +287,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data) | |||
| 285 | err = audit_add_rule(entry, &audit_entlist); | 287 | err = audit_add_rule(entry, &audit_entlist); |
| 286 | if (!err && (flags & AUDIT_AT_EXIT)) | 288 | if (!err && (flags & AUDIT_AT_EXIT)) |
| 287 | err = audit_add_rule(entry, &audit_extlist); | 289 | err = audit_add_rule(entry, &audit_extlist); |
| 290 | audit_log(NULL, "auid %u added an audit rule\n", loginuid); | ||
| 288 | break; | 291 | break; |
| 289 | case AUDIT_DEL: | 292 | case AUDIT_DEL: |
| 290 | flags =((struct audit_rule *)data)->flags; | 293 | flags =((struct audit_rule *)data)->flags; |
| @@ -294,6 +297,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data) | |||
| 294 | err = audit_del_rule(data, &audit_entlist); | 297 | err = audit_del_rule(data, &audit_entlist); |
| 295 | if (!err && (flags & AUDIT_AT_EXIT)) | 298 | if (!err && (flags & AUDIT_AT_EXIT)) |
| 296 | err = audit_del_rule(data, &audit_extlist); | 299 | err = audit_del_rule(data, &audit_extlist); |
| 300 | audit_log(NULL, "auid %u removed an audit rule\n", loginuid); | ||
| 297 | break; | 301 | break; |
| 298 | default: | 302 | default: |
| 299 | return -EINVAL; | 303 | return -EINVAL; |
| @@ -348,6 +352,10 @@ static int audit_filter_rules(struct task_struct *tsk, | |||
| 348 | case AUDIT_PERS: | 352 | case AUDIT_PERS: |
| 349 | result = (tsk->personality == value); | 353 | result = (tsk->personality == value); |
| 350 | break; | 354 | break; |
| 355 | case AUDIT_ARCH: | ||
| 356 | if (ctx) | ||
| 357 | result = (ctx->arch == value); | ||
| 358 | break; | ||
| 351 | 359 | ||
| 352 | case AUDIT_EXIT: | 360 | case AUDIT_EXIT: |
| 353 | if (ctx && ctx->return_valid) | 361 | if (ctx && ctx->return_valid) |
| @@ -355,7 +363,7 @@ static int audit_filter_rules(struct task_struct *tsk, | |||
| 355 | break; | 363 | break; |
| 356 | case AUDIT_SUCCESS: | 364 | case AUDIT_SUCCESS: |
| 357 | if (ctx && ctx->return_valid) | 365 | if (ctx && ctx->return_valid) |
| 358 | result = (ctx->return_code >= 0); | 366 | result = (ctx->return_valid == AUDITSC_SUCCESS); |
| 359 | break; | 367 | break; |
| 360 | case AUDIT_DEVMAJOR: | 368 | case AUDIT_DEVMAJOR: |
| 361 | if (ctx) { | 369 | if (ctx) { |
| @@ -648,8 +656,11 @@ static void audit_log_exit(struct audit_context *context) | |||
| 648 | audit_log_format(ab, "syscall=%d", context->major); | 656 | audit_log_format(ab, "syscall=%d", context->major); |
| 649 | if (context->personality != PER_LINUX) | 657 | if (context->personality != PER_LINUX) |
| 650 | audit_log_format(ab, " per=%lx", context->personality); | 658 | audit_log_format(ab, " per=%lx", context->personality); |
| 659 | audit_log_format(ab, " arch=%x", context->arch); | ||
| 651 | if (context->return_valid) | 660 | if (context->return_valid) |
| 652 | audit_log_format(ab, " exit=%d", context->return_code); | 661 | audit_log_format(ab, " success=%s exit=%ld", |
| 662 | (context->return_valid==AUDITSC_SUCCESS)?"yes":"no", | ||
| 663 | context->return_code); | ||
| 653 | audit_log_format(ab, | 664 | audit_log_format(ab, |
| 654 | " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" | 665 | " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" |
| 655 | " pid=%d loginuid=%d uid=%d gid=%d" | 666 | " pid=%d loginuid=%d uid=%d gid=%d" |
| @@ -696,9 +707,10 @@ static void audit_log_exit(struct audit_context *context) | |||
| 696 | if (!ab) | 707 | if (!ab) |
| 697 | continue; /* audit_panic has been called */ | 708 | continue; /* audit_panic has been called */ |
| 698 | audit_log_format(ab, "item=%d", i); | 709 | audit_log_format(ab, "item=%d", i); |
| 699 | if (context->names[i].name) | 710 | if (context->names[i].name) { |
| 700 | audit_log_format(ab, " name=%s", | 711 | audit_log_format(ab, " name="); |
| 701 | context->names[i].name); | 712 | audit_log_untrustedstring(ab, context->names[i].name); |
| 713 | } | ||
| 702 | if (context->names[i].ino != (unsigned long)-1) | 714 | if (context->names[i].ino != (unsigned long)-1) |
| 703 | audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o" | 715 | audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o" |
| 704 | " uid=%d gid=%d rdev=%02x:%02x", | 716 | " uid=%d gid=%d rdev=%02x:%02x", |
| @@ -772,7 +784,7 @@ static inline unsigned int audit_serial(void) | |||
| 772 | * then the record will be written at syscall exit time (otherwise, it | 784 | * then the record will be written at syscall exit time (otherwise, it |
| 773 | * will only be written if another part of the kernel requests that it | 785 | * will only be written if another part of the kernel requests that it |
| 774 | * be written). */ | 786 | * be written). */ |
| 775 | void audit_syscall_entry(struct task_struct *tsk, int major, | 787 | void audit_syscall_entry(struct task_struct *tsk, int arch, int major, |
| 776 | unsigned long a1, unsigned long a2, | 788 | unsigned long a1, unsigned long a2, |
| 777 | unsigned long a3, unsigned long a4) | 789 | unsigned long a3, unsigned long a4) |
| 778 | { | 790 | { |
| @@ -826,6 +838,7 @@ void audit_syscall_entry(struct task_struct *tsk, int major, | |||
| 826 | if (!audit_enabled) | 838 | if (!audit_enabled) |
| 827 | return; | 839 | return; |
| 828 | 840 | ||
| 841 | context->arch = arch; | ||
| 829 | context->major = major; | 842 | context->major = major; |
| 830 | context->argv[0] = a1; | 843 | context->argv[0] = a1; |
| 831 | context->argv[1] = a2; | 844 | context->argv[1] = a2; |
| @@ -849,13 +862,13 @@ void audit_syscall_entry(struct task_struct *tsk, int major, | |||
| 849 | * filtering, or because some other part of the kernel write an audit | 862 | * filtering, or because some other part of the kernel write an audit |
| 850 | * message), then write out the syscall information. In call cases, | 863 | * message), then write out the syscall information. In call cases, |
| 851 | * free the names stored from getname(). */ | 864 | * free the names stored from getname(). */ |
| 852 | void audit_syscall_exit(struct task_struct *tsk, int return_code) | 865 | void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) |
| 853 | { | 866 | { |
| 854 | struct audit_context *context; | 867 | struct audit_context *context; |
| 855 | 868 | ||
| 856 | get_task_struct(tsk); | 869 | get_task_struct(tsk); |
| 857 | task_lock(tsk); | 870 | task_lock(tsk); |
| 858 | context = audit_get_context(tsk, 1, return_code); | 871 | context = audit_get_context(tsk, valid, return_code); |
| 859 | task_unlock(tsk); | 872 | task_unlock(tsk); |
| 860 | 873 | ||
| 861 | /* Not having a context here is ok, since the parent may have | 874 | /* Not having a context here is ok, since the parent may have |
| @@ -868,6 +881,7 @@ void audit_syscall_exit(struct task_struct *tsk, int return_code) | |||
| 868 | 881 | ||
| 869 | context->in_syscall = 0; | 882 | context->in_syscall = 0; |
| 870 | context->auditable = 0; | 883 | context->auditable = 0; |
| 884 | |||
| 871 | if (context->previous) { | 885 | if (context->previous) { |
| 872 | struct audit_context *new_context = context->previous; | 886 | struct audit_context *new_context = context->previous; |
| 873 | context->previous = NULL; | 887 | context->previous = NULL; |
| @@ -981,7 +995,7 @@ void audit_inode(const char *name, const struct inode *inode) | |||
| 981 | } | 995 | } |
| 982 | 996 | ||
| 983 | void audit_get_stamp(struct audit_context *ctx, | 997 | void audit_get_stamp(struct audit_context *ctx, |
| 984 | struct timespec *t, int *serial) | 998 | struct timespec *t, unsigned int *serial) |
| 985 | { | 999 | { |
| 986 | if (ctx) { | 1000 | if (ctx) { |
| 987 | t->tv_sec = ctx->ctime.tv_sec; | 1001 | t->tv_sec = ctx->ctime.tv_sec; |
| @@ -996,20 +1010,21 @@ void audit_get_stamp(struct audit_context *ctx, | |||
| 996 | 1010 | ||
| 997 | extern int audit_set_type(struct audit_buffer *ab, int type); | 1011 | extern int audit_set_type(struct audit_buffer *ab, int type); |
| 998 | 1012 | ||
| 999 | int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid) | 1013 | int audit_set_loginuid(struct task_struct *task, uid_t loginuid) |
| 1000 | { | 1014 | { |
| 1001 | if (ctx) { | 1015 | if (task->audit_context) { |
| 1002 | struct audit_buffer *ab; | 1016 | struct audit_buffer *ab; |
| 1003 | 1017 | ||
| 1004 | ab = audit_log_start(NULL); | 1018 | ab = audit_log_start(NULL); |
| 1005 | if (ab) { | 1019 | if (ab) { |
| 1006 | audit_log_format(ab, "login pid=%d uid=%u " | 1020 | audit_log_format(ab, "login pid=%d uid=%u " |
| 1007 | "old loginuid=%u new loginuid=%u", | 1021 | "old loginuid=%u new loginuid=%u", |
| 1008 | ctx->pid, ctx->uid, ctx->loginuid, loginuid); | 1022 | task->pid, task->uid, |
| 1023 | task->audit_context->loginuid, loginuid); | ||
| 1009 | audit_set_type(ab, AUDIT_LOGIN); | 1024 | audit_set_type(ab, AUDIT_LOGIN); |
| 1010 | audit_log_end(ab); | 1025 | audit_log_end(ab); |
| 1011 | } | 1026 | } |
| 1012 | ctx->loginuid = loginuid; | 1027 | task->audit_context->loginuid = loginuid; |
| 1013 | } | 1028 | } |
| 1014 | return 0; | 1029 | return 0; |
| 1015 | } | 1030 | } |
