diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/acct.c | 8 | ||||
| -rw-r--r-- | kernel/cgroup.c | 1 | ||||
| -rw-r--r-- | kernel/cred.c | 293 | ||||
| -rw-r--r-- | kernel/exit.c | 4 | ||||
| -rw-r--r-- | kernel/fork.c | 27 | ||||
| -rw-r--r-- | kernel/irq/manage.c | 10 | ||||
| -rw-r--r-- | kernel/kmod.c | 5 | ||||
| -rw-r--r-- | kernel/module.c | 10 | ||||
| -rw-r--r-- | kernel/perf_counter.c | 20 | ||||
| -rw-r--r-- | kernel/ptrace.c | 2 | ||||
| -rw-r--r-- | kernel/sysctl.c | 6 | ||||
| -rw-r--r-- | kernel/time/clockevents.c | 16 | ||||
| -rw-r--r-- | kernel/time/tick-broadcast.c | 7 | ||||
| -rw-r--r-- | kernel/time/timer_list.c | 2 | ||||
| -rw-r--r-- | kernel/trace/ftrace.c | 17 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 12 |
16 files changed, 376 insertions, 64 deletions
diff --git a/kernel/acct.c b/kernel/acct.c index 9f3391090b3e..9a4715a2f6bf 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
| @@ -491,13 +491,17 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
| 491 | u64 run_time; | 491 | u64 run_time; |
| 492 | struct timespec uptime; | 492 | struct timespec uptime; |
| 493 | struct tty_struct *tty; | 493 | struct tty_struct *tty; |
| 494 | const struct cred *orig_cred; | ||
| 495 | |||
| 496 | /* Perform file operations on behalf of whoever enabled accounting */ | ||
| 497 | orig_cred = override_creds(file->f_cred); | ||
| 494 | 498 | ||
| 495 | /* | 499 | /* |
| 496 | * First check to see if there is enough free_space to continue | 500 | * First check to see if there is enough free_space to continue |
| 497 | * the process accounting system. | 501 | * the process accounting system. |
| 498 | */ | 502 | */ |
| 499 | if (!check_free_space(acct, file)) | 503 | if (!check_free_space(acct, file)) |
| 500 | return; | 504 | goto out; |
| 501 | 505 | ||
| 502 | /* | 506 | /* |
| 503 | * Fill the accounting struct with the needed info as recorded | 507 | * Fill the accounting struct with the needed info as recorded |
| @@ -578,6 +582,8 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
| 578 | sizeof(acct_t), &file->f_pos); | 582 | sizeof(acct_t), &file->f_pos); |
| 579 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; | 583 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; |
| 580 | set_fs(fs); | 584 | set_fs(fs); |
| 585 | out: | ||
| 586 | revert_creds(orig_cred); | ||
| 581 | } | 587 | } |
| 582 | 588 | ||
| 583 | /** | 589 | /** |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index b6eadfe30e7b..c7ece8f027f2 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -600,6 +600,7 @@ static struct inode_operations cgroup_dir_inode_operations; | |||
| 600 | static struct file_operations proc_cgroupstats_operations; | 600 | static struct file_operations proc_cgroupstats_operations; |
| 601 | 601 | ||
| 602 | static struct backing_dev_info cgroup_backing_dev_info = { | 602 | static struct backing_dev_info cgroup_backing_dev_info = { |
| 603 | .name = "cgroup", | ||
| 603 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK, | 604 | .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK, |
| 604 | }; | 605 | }; |
| 605 | 606 | ||
diff --git a/kernel/cred.c b/kernel/cred.c index 1bb4d7e5d616..006fcab009d5 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
| @@ -18,6 +18,18 @@ | |||
| 18 | #include <linux/cn_proc.h> | 18 | #include <linux/cn_proc.h> |
| 19 | #include "cred-internals.h" | 19 | #include "cred-internals.h" |
| 20 | 20 | ||
| 21 | #if 0 | ||
| 22 | #define kdebug(FMT, ...) \ | ||
| 23 | printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) | ||
| 24 | #else | ||
| 25 | static inline __attribute__((format(printf, 1, 2))) | ||
| 26 | void no_printk(const char *fmt, ...) | ||
| 27 | { | ||
| 28 | } | ||
| 29 | #define kdebug(FMT, ...) \ | ||
| 30 | no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) | ||
| 31 | #endif | ||
| 32 | |||
| 21 | static struct kmem_cache *cred_jar; | 33 | static struct kmem_cache *cred_jar; |
| 22 | 34 | ||
| 23 | /* | 35 | /* |
| @@ -36,6 +48,10 @@ static struct thread_group_cred init_tgcred = { | |||
| 36 | */ | 48 | */ |
| 37 | struct cred init_cred = { | 49 | struct cred init_cred = { |
| 38 | .usage = ATOMIC_INIT(4), | 50 | .usage = ATOMIC_INIT(4), |
| 51 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 52 | .subscribers = ATOMIC_INIT(2), | ||
| 53 | .magic = CRED_MAGIC, | ||
| 54 | #endif | ||
| 39 | .securebits = SECUREBITS_DEFAULT, | 55 | .securebits = SECUREBITS_DEFAULT, |
| 40 | .cap_inheritable = CAP_INIT_INH_SET, | 56 | .cap_inheritable = CAP_INIT_INH_SET, |
| 41 | .cap_permitted = CAP_FULL_SET, | 57 | .cap_permitted = CAP_FULL_SET, |
| @@ -48,6 +64,31 @@ struct cred init_cred = { | |||
| 48 | #endif | 64 | #endif |
| 49 | }; | 65 | }; |
| 50 | 66 | ||
| 67 | static inline void set_cred_subscribers(struct cred *cred, int n) | ||
| 68 | { | ||
| 69 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 70 | atomic_set(&cred->subscribers, n); | ||
| 71 | #endif | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline int read_cred_subscribers(const struct cred *cred) | ||
| 75 | { | ||
| 76 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 77 | return atomic_read(&cred->subscribers); | ||
| 78 | #else | ||
| 79 | return 0; | ||
| 80 | #endif | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline void alter_cred_subscribers(const struct cred *_cred, int n) | ||
| 84 | { | ||
| 85 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 86 | struct cred *cred = (struct cred *) _cred; | ||
| 87 | |||
| 88 | atomic_add(n, &cred->subscribers); | ||
| 89 | #endif | ||
| 90 | } | ||
| 91 | |||
| 51 | /* | 92 | /* |
| 52 | * Dispose of the shared task group credentials | 93 | * Dispose of the shared task group credentials |
| 53 | */ | 94 | */ |
| @@ -85,9 +126,22 @@ static void put_cred_rcu(struct rcu_head *rcu) | |||
| 85 | { | 126 | { |
| 86 | struct cred *cred = container_of(rcu, struct cred, rcu); | 127 | struct cred *cred = container_of(rcu, struct cred, rcu); |
| 87 | 128 | ||
| 129 | kdebug("put_cred_rcu(%p)", cred); | ||
| 130 | |||
| 131 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 132 | if (cred->magic != CRED_MAGIC_DEAD || | ||
| 133 | atomic_read(&cred->usage) != 0 || | ||
| 134 | read_cred_subscribers(cred) != 0) | ||
| 135 | panic("CRED: put_cred_rcu() sees %p with" | ||
| 136 | " mag %x, put %p, usage %d, subscr %d\n", | ||
| 137 | cred, cred->magic, cred->put_addr, | ||
| 138 | atomic_read(&cred->usage), | ||
| 139 | read_cred_subscribers(cred)); | ||
| 140 | #else | ||
| 88 | if (atomic_read(&cred->usage) != 0) | 141 | if (atomic_read(&cred->usage) != 0) |
| 89 | panic("CRED: put_cred_rcu() sees %p with usage %d\n", | 142 | panic("CRED: put_cred_rcu() sees %p with usage %d\n", |
| 90 | cred, atomic_read(&cred->usage)); | 143 | cred, atomic_read(&cred->usage)); |
| 144 | #endif | ||
| 91 | 145 | ||
| 92 | security_cred_free(cred); | 146 | security_cred_free(cred); |
| 93 | key_put(cred->thread_keyring); | 147 | key_put(cred->thread_keyring); |
| @@ -106,12 +160,90 @@ static void put_cred_rcu(struct rcu_head *rcu) | |||
| 106 | */ | 160 | */ |
| 107 | void __put_cred(struct cred *cred) | 161 | void __put_cred(struct cred *cred) |
| 108 | { | 162 | { |
| 163 | kdebug("__put_cred(%p{%d,%d})", cred, | ||
| 164 | atomic_read(&cred->usage), | ||
| 165 | read_cred_subscribers(cred)); | ||
| 166 | |||
| 109 | BUG_ON(atomic_read(&cred->usage) != 0); | 167 | BUG_ON(atomic_read(&cred->usage) != 0); |
| 168 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 169 | BUG_ON(read_cred_subscribers(cred) != 0); | ||
| 170 | cred->magic = CRED_MAGIC_DEAD; | ||
| 171 | cred->put_addr = __builtin_return_address(0); | ||
| 172 | #endif | ||
| 173 | BUG_ON(cred == current->cred); | ||
| 174 | BUG_ON(cred == current->real_cred); | ||
| 110 | 175 | ||
| 111 | call_rcu(&cred->rcu, put_cred_rcu); | 176 | call_rcu(&cred->rcu, put_cred_rcu); |
| 112 | } | 177 | } |
| 113 | EXPORT_SYMBOL(__put_cred); | 178 | EXPORT_SYMBOL(__put_cred); |
| 114 | 179 | ||
| 180 | /* | ||
| 181 | * Clean up a task's credentials when it exits | ||
| 182 | */ | ||
| 183 | void exit_creds(struct task_struct *tsk) | ||
| 184 | { | ||
| 185 | struct cred *cred; | ||
| 186 | |||
| 187 | kdebug("exit_creds(%u,%p,%p,{%d,%d})", tsk->pid, tsk->real_cred, tsk->cred, | ||
| 188 | atomic_read(&tsk->cred->usage), | ||
| 189 | read_cred_subscribers(tsk->cred)); | ||
| 190 | |||
| 191 | cred = (struct cred *) tsk->real_cred; | ||
| 192 | tsk->real_cred = NULL; | ||
| 193 | validate_creds(cred); | ||
| 194 | alter_cred_subscribers(cred, -1); | ||
| 195 | put_cred(cred); | ||
| 196 | |||
| 197 | cred = (struct cred *) tsk->cred; | ||
| 198 | tsk->cred = NULL; | ||
| 199 | validate_creds(cred); | ||
| 200 | alter_cred_subscribers(cred, -1); | ||
| 201 | put_cred(cred); | ||
| 202 | |||
| 203 | cred = (struct cred *) tsk->replacement_session_keyring; | ||
| 204 | if (cred) { | ||
| 205 | tsk->replacement_session_keyring = NULL; | ||
| 206 | validate_creds(cred); | ||
| 207 | put_cred(cred); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | /* | ||
| 212 | * Allocate blank credentials, such that the credentials can be filled in at a | ||
| 213 | * later date without risk of ENOMEM. | ||
| 214 | */ | ||
| 215 | struct cred *cred_alloc_blank(void) | ||
| 216 | { | ||
| 217 | struct cred *new; | ||
| 218 | |||
| 219 | new = kmem_cache_zalloc(cred_jar, GFP_KERNEL); | ||
| 220 | if (!new) | ||
| 221 | return NULL; | ||
| 222 | |||
| 223 | #ifdef CONFIG_KEYS | ||
| 224 | new->tgcred = kzalloc(sizeof(*new->tgcred), GFP_KERNEL); | ||
| 225 | if (!new->tgcred) { | ||
| 226 | kfree(new); | ||
| 227 | return NULL; | ||
| 228 | } | ||
| 229 | atomic_set(&new->tgcred->usage, 1); | ||
| 230 | #endif | ||
| 231 | |||
| 232 | atomic_set(&new->usage, 1); | ||
| 233 | |||
| 234 | if (security_cred_alloc_blank(new, GFP_KERNEL) < 0) | ||
| 235 | goto error; | ||
| 236 | |||
| 237 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 238 | new->magic = CRED_MAGIC; | ||
| 239 | #endif | ||
| 240 | return new; | ||
| 241 | |||
| 242 | error: | ||
| 243 | abort_creds(new); | ||
| 244 | return NULL; | ||
| 245 | } | ||
| 246 | |||
| 115 | /** | 247 | /** |
| 116 | * prepare_creds - Prepare a new set of credentials for modification | 248 | * prepare_creds - Prepare a new set of credentials for modification |
| 117 | * | 249 | * |
| @@ -132,16 +264,19 @@ struct cred *prepare_creds(void) | |||
| 132 | const struct cred *old; | 264 | const struct cred *old; |
| 133 | struct cred *new; | 265 | struct cred *new; |
| 134 | 266 | ||
| 135 | BUG_ON(atomic_read(&task->real_cred->usage) < 1); | 267 | validate_process_creds(); |
| 136 | 268 | ||
| 137 | new = kmem_cache_alloc(cred_jar, GFP_KERNEL); | 269 | new = kmem_cache_alloc(cred_jar, GFP_KERNEL); |
| 138 | if (!new) | 270 | if (!new) |
| 139 | return NULL; | 271 | return NULL; |
| 140 | 272 | ||
| 273 | kdebug("prepare_creds() alloc %p", new); | ||
| 274 | |||
| 141 | old = task->cred; | 275 | old = task->cred; |
| 142 | memcpy(new, old, sizeof(struct cred)); | 276 | memcpy(new, old, sizeof(struct cred)); |
| 143 | 277 | ||
| 144 | atomic_set(&new->usage, 1); | 278 | atomic_set(&new->usage, 1); |
| 279 | set_cred_subscribers(new, 0); | ||
| 145 | get_group_info(new->group_info); | 280 | get_group_info(new->group_info); |
| 146 | get_uid(new->user); | 281 | get_uid(new->user); |
| 147 | 282 | ||
| @@ -157,6 +292,7 @@ struct cred *prepare_creds(void) | |||
| 157 | 292 | ||
| 158 | if (security_prepare_creds(new, old, GFP_KERNEL) < 0) | 293 | if (security_prepare_creds(new, old, GFP_KERNEL) < 0) |
| 159 | goto error; | 294 | goto error; |
| 295 | validate_creds(new); | ||
| 160 | return new; | 296 | return new; |
| 161 | 297 | ||
| 162 | error: | 298 | error: |
| @@ -229,9 +365,12 @@ struct cred *prepare_usermodehelper_creds(void) | |||
| 229 | if (!new) | 365 | if (!new) |
| 230 | return NULL; | 366 | return NULL; |
| 231 | 367 | ||
| 368 | kdebug("prepare_usermodehelper_creds() alloc %p", new); | ||
| 369 | |||
| 232 | memcpy(new, &init_cred, sizeof(struct cred)); | 370 | memcpy(new, &init_cred, sizeof(struct cred)); |
| 233 | 371 | ||
| 234 | atomic_set(&new->usage, 1); | 372 | atomic_set(&new->usage, 1); |
| 373 | set_cred_subscribers(new, 0); | ||
| 235 | get_group_info(new->group_info); | 374 | get_group_info(new->group_info); |
| 236 | get_uid(new->user); | 375 | get_uid(new->user); |
| 237 | 376 | ||
| @@ -250,6 +389,7 @@ struct cred *prepare_usermodehelper_creds(void) | |||
| 250 | #endif | 389 | #endif |
| 251 | if (security_prepare_creds(new, &init_cred, GFP_ATOMIC) < 0) | 390 | if (security_prepare_creds(new, &init_cred, GFP_ATOMIC) < 0) |
| 252 | goto error; | 391 | goto error; |
| 392 | validate_creds(new); | ||
| 253 | 393 | ||
| 254 | BUG_ON(atomic_read(&new->usage) != 1); | 394 | BUG_ON(atomic_read(&new->usage) != 1); |
| 255 | return new; | 395 | return new; |
| @@ -286,6 +426,10 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags) | |||
| 286 | ) { | 426 | ) { |
| 287 | p->real_cred = get_cred(p->cred); | 427 | p->real_cred = get_cred(p->cred); |
| 288 | get_cred(p->cred); | 428 | get_cred(p->cred); |
| 429 | alter_cred_subscribers(p->cred, 2); | ||
| 430 | kdebug("share_creds(%p{%d,%d})", | ||
| 431 | p->cred, atomic_read(&p->cred->usage), | ||
| 432 | read_cred_subscribers(p->cred)); | ||
| 289 | atomic_inc(&p->cred->user->processes); | 433 | atomic_inc(&p->cred->user->processes); |
| 290 | return 0; | 434 | return 0; |
| 291 | } | 435 | } |
| @@ -331,6 +475,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags) | |||
| 331 | 475 | ||
| 332 | atomic_inc(&new->user->processes); | 476 | atomic_inc(&new->user->processes); |
| 333 | p->cred = p->real_cred = get_cred(new); | 477 | p->cred = p->real_cred = get_cred(new); |
| 478 | alter_cred_subscribers(new, 2); | ||
| 479 | validate_creds(new); | ||
| 334 | return 0; | 480 | return 0; |
| 335 | 481 | ||
| 336 | error_put: | 482 | error_put: |
| @@ -355,13 +501,20 @@ error_put: | |||
| 355 | int commit_creds(struct cred *new) | 501 | int commit_creds(struct cred *new) |
| 356 | { | 502 | { |
| 357 | struct task_struct *task = current; | 503 | struct task_struct *task = current; |
| 358 | const struct cred *old; | 504 | const struct cred *old = task->real_cred; |
| 359 | 505 | ||
| 360 | BUG_ON(task->cred != task->real_cred); | 506 | kdebug("commit_creds(%p{%d,%d})", new, |
| 361 | BUG_ON(atomic_read(&task->real_cred->usage) < 2); | 507 | atomic_read(&new->usage), |
| 508 | read_cred_subscribers(new)); | ||
| 509 | |||
| 510 | BUG_ON(task->cred != old); | ||
| 511 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 512 | BUG_ON(read_cred_subscribers(old) < 2); | ||
| 513 | validate_creds(old); | ||
| 514 | validate_creds(new); | ||
| 515 | #endif | ||
| 362 | BUG_ON(atomic_read(&new->usage) < 1); | 516 | BUG_ON(atomic_read(&new->usage) < 1); |
| 363 | 517 | ||
| 364 | old = task->real_cred; | ||
| 365 | security_commit_creds(new, old); | 518 | security_commit_creds(new, old); |
| 366 | 519 | ||
| 367 | get_cred(new); /* we will require a ref for the subj creds too */ | 520 | get_cred(new); /* we will require a ref for the subj creds too */ |
| @@ -390,12 +543,14 @@ int commit_creds(struct cred *new) | |||
| 390 | * cheaply with the new uid cache, so if it matters | 543 | * cheaply with the new uid cache, so if it matters |
| 391 | * we should be checking for it. -DaveM | 544 | * we should be checking for it. -DaveM |
| 392 | */ | 545 | */ |
| 546 | alter_cred_subscribers(new, 2); | ||
| 393 | if (new->user != old->user) | 547 | if (new->user != old->user) |
| 394 | atomic_inc(&new->user->processes); | 548 | atomic_inc(&new->user->processes); |
| 395 | rcu_assign_pointer(task->real_cred, new); | 549 | rcu_assign_pointer(task->real_cred, new); |
| 396 | rcu_assign_pointer(task->cred, new); | 550 | rcu_assign_pointer(task->cred, new); |
| 397 | if (new->user != old->user) | 551 | if (new->user != old->user) |
| 398 | atomic_dec(&old->user->processes); | 552 | atomic_dec(&old->user->processes); |
| 553 | alter_cred_subscribers(old, -2); | ||
| 399 | 554 | ||
| 400 | sched_switch_user(task); | 555 | sched_switch_user(task); |
| 401 | 556 | ||
| @@ -428,6 +583,13 @@ EXPORT_SYMBOL(commit_creds); | |||
| 428 | */ | 583 | */ |
| 429 | void abort_creds(struct cred *new) | 584 | void abort_creds(struct cred *new) |
| 430 | { | 585 | { |
| 586 | kdebug("abort_creds(%p{%d,%d})", new, | ||
| 587 | atomic_read(&new->usage), | ||
| 588 | read_cred_subscribers(new)); | ||
| 589 | |||
| 590 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 591 | BUG_ON(read_cred_subscribers(new) != 0); | ||
| 592 | #endif | ||
| 431 | BUG_ON(atomic_read(&new->usage) < 1); | 593 | BUG_ON(atomic_read(&new->usage) < 1); |
| 432 | put_cred(new); | 594 | put_cred(new); |
| 433 | } | 595 | } |
| @@ -444,7 +606,20 @@ const struct cred *override_creds(const struct cred *new) | |||
| 444 | { | 606 | { |
| 445 | const struct cred *old = current->cred; | 607 | const struct cred *old = current->cred; |
| 446 | 608 | ||
| 447 | rcu_assign_pointer(current->cred, get_cred(new)); | 609 | kdebug("override_creds(%p{%d,%d})", new, |
| 610 | atomic_read(&new->usage), | ||
| 611 | read_cred_subscribers(new)); | ||
| 612 | |||
| 613 | validate_creds(old); | ||
| 614 | validate_creds(new); | ||
| 615 | get_cred(new); | ||
| 616 | alter_cred_subscribers(new, 1); | ||
| 617 | rcu_assign_pointer(current->cred, new); | ||
| 618 | alter_cred_subscribers(old, -1); | ||
| 619 | |||
| 620 | kdebug("override_creds() = %p{%d,%d}", old, | ||
| 621 | atomic_read(&old->usage), | ||
| 622 | read_cred_subscribers(old)); | ||
| 448 | return old; | 623 | return old; |
| 449 | } | 624 | } |
| 450 | EXPORT_SYMBOL(override_creds); | 625 | EXPORT_SYMBOL(override_creds); |
| @@ -460,7 +635,15 @@ void revert_creds(const struct cred *old) | |||
| 460 | { | 635 | { |
| 461 | const struct cred *override = current->cred; | 636 | const struct cred *override = current->cred; |
| 462 | 637 | ||
| 638 | kdebug("revert_creds(%p{%d,%d})", old, | ||
| 639 | atomic_read(&old->usage), | ||
| 640 | read_cred_subscribers(old)); | ||
| 641 | |||
| 642 | validate_creds(old); | ||
| 643 | validate_creds(override); | ||
| 644 | alter_cred_subscribers(old, 1); | ||
| 463 | rcu_assign_pointer(current->cred, old); | 645 | rcu_assign_pointer(current->cred, old); |
| 646 | alter_cred_subscribers(override, -1); | ||
| 464 | put_cred(override); | 647 | put_cred(override); |
| 465 | } | 648 | } |
| 466 | EXPORT_SYMBOL(revert_creds); | 649 | EXPORT_SYMBOL(revert_creds); |
| @@ -502,11 +685,15 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon) | |||
| 502 | if (!new) | 685 | if (!new) |
| 503 | return NULL; | 686 | return NULL; |
| 504 | 687 | ||
| 688 | kdebug("prepare_kernel_cred() alloc %p", new); | ||
| 689 | |||
| 505 | if (daemon) | 690 | if (daemon) |
| 506 | old = get_task_cred(daemon); | 691 | old = get_task_cred(daemon); |
| 507 | else | 692 | else |
| 508 | old = get_cred(&init_cred); | 693 | old = get_cred(&init_cred); |
| 509 | 694 | ||
| 695 | validate_creds(old); | ||
| 696 | |||
| 510 | *new = *old; | 697 | *new = *old; |
| 511 | get_uid(new->user); | 698 | get_uid(new->user); |
| 512 | get_group_info(new->group_info); | 699 | get_group_info(new->group_info); |
| @@ -526,7 +713,9 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon) | |||
| 526 | goto error; | 713 | goto error; |
| 527 | 714 | ||
| 528 | atomic_set(&new->usage, 1); | 715 | atomic_set(&new->usage, 1); |
| 716 | set_cred_subscribers(new, 0); | ||
| 529 | put_cred(old); | 717 | put_cred(old); |
| 718 | validate_creds(new); | ||
| 530 | return new; | 719 | return new; |
| 531 | 720 | ||
| 532 | error: | 721 | error: |
| @@ -589,3 +778,95 @@ int set_create_files_as(struct cred *new, struct inode *inode) | |||
| 589 | return security_kernel_create_files_as(new, inode); | 778 | return security_kernel_create_files_as(new, inode); |
| 590 | } | 779 | } |
| 591 | EXPORT_SYMBOL(set_create_files_as); | 780 | EXPORT_SYMBOL(set_create_files_as); |
| 781 | |||
| 782 | #ifdef CONFIG_DEBUG_CREDENTIALS | ||
| 783 | |||
| 784 | /* | ||
| 785 | * dump invalid credentials | ||
| 786 | */ | ||
| 787 | static void dump_invalid_creds(const struct cred *cred, const char *label, | ||
| 788 | const struct task_struct *tsk) | ||
| 789 | { | ||
| 790 | printk(KERN_ERR "CRED: %s credentials: %p %s%s%s\n", | ||
| 791 | label, cred, | ||
| 792 | cred == &init_cred ? "[init]" : "", | ||
| 793 | cred == tsk->real_cred ? "[real]" : "", | ||
| 794 | cred == tsk->cred ? "[eff]" : ""); | ||
| 795 | printk(KERN_ERR "CRED: ->magic=%x, put_addr=%p\n", | ||
| 796 | cred->magic, cred->put_addr); | ||
| 797 | printk(KERN_ERR "CRED: ->usage=%d, subscr=%d\n", | ||
| 798 | atomic_read(&cred->usage), | ||
| 799 | read_cred_subscribers(cred)); | ||
| 800 | printk(KERN_ERR "CRED: ->*uid = { %d,%d,%d,%d }\n", | ||
| 801 | cred->uid, cred->euid, cred->suid, cred->fsuid); | ||
| 802 | printk(KERN_ERR "CRED: ->*gid = { %d,%d,%d,%d }\n", | ||
| 803 | cred->gid, cred->egid, cred->sgid, cred->fsgid); | ||
| 804 | #ifdef CONFIG_SECURITY | ||
| 805 | printk(KERN_ERR "CRED: ->security is %p\n", cred->security); | ||
| 806 | if ((unsigned long) cred->security >= PAGE_SIZE && | ||
| 807 | (((unsigned long) cred->security & 0xffffff00) != | ||
| 808 | (POISON_FREE << 24 | POISON_FREE << 16 | POISON_FREE << 8))) | ||
| 809 | printk(KERN_ERR "CRED: ->security {%x, %x}\n", | ||
| 810 | ((u32*)cred->security)[0], | ||
| 811 | ((u32*)cred->security)[1]); | ||
| 812 | #endif | ||
| 813 | } | ||
| 814 | |||
| 815 | /* | ||
| 816 | * report use of invalid credentials | ||
| 817 | */ | ||
| 818 | void __invalid_creds(const struct cred *cred, const char *file, unsigned line) | ||
| 819 | { | ||
| 820 | printk(KERN_ERR "CRED: Invalid credentials\n"); | ||
| 821 | printk(KERN_ERR "CRED: At %s:%u\n", file, line); | ||
| 822 | dump_invalid_creds(cred, "Specified", current); | ||
| 823 | BUG(); | ||
| 824 | } | ||
| 825 | EXPORT_SYMBOL(__invalid_creds); | ||
| 826 | |||
| 827 | /* | ||
| 828 | * check the credentials on a process | ||
| 829 | */ | ||
| 830 | void __validate_process_creds(struct task_struct *tsk, | ||
| 831 | const char *file, unsigned line) | ||
| 832 | { | ||
| 833 | if (tsk->cred == tsk->real_cred) { | ||
| 834 | if (unlikely(read_cred_subscribers(tsk->cred) < 2 || | ||
| 835 | creds_are_invalid(tsk->cred))) | ||
| 836 | goto invalid_creds; | ||
| 837 | } else { | ||
| 838 | if (unlikely(read_cred_subscribers(tsk->real_cred) < 1 || | ||
| 839 | read_cred_subscribers(tsk->cred) < 1 || | ||
| 840 | creds_are_invalid(tsk->real_cred) || | ||
| 841 | creds_are_invalid(tsk->cred))) | ||
| 842 | goto invalid_creds; | ||
| 843 | } | ||
| 844 | return; | ||
| 845 | |||
| 846 | invalid_creds: | ||
| 847 | printk(KERN_ERR "CRED: Invalid process credentials\n"); | ||
| 848 | printk(KERN_ERR "CRED: At %s:%u\n", file, line); | ||
| 849 | |||
| 850 | dump_invalid_creds(tsk->real_cred, "Real", tsk); | ||
| 851 | if (tsk->cred != tsk->real_cred) | ||
| 852 | dump_invalid_creds(tsk->cred, "Effective", tsk); | ||
| 853 | else | ||
| 854 | printk(KERN_ERR "CRED: Effective creds == Real creds\n"); | ||
| 855 | BUG(); | ||
| 856 | } | ||
| 857 | EXPORT_SYMBOL(__validate_process_creds); | ||
| 858 | |||
| 859 | /* | ||
| 860 | * check creds for do_exit() | ||
| 861 | */ | ||
| 862 | void validate_creds_for_do_exit(struct task_struct *tsk) | ||
| 863 | { | ||
| 864 | kdebug("validate_creds_for_do_exit(%p,%p{%d,%d})", | ||
| 865 | tsk->real_cred, tsk->cred, | ||
| 866 | atomic_read(&tsk->cred->usage), | ||
| 867 | read_cred_subscribers(tsk->cred)); | ||
| 868 | |||
| 869 | __validate_process_creds(tsk, __FILE__, __LINE__); | ||
| 870 | } | ||
| 871 | |||
| 872 | #endif /* CONFIG_DEBUG_CREDENTIALS */ | ||
diff --git a/kernel/exit.c b/kernel/exit.c index 869dc221733e..c98ff7a8025f 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -901,6 +901,8 @@ NORET_TYPE void do_exit(long code) | |||
| 901 | 901 | ||
| 902 | tracehook_report_exit(&code); | 902 | tracehook_report_exit(&code); |
| 903 | 903 | ||
| 904 | validate_creds_for_do_exit(tsk); | ||
| 905 | |||
| 904 | /* | 906 | /* |
| 905 | * We're taking recursive faults here in do_exit. Safest is to just | 907 | * We're taking recursive faults here in do_exit. Safest is to just |
| 906 | * leave this task alone and wait for reboot. | 908 | * leave this task alone and wait for reboot. |
| @@ -1009,6 +1011,8 @@ NORET_TYPE void do_exit(long code) | |||
| 1009 | if (tsk->splice_pipe) | 1011 | if (tsk->splice_pipe) |
| 1010 | __free_pipe_info(tsk->splice_pipe); | 1012 | __free_pipe_info(tsk->splice_pipe); |
| 1011 | 1013 | ||
| 1014 | validate_creds_for_do_exit(tsk); | ||
| 1015 | |||
| 1012 | preempt_disable(); | 1016 | preempt_disable(); |
| 1013 | /* causes final put_task_struct in finish_task_switch(). */ | 1017 | /* causes final put_task_struct in finish_task_switch(). */ |
| 1014 | tsk->state = TASK_DEAD; | 1018 | tsk->state = TASK_DEAD; |
diff --git a/kernel/fork.c b/kernel/fork.c index 021e1138556e..aab8579c6093 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -152,8 +152,7 @@ void __put_task_struct(struct task_struct *tsk) | |||
| 152 | WARN_ON(atomic_read(&tsk->usage)); | 152 | WARN_ON(atomic_read(&tsk->usage)); |
| 153 | WARN_ON(tsk == current); | 153 | WARN_ON(tsk == current); |
| 154 | 154 | ||
| 155 | put_cred(tsk->real_cred); | 155 | exit_creds(tsk); |
| 156 | put_cred(tsk->cred); | ||
| 157 | delayacct_tsk_free(tsk); | 156 | delayacct_tsk_free(tsk); |
| 158 | 157 | ||
| 159 | if (!profile_handoff_task(tsk)) | 158 | if (!profile_handoff_task(tsk)) |
| @@ -426,7 +425,6 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
| 426 | init_rwsem(&mm->mmap_sem); | 425 | init_rwsem(&mm->mmap_sem); |
| 427 | INIT_LIST_HEAD(&mm->mmlist); | 426 | INIT_LIST_HEAD(&mm->mmlist); |
| 428 | mm->flags = (current->mm) ? current->mm->flags : default_dump_filter; | 427 | mm->flags = (current->mm) ? current->mm->flags : default_dump_filter; |
| 429 | mm->oom_adj = (current->mm) ? current->mm->oom_adj : 0; | ||
| 430 | mm->core_state = NULL; | 428 | mm->core_state = NULL; |
| 431 | mm->nr_ptes = 0; | 429 | mm->nr_ptes = 0; |
| 432 | set_mm_counter(mm, file_rss, 0); | 430 | set_mm_counter(mm, file_rss, 0); |
| @@ -816,11 +814,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
| 816 | { | 814 | { |
| 817 | struct signal_struct *sig; | 815 | struct signal_struct *sig; |
| 818 | 816 | ||
| 819 | if (clone_flags & CLONE_THREAD) { | 817 | if (clone_flags & CLONE_THREAD) |
| 820 | atomic_inc(¤t->signal->count); | ||
| 821 | atomic_inc(¤t->signal->live); | ||
| 822 | return 0; | 818 | return 0; |
| 823 | } | ||
| 824 | 819 | ||
| 825 | sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); | 820 | sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); |
| 826 | tsk->signal = sig; | 821 | tsk->signal = sig; |
| @@ -878,16 +873,6 @@ void __cleanup_signal(struct signal_struct *sig) | |||
| 878 | kmem_cache_free(signal_cachep, sig); | 873 | kmem_cache_free(signal_cachep, sig); |
| 879 | } | 874 | } |
| 880 | 875 | ||
| 881 | static void cleanup_signal(struct task_struct *tsk) | ||
| 882 | { | ||
| 883 | struct signal_struct *sig = tsk->signal; | ||
| 884 | |||
| 885 | atomic_dec(&sig->live); | ||
| 886 | |||
| 887 | if (atomic_dec_and_test(&sig->count)) | ||
| 888 | __cleanup_signal(sig); | ||
| 889 | } | ||
| 890 | |||
| 891 | static void copy_flags(unsigned long clone_flags, struct task_struct *p) | 876 | static void copy_flags(unsigned long clone_flags, struct task_struct *p) |
| 892 | { | 877 | { |
| 893 | unsigned long new_flags = p->flags; | 878 | unsigned long new_flags = p->flags; |
| @@ -1240,6 +1225,8 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1240 | } | 1225 | } |
| 1241 | 1226 | ||
| 1242 | if (clone_flags & CLONE_THREAD) { | 1227 | if (clone_flags & CLONE_THREAD) { |
| 1228 | atomic_inc(¤t->signal->count); | ||
| 1229 | atomic_inc(¤t->signal->live); | ||
| 1243 | p->group_leader = current->group_leader; | 1230 | p->group_leader = current->group_leader; |
| 1244 | list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group); | 1231 | list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group); |
| 1245 | } | 1232 | } |
| @@ -1283,7 +1270,8 @@ bad_fork_cleanup_mm: | |||
| 1283 | if (p->mm) | 1270 | if (p->mm) |
| 1284 | mmput(p->mm); | 1271 | mmput(p->mm); |
| 1285 | bad_fork_cleanup_signal: | 1272 | bad_fork_cleanup_signal: |
| 1286 | cleanup_signal(p); | 1273 | if (!(clone_flags & CLONE_THREAD)) |
| 1274 | __cleanup_signal(p->signal); | ||
| 1287 | bad_fork_cleanup_sighand: | 1275 | bad_fork_cleanup_sighand: |
| 1288 | __cleanup_sighand(p->sighand); | 1276 | __cleanup_sighand(p->sighand); |
| 1289 | bad_fork_cleanup_fs: | 1277 | bad_fork_cleanup_fs: |
| @@ -1308,8 +1296,7 @@ bad_fork_cleanup_put_domain: | |||
| 1308 | module_put(task_thread_info(p)->exec_domain->module); | 1296 | module_put(task_thread_info(p)->exec_domain->module); |
| 1309 | bad_fork_cleanup_count: | 1297 | bad_fork_cleanup_count: |
| 1310 | atomic_dec(&p->cred->user->processes); | 1298 | atomic_dec(&p->cred->user->processes); |
| 1311 | put_cred(p->real_cred); | 1299 | exit_creds(p); |
| 1312 | put_cred(p->cred); | ||
| 1313 | bad_fork_free: | 1300 | bad_fork_free: |
| 1314 | free_task(p); | 1301 | free_task(p); |
| 1315 | fork_out: | 1302 | fork_out: |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index d222515a5a06..0ec9ed831737 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
| @@ -607,7 +607,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 607 | */ | 607 | */ |
| 608 | get_task_struct(t); | 608 | get_task_struct(t); |
| 609 | new->thread = t; | 609 | new->thread = t; |
| 610 | wake_up_process(t); | ||
| 611 | } | 610 | } |
| 612 | 611 | ||
| 613 | /* | 612 | /* |
| @@ -690,6 +689,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 690 | (int)(new->flags & IRQF_TRIGGER_MASK)); | 689 | (int)(new->flags & IRQF_TRIGGER_MASK)); |
| 691 | } | 690 | } |
| 692 | 691 | ||
| 692 | new->irq = irq; | ||
| 693 | *old_ptr = new; | 693 | *old_ptr = new; |
| 694 | 694 | ||
| 695 | /* Reset broken irq detection when installing new handler */ | 695 | /* Reset broken irq detection when installing new handler */ |
| @@ -707,7 +707,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
| 707 | 707 | ||
| 708 | spin_unlock_irqrestore(&desc->lock, flags); | 708 | spin_unlock_irqrestore(&desc->lock, flags); |
| 709 | 709 | ||
| 710 | new->irq = irq; | 710 | /* |
| 711 | * Strictly no need to wake it up, but hung_task complains | ||
| 712 | * when no hard interrupt wakes the thread up. | ||
| 713 | */ | ||
| 714 | if (new->thread) | ||
| 715 | wake_up_process(new->thread); | ||
| 716 | |||
| 711 | register_irq_proc(irq, desc); | 717 | register_irq_proc(irq, desc); |
| 712 | new->dir = NULL; | 718 | new->dir = NULL; |
| 713 | register_handler_proc(irq, new); | 719 | register_handler_proc(irq, new); |
diff --git a/kernel/kmod.c b/kernel/kmod.c index 385c31a1bdbf..4e8cae2e9148 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
| @@ -78,6 +78,10 @@ int __request_module(bool wait, const char *fmt, ...) | |||
| 78 | #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */ | 78 | #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */ |
| 79 | static int kmod_loop_msg; | 79 | static int kmod_loop_msg; |
| 80 | 80 | ||
| 81 | ret = security_kernel_module_request(); | ||
| 82 | if (ret) | ||
| 83 | return ret; | ||
| 84 | |||
| 81 | va_start(args, fmt); | 85 | va_start(args, fmt); |
| 82 | ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args); | 86 | ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args); |
| 83 | va_end(args); | 87 | va_end(args); |
| @@ -462,6 +466,7 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, | |||
| 462 | int retval = 0; | 466 | int retval = 0; |
| 463 | 467 | ||
| 464 | BUG_ON(atomic_read(&sub_info->cred->usage) != 1); | 468 | BUG_ON(atomic_read(&sub_info->cred->usage) != 1); |
| 469 | validate_creds(sub_info->cred); | ||
| 465 | 470 | ||
| 466 | helper_lock(); | 471 | helper_lock(); |
| 467 | if (sub_info->path[0] == '\0') | 472 | if (sub_info->path[0] == '\0') |
diff --git a/kernel/module.c b/kernel/module.c index fd1411403558..2d537186191f 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -909,16 +909,18 @@ void __symbol_put(const char *symbol) | |||
| 909 | } | 909 | } |
| 910 | EXPORT_SYMBOL(__symbol_put); | 910 | EXPORT_SYMBOL(__symbol_put); |
| 911 | 911 | ||
| 912 | /* Note this assumes addr is a function, which it currently always is. */ | ||
| 912 | void symbol_put_addr(void *addr) | 913 | void symbol_put_addr(void *addr) |
| 913 | { | 914 | { |
| 914 | struct module *modaddr; | 915 | struct module *modaddr; |
| 916 | unsigned long a = (unsigned long)dereference_function_descriptor(addr); | ||
| 915 | 917 | ||
| 916 | if (core_kernel_text((unsigned long)addr)) | 918 | if (core_kernel_text(a)) |
| 917 | return; | 919 | return; |
| 918 | 920 | ||
| 919 | /* module_text_address is safe here: we're supposed to have reference | 921 | /* module_text_address is safe here: we're supposed to have reference |
| 920 | * to module from symbol_get, so it can't go away. */ | 922 | * to module from symbol_get, so it can't go away. */ |
| 921 | modaddr = __module_text_address((unsigned long)addr); | 923 | modaddr = __module_text_address(a); |
| 922 | BUG_ON(!modaddr); | 924 | BUG_ON(!modaddr); |
| 923 | module_put(modaddr); | 925 | module_put(modaddr); |
| 924 | } | 926 | } |
| @@ -1272,6 +1274,10 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, | |||
| 1272 | struct module_notes_attrs *notes_attrs; | 1274 | struct module_notes_attrs *notes_attrs; |
| 1273 | struct bin_attribute *nattr; | 1275 | struct bin_attribute *nattr; |
| 1274 | 1276 | ||
| 1277 | /* failed to create section attributes, so can't create notes */ | ||
| 1278 | if (!mod->sect_attrs) | ||
| 1279 | return; | ||
| 1280 | |||
| 1275 | /* Count notes sections and allocate structures. */ | 1281 | /* Count notes sections and allocate structures. */ |
| 1276 | notes = 0; | 1282 | notes = 0; |
| 1277 | for (i = 0; i < nsect; i++) | 1283 | for (i = 0; i < nsect; i++) |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 534e20d14d63..d7cbc579fc80 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
| @@ -50,7 +50,7 @@ static atomic_t nr_task_counters __read_mostly; | |||
| 50 | * 1 - disallow cpu counters to unpriv | 50 | * 1 - disallow cpu counters to unpriv |
| 51 | * 2 - disallow kernel profiling to unpriv | 51 | * 2 - disallow kernel profiling to unpriv |
| 52 | */ | 52 | */ |
| 53 | int sysctl_perf_counter_paranoid __read_mostly; | 53 | int sysctl_perf_counter_paranoid __read_mostly = 1; |
| 54 | 54 | ||
| 55 | static inline bool perf_paranoid_cpu(void) | 55 | static inline bool perf_paranoid_cpu(void) |
| 56 | { | 56 | { |
| @@ -1503,10 +1503,21 @@ static void perf_counter_enable_on_exec(struct task_struct *task) | |||
| 1503 | */ | 1503 | */ |
| 1504 | static void __perf_counter_read(void *info) | 1504 | static void __perf_counter_read(void *info) |
| 1505 | { | 1505 | { |
| 1506 | struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context); | ||
| 1506 | struct perf_counter *counter = info; | 1507 | struct perf_counter *counter = info; |
| 1507 | struct perf_counter_context *ctx = counter->ctx; | 1508 | struct perf_counter_context *ctx = counter->ctx; |
| 1508 | unsigned long flags; | 1509 | unsigned long flags; |
| 1509 | 1510 | ||
| 1511 | /* | ||
| 1512 | * If this is a task context, we need to check whether it is | ||
| 1513 | * the current task context of this cpu. If not it has been | ||
| 1514 | * scheduled out before the smp call arrived. In that case | ||
| 1515 | * counter->count would have been updated to a recent sample | ||
| 1516 | * when the counter was scheduled out. | ||
| 1517 | */ | ||
| 1518 | if (ctx->task && cpuctx->task_ctx != ctx) | ||
| 1519 | return; | ||
| 1520 | |||
| 1510 | local_irq_save(flags); | 1521 | local_irq_save(flags); |
| 1511 | if (ctx->is_active) | 1522 | if (ctx->is_active) |
| 1512 | update_context_time(ctx); | 1523 | update_context_time(ctx); |
| @@ -1780,7 +1791,7 @@ static int perf_counter_read_group(struct perf_counter *counter, | |||
| 1780 | size += err; | 1791 | size += err; |
| 1781 | 1792 | ||
| 1782 | list_for_each_entry(sub, &leader->sibling_list, list_entry) { | 1793 | list_for_each_entry(sub, &leader->sibling_list, list_entry) { |
| 1783 | err = perf_counter_read_entry(counter, read_format, | 1794 | err = perf_counter_read_entry(sub, read_format, |
| 1784 | buf + size); | 1795 | buf + size); |
| 1785 | if (err < 0) | 1796 | if (err < 0) |
| 1786 | return err; | 1797 | return err; |
| @@ -2008,6 +2019,10 @@ int perf_counter_task_disable(void) | |||
| 2008 | return 0; | 2019 | return 0; |
| 2009 | } | 2020 | } |
| 2010 | 2021 | ||
| 2022 | #ifndef PERF_COUNTER_INDEX_OFFSET | ||
| 2023 | # define PERF_COUNTER_INDEX_OFFSET 0 | ||
| 2024 | #endif | ||
| 2025 | |||
| 2011 | static int perf_counter_index(struct perf_counter *counter) | 2026 | static int perf_counter_index(struct perf_counter *counter) |
| 2012 | { | 2027 | { |
| 2013 | if (counter->state != PERF_COUNTER_STATE_ACTIVE) | 2028 | if (counter->state != PERF_COUNTER_STATE_ACTIVE) |
| @@ -4051,6 +4066,7 @@ perf_counter_alloc(struct perf_counter_attr *attr, | |||
| 4051 | hwc->sample_period = attr->sample_period; | 4066 | hwc->sample_period = attr->sample_period; |
| 4052 | if (attr->freq && attr->sample_freq) | 4067 | if (attr->freq && attr->sample_freq) |
| 4053 | hwc->sample_period = 1; | 4068 | hwc->sample_period = 1; |
| 4069 | hwc->last_period = hwc->sample_period; | ||
| 4054 | 4070 | ||
| 4055 | atomic64_set(&hwc->period_left, hwc->sample_period); | 4071 | atomic64_set(&hwc->period_left, hwc->sample_period); |
| 4056 | 4072 | ||
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 082c320e4dbf..307c285af59e 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
| @@ -152,7 +152,7 @@ int __ptrace_may_access(struct task_struct *task, unsigned int mode) | |||
| 152 | if (!dumpable && !capable(CAP_SYS_PTRACE)) | 152 | if (!dumpable && !capable(CAP_SYS_PTRACE)) |
| 153 | return -EPERM; | 153 | return -EPERM; |
| 154 | 154 | ||
| 155 | return security_ptrace_may_access(task, mode); | 155 | return security_ptrace_access_check(task, mode); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | bool ptrace_may_access(struct task_struct *task, unsigned int mode) | 158 | bool ptrace_may_access(struct task_struct *task, unsigned int mode) |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 98e02328c67d..71d8dc7f9920 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -1306,10 +1306,10 @@ static struct ctl_table vm_table[] = { | |||
| 1306 | { | 1306 | { |
| 1307 | .ctl_name = CTL_UNNUMBERED, | 1307 | .ctl_name = CTL_UNNUMBERED, |
| 1308 | .procname = "mmap_min_addr", | 1308 | .procname = "mmap_min_addr", |
| 1309 | .data = &mmap_min_addr, | 1309 | .data = &dac_mmap_min_addr, |
| 1310 | .maxlen = sizeof(unsigned long), | 1310 | .maxlen = sizeof(unsigned long), |
| 1311 | .mode = 0644, | 1311 | .mode = 0644, |
| 1312 | .proc_handler = &proc_doulongvec_minmax, | 1312 | .proc_handler = &mmap_min_addr_handler, |
| 1313 | }, | 1313 | }, |
| 1314 | #ifdef CONFIG_NUMA | 1314 | #ifdef CONFIG_NUMA |
| 1315 | { | 1315 | { |
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index a6dcd67b041d..620b58abdc32 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
| @@ -137,11 +137,12 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires, | |||
| 137 | */ | 137 | */ |
| 138 | int clockevents_register_notifier(struct notifier_block *nb) | 138 | int clockevents_register_notifier(struct notifier_block *nb) |
| 139 | { | 139 | { |
| 140 | unsigned long flags; | ||
| 140 | int ret; | 141 | int ret; |
| 141 | 142 | ||
| 142 | spin_lock(&clockevents_lock); | 143 | spin_lock_irqsave(&clockevents_lock, flags); |
| 143 | ret = raw_notifier_chain_register(&clockevents_chain, nb); | 144 | ret = raw_notifier_chain_register(&clockevents_chain, nb); |
| 144 | spin_unlock(&clockevents_lock); | 145 | spin_unlock_irqrestore(&clockevents_lock, flags); |
| 145 | 146 | ||
| 146 | return ret; | 147 | return ret; |
| 147 | } | 148 | } |
| @@ -178,16 +179,18 @@ static void clockevents_notify_released(void) | |||
| 178 | */ | 179 | */ |
| 179 | void clockevents_register_device(struct clock_event_device *dev) | 180 | void clockevents_register_device(struct clock_event_device *dev) |
| 180 | { | 181 | { |
| 182 | unsigned long flags; | ||
| 183 | |||
| 181 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); | 184 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); |
| 182 | BUG_ON(!dev->cpumask); | 185 | BUG_ON(!dev->cpumask); |
| 183 | 186 | ||
| 184 | spin_lock(&clockevents_lock); | 187 | spin_lock_irqsave(&clockevents_lock, flags); |
| 185 | 188 | ||
| 186 | list_add(&dev->list, &clockevent_devices); | 189 | list_add(&dev->list, &clockevent_devices); |
| 187 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); | 190 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); |
| 188 | clockevents_notify_released(); | 191 | clockevents_notify_released(); |
| 189 | 192 | ||
| 190 | spin_unlock(&clockevents_lock); | 193 | spin_unlock_irqrestore(&clockevents_lock, flags); |
| 191 | } | 194 | } |
| 192 | EXPORT_SYMBOL_GPL(clockevents_register_device); | 195 | EXPORT_SYMBOL_GPL(clockevents_register_device); |
| 193 | 196 | ||
| @@ -235,8 +238,9 @@ void clockevents_exchange_device(struct clock_event_device *old, | |||
| 235 | void clockevents_notify(unsigned long reason, void *arg) | 238 | void clockevents_notify(unsigned long reason, void *arg) |
| 236 | { | 239 | { |
| 237 | struct list_head *node, *tmp; | 240 | struct list_head *node, *tmp; |
| 241 | unsigned long flags; | ||
| 238 | 242 | ||
| 239 | spin_lock(&clockevents_lock); | 243 | spin_lock_irqsave(&clockevents_lock, flags); |
| 240 | clockevents_do_notify(reason, arg); | 244 | clockevents_do_notify(reason, arg); |
| 241 | 245 | ||
| 242 | switch (reason) { | 246 | switch (reason) { |
| @@ -251,7 +255,7 @@ void clockevents_notify(unsigned long reason, void *arg) | |||
| 251 | default: | 255 | default: |
| 252 | break; | 256 | break; |
| 253 | } | 257 | } |
| 254 | spin_unlock(&clockevents_lock); | 258 | spin_unlock_irqrestore(&clockevents_lock, flags); |
| 255 | } | 259 | } |
| 256 | EXPORT_SYMBOL_GPL(clockevents_notify); | 260 | EXPORT_SYMBOL_GPL(clockevents_notify); |
| 257 | #endif | 261 | #endif |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 877dbedc3118..c2ec25087a35 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
| @@ -205,11 +205,11 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev) | |||
| 205 | * Powerstate information: The system enters/leaves a state, where | 205 | * Powerstate information: The system enters/leaves a state, where |
| 206 | * affected devices might stop | 206 | * affected devices might stop |
| 207 | */ | 207 | */ |
| 208 | static void tick_do_broadcast_on_off(void *why) | 208 | static void tick_do_broadcast_on_off(unsigned long *reason) |
| 209 | { | 209 | { |
| 210 | struct clock_event_device *bc, *dev; | 210 | struct clock_event_device *bc, *dev; |
| 211 | struct tick_device *td; | 211 | struct tick_device *td; |
| 212 | unsigned long flags, *reason = why; | 212 | unsigned long flags; |
| 213 | int cpu, bc_stopped; | 213 | int cpu, bc_stopped; |
| 214 | 214 | ||
| 215 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 215 | spin_lock_irqsave(&tick_broadcast_lock, flags); |
| @@ -276,8 +276,7 @@ void tick_broadcast_on_off(unsigned long reason, int *oncpu) | |||
| 276 | printk(KERN_ERR "tick-broadcast: ignoring broadcast for " | 276 | printk(KERN_ERR "tick-broadcast: ignoring broadcast for " |
| 277 | "offline CPU #%d\n", *oncpu); | 277 | "offline CPU #%d\n", *oncpu); |
| 278 | else | 278 | else |
| 279 | smp_call_function_single(*oncpu, tick_do_broadcast_on_off, | 279 | tick_do_broadcast_on_off(&reason); |
| 280 | &reason, 1); | ||
| 281 | } | 280 | } |
| 282 | 281 | ||
| 283 | /* | 282 | /* |
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index a999b92a1277..fddd69d16e03 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c | |||
| @@ -286,7 +286,7 @@ static int __init init_timer_list_procfs(void) | |||
| 286 | { | 286 | { |
| 287 | struct proc_dir_entry *pe; | 287 | struct proc_dir_entry *pe; |
| 288 | 288 | ||
| 289 | pe = proc_create("timer_list", 0644, NULL, &timer_list_fops); | 289 | pe = proc_create("timer_list", 0444, NULL, &timer_list_fops); |
| 290 | if (!pe) | 290 | if (!pe) |
| 291 | return -ENOMEM; | 291 | return -ENOMEM; |
| 292 | return 0; | 292 | return 0; |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 1e1d23c26308..25edd5cc5935 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -2278,7 +2278,11 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
| 2278 | read++; | 2278 | read++; |
| 2279 | cnt--; | 2279 | cnt--; |
| 2280 | 2280 | ||
| 2281 | if (!(iter->flags & ~FTRACE_ITER_CONT)) { | 2281 | /* |
| 2282 | * If the parser haven't finished with the last write, | ||
| 2283 | * continue reading the user input without skipping spaces. | ||
| 2284 | */ | ||
| 2285 | if (!(iter->flags & FTRACE_ITER_CONT)) { | ||
| 2282 | /* skip white space */ | 2286 | /* skip white space */ |
| 2283 | while (cnt && isspace(ch)) { | 2287 | while (cnt && isspace(ch)) { |
| 2284 | ret = get_user(ch, ubuf++); | 2288 | ret = get_user(ch, ubuf++); |
| @@ -2288,8 +2292,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
| 2288 | cnt--; | 2292 | cnt--; |
| 2289 | } | 2293 | } |
| 2290 | 2294 | ||
| 2295 | /* only spaces were written */ | ||
| 2291 | if (isspace(ch)) { | 2296 | if (isspace(ch)) { |
| 2292 | file->f_pos += read; | 2297 | *ppos += read; |
| 2293 | ret = read; | 2298 | ret = read; |
| 2294 | goto out; | 2299 | goto out; |
| 2295 | } | 2300 | } |
| @@ -2319,12 +2324,12 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
| 2319 | if (ret) | 2324 | if (ret) |
| 2320 | goto out; | 2325 | goto out; |
| 2321 | iter->buffer_idx = 0; | 2326 | iter->buffer_idx = 0; |
| 2322 | } else | 2327 | } else { |
| 2323 | iter->flags |= FTRACE_ITER_CONT; | 2328 | iter->flags |= FTRACE_ITER_CONT; |
| 2329 | iter->buffer[iter->buffer_idx++] = ch; | ||
| 2330 | } | ||
| 2324 | 2331 | ||
| 2325 | 2332 | *ppos += read; | |
| 2326 | file->f_pos += read; | ||
| 2327 | |||
| 2328 | ret = read; | 2333 | ret = read; |
| 2329 | out: | 2334 | out: |
| 2330 | mutex_unlock(&ftrace_regex_lock); | 2335 | mutex_unlock(&ftrace_regex_lock); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index c22b40f8f576..8c358395d338 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -3896,17 +3896,9 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 3896 | if (ret < 0) | 3896 | if (ret < 0) |
| 3897 | return ret; | 3897 | return ret; |
| 3898 | 3898 | ||
| 3899 | switch (val) { | 3899 | if (val != 0 && val != 1) |
| 3900 | case 0: | ||
| 3901 | trace_flags &= ~(1 << index); | ||
| 3902 | break; | ||
| 3903 | case 1: | ||
| 3904 | trace_flags |= 1 << index; | ||
| 3905 | break; | ||
| 3906 | |||
| 3907 | default: | ||
| 3908 | return -EINVAL; | 3900 | return -EINVAL; |
| 3909 | } | 3901 | set_tracer_flags(1 << index, val); |
| 3910 | 3902 | ||
| 3911 | *ppos += cnt; | 3903 | *ppos += cnt; |
| 3912 | 3904 | ||
