We need the char/misc driver fixes in here as well.
Showing the changes to kernel (8 of 414 files). Show all
Unified · Split
| @@ -471,6 +471,7 @@ static void *cgroup_pidlist_next(struct seq_file *s, void *v, loff_t *pos) · 470 unmodified lines | ||
| 471 | 471 | */ |
| 472 | 472 | p++; |
| 473 | 473 | if (p >= end) { |
| 474 | + (*pos)++; | |
| 474 | 475 | return NULL; |
| 475 | 476 | } else { |
| 476 | 477 | *pos = *p; |
| @@ -782,7 +783,7 @@ void cgroup1_release_agent(struct work_struct *work) · 305 unmodified lines | ||
| 782 | 783 | |
| 783 | 784 | pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); |
| 784 | 785 | agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL); |
| 785 | − if (!pathbuf || !agentbuf) | |
| 786 | + if (!pathbuf || !agentbuf || !strlen(agentbuf)) | |
| 786 | 787 | goto out; |
| 787 | 788 | |
| 788 | 789 | spin_lock_irq(&css_set_lock); |
| @@ -3542,21 +3542,21 @@ static int cpu_stat_show(struct seq_file *seq, void *v) · 3541 unmodified lines | ||
| 3542 | 3542 | static int cgroup_io_pressure_show(struct seq_file *seq, void *v) |
| 3543 | 3543 | { |
| 3544 | 3544 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
| 3545 | − struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3545 | + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3546 | 3546 | |
| 3547 | 3547 | return psi_show(seq, psi, PSI_IO); |
| 3548 | 3548 | } |
| 3549 | 3549 | static int cgroup_memory_pressure_show(struct seq_file *seq, void *v) |
| 3550 | 3550 | { |
| 3551 | 3551 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
| 3552 | − struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3552 | + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3553 | 3553 | |
| 3554 | 3554 | return psi_show(seq, psi, PSI_MEM); |
| 3555 | 3555 | } |
| 3556 | 3556 | static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) |
| 3557 | 3557 | { |
| 3558 | 3558 | struct cgroup *cgrp = seq_css(seq)->cgroup; |
| 3559 | − struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3559 | + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; | |
| 3560 | 3560 | |
| 3561 | 3561 | return psi_show(seq, psi, PSI_CPU); |
| 3562 | 3562 | } |
| @@ -4400,12 +4400,16 @@ static void css_task_iter_advance_css_set(struct css_task_iter *it) · 837 unmodified lines | ||
| 4400 | 4400 | } |
| 4401 | 4401 | } while (!css_set_populated(cset) && list_empty(&cset->dying_tasks)); |
| 4402 | 4402 | |
| 4403 | − if (!list_empty(&cset->tasks)) | |
| 4403 | + if (!list_empty(&cset->tasks)) { | |
| 4404 | 4404 | it->task_pos = cset->tasks.next; |
| 4405 | − else if (!list_empty(&cset->mg_tasks)) | |
| 4405 | + it->cur_tasks_head = &cset->tasks; | |
| 4406 | + } else if (!list_empty(&cset->mg_tasks)) { | |
| 4406 | 4407 | it->task_pos = cset->mg_tasks.next; |
| 4407 | − else | |
| 4408 | + it->cur_tasks_head = &cset->mg_tasks; | |
| 4409 | + } else { | |
| 4408 | 4410 | it->task_pos = cset->dying_tasks.next; |
| 4411 | + it->cur_tasks_head = &cset->dying_tasks; | |
| 4412 | + } | |
| 4409 | 4413 | |
| 4410 | 4414 | it->tasks_head = &cset->tasks; |
| 4411 | 4415 | it->mg_tasks_head = &cset->mg_tasks; |
| @@ -4463,10 +4467,14 @@ repeat: · 51 unmodified lines | ||
| 4463 | 4467 | else |
| 4464 | 4468 | it->task_pos = it->task_pos->next; |
| 4465 | 4469 | |
| 4466 | − if (it->task_pos == it->tasks_head) | |
| 4470 | + if (it->task_pos == it->tasks_head) { | |
| 4467 | 4471 | it->task_pos = it->mg_tasks_head->next; |
| 4468 | − if (it->task_pos == it->mg_tasks_head) | |
| 4472 | + it->cur_tasks_head = it->mg_tasks_head; | |
| 4473 | + } | |
| 4474 | + if (it->task_pos == it->mg_tasks_head) { | |
| 4469 | 4475 | it->task_pos = it->dying_tasks_head->next; |
| 4476 | + it->cur_tasks_head = it->dying_tasks_head; | |
| 4477 | + } | |
| 4470 | 4478 | if (it->task_pos == it->dying_tasks_head) |
| 4471 | 4479 | css_task_iter_advance_css_set(it); |
| 4472 | 4480 | } else { |
| @@ -4485,11 +4493,12 @@ repeat: · 12 unmodified lines | ||
| 4485 | 4493 | goto repeat; |
| 4486 | 4494 | |
| 4487 | 4495 | /* and dying leaders w/o live member threads */ |
| 4488 | − if (!atomic_read(&task->signal->live)) | |
| 4496 | + if (it->cur_tasks_head == it->dying_tasks_head && | |
| 4497 | + !atomic_read(&task->signal->live)) | |
| 4489 | 4498 | goto repeat; |
| 4490 | 4499 | } else { |
| 4491 | 4500 | /* skip all dying ones */ |
| 4492 | − if (task->flags & PF_EXITING) | |
| 4501 | + if (it->cur_tasks_head == it->dying_tasks_head) | |
| 4493 | 4502 | goto repeat; |
| 4494 | 4503 | } |
| 4495 | 4504 | } |
| @@ -4595,6 +4604,9 @@ static void *cgroup_procs_next(struct seq_file *s, void *v, loff_t *pos) · 99 unmodified lines | ||
| 4595 | 4604 | struct kernfs_open_file *of = s->private; |
| 4596 | 4605 | struct css_task_iter *it = of->priv; |
| 4597 | 4606 | |
| 4607 | + if (pos) | |
| 4608 | + (*pos)++; | |
| 4609 | + | |
| 4598 | 4610 | return css_task_iter_next(it); |
| 4599 | 4611 | } |
| 4600 | 4612 | |
| @@ -4610,7 +4622,7 @@ static void *__cgroup_procs_start(struct seq_file *s, loff_t *pos, · 9 unmodified lines | ||
| 4610 | 4622 | * from position 0, so we can simply keep iterating on !0 *pos. |
| 4611 | 4623 | */ |
| 4612 | 4624 | if (!it) { |
| 4613 | − if (WARN_ON_ONCE((*pos)++)) | |
| 4625 | + if (WARN_ON_ONCE((*pos))) | |
| 4614 | 4626 | return ERR_PTR(-EINVAL); |
| 4615 | 4627 | |
| 4616 | 4628 | it = kzalloc(sizeof(*it), GFP_KERNEL); |
| @@ -4618,10 +4630,11 @@ static void *__cgroup_procs_start(struct seq_file *s, loff_t *pos, · 1 unmodified line | ||
| 4618 | 4630 | return ERR_PTR(-ENOMEM); |
| 4619 | 4631 | of->priv = it; |
| 4620 | 4632 | css_task_iter_start(&cgrp->self, iter_flags, it); |
| 4621 | − } else if (!(*pos)++) { | |
| 4633 | + } else if (!(*pos)) { | |
| 4622 | 4634 | css_task_iter_end(it); |
| 4623 | 4635 | css_task_iter_start(&cgrp->self, iter_flags, it); |
| 4624 | − } | |
| 4636 | + } else | |
| 4637 | + return it->cur_task; | |
| 4625 | 4638 | |
| 4626 | 4639 | return cgroup_procs_next(s, NULL, NULL); |
| 4627 | 4640 | } |
| @@ -6258,6 +6271,10 @@ void cgroup_sk_alloc(struct sock_cgroup_data *skcd) · 1630 unmodified lines | ||
| 6258 | 6271 | return; |
| 6259 | 6272 | } |
| 6260 | 6273 | |
| 6274 | + /* Don't associate the sock with unrelated interrupted task's cgroup. */ | |
| 6275 | + if (in_interrupt()) | |
| 6276 | + return; | |
| 6277 | + | |
| 6261 | 6278 | rcu_read_lock(); |
| 6262 | 6279 | |
| 6263 | 6280 | while (true) { |
| @@ -385,9 +385,9 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb) · 384 unmodified lines | ||
| 385 | 385 | */ |
| 386 | 386 | static struct futex_hash_bucket *hash_futex(union futex_key *key) |
| 387 | 387 | { |
| 388 | − u32 hash = jhash2((u32*)&key->both.word, | |
| 389 | − (sizeof(key->both.word)+sizeof(key->both.ptr))/4, | |
| 388 | + u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4, | |
| 390 | 389 | key->both.offset); |
| 390 | + | |
| 391 | 391 | return &futex_queues[hash & (futex_hashsize - 1)]; |
| 392 | 392 | } |
| 393 | 393 | |
| @@ -429,7 +429,7 @@ static void get_futex_key_refs(union futex_key *key) · 35 unmodified lines | ||
| 429 | 429 | |
| 430 | 430 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { |
| 431 | 431 | case FUT_OFF_INODE: |
| 432 | − ihold(key->shared.inode); /* implies smp_mb(); (B) */ | |
| 432 | + smp_mb(); /* explicit smp_mb(); (B) */ | |
| 433 | 433 | break; |
| 434 | 434 | case FUT_OFF_MMSHARED: |
| 435 | 435 | futex_get_mm(key); /* implies smp_mb(); (B) */ |
| @@ -463,7 +463,6 @@ static void drop_futex_key_refs(union futex_key *key) · 27 unmodified lines | ||
| 463 | 463 | |
| 464 | 464 | switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { |
| 465 | 465 | case FUT_OFF_INODE: |
| 466 | − iput(key->shared.inode); | |
| 467 | 466 | break; |
| 468 | 467 | case FUT_OFF_MMSHARED: |
| 469 | 468 | mmdrop(key->private.mm); |
| @@ -505,6 +504,46 @@ futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout, · 35 unmodified lines | ||
| 505 | 504 | return timeout; |
| 506 | 505 | } |
| 507 | 506 | |
| 507 | +/* | |
| 508 | + * Generate a machine wide unique identifier for this inode. | |
| 509 | + * | |
| 510 | + * This relies on u64 not wrapping in the life-time of the machine; which with | |
| 511 | + * 1ns resolution means almost 585 years. | |
| 512 | + * | |
| 513 | + * This further relies on the fact that a well formed program will not unmap | |
| 514 | + * the file while it has a (shared) futex waiting on it. This mapping will have | |
| 515 | + * a file reference which pins the mount and inode. | |
| 516 | + * | |
| 517 | + * If for some reason an inode gets evicted and read back in again, it will get | |
| 518 | + * a new sequence number and will _NOT_ match, even though it is the exact same | |
| 519 | + * file. | |
| 520 | + * | |
| 521 | + * It is important that match_futex() will never have a false-positive, esp. | |
| 522 | + * for PI futexes that can mess up the state. The above argues that false-negatives | |
| 523 | + * are only possible for malformed programs. | |
| 524 | + */ | |
| 525 | +static u64 get_inode_sequence_number(struct inode *inode) | |
| 526 | +{ | |
| 527 | + static atomic64_t i_seq; | |
| 528 | + u64 old; | |
| 529 | + | |
| 530 | + /* Does the inode already have a sequence number? */ | |
| 531 | + old = atomic64_read(&inode->i_sequence); | |
| 532 | + if (likely(old)) | |
| 533 | + return old; | |
| 534 | + | |
| 535 | + for (;;) { | |
| 536 | + u64 new = atomic64_add_return(1, &i_seq); | |
| 537 | + if (WARN_ON_ONCE(!new)) | |
| 538 | + continue; | |
| 539 | + | |
| 540 | + old = atomic64_cmpxchg_relaxed(&inode->i_sequence, 0, new); | |
| 541 | + if (old) | |
| 542 | + return old; | |
| 543 | + return new; | |
| 544 | + } | |
| 545 | +} | |
| 546 | + | |
| 508 | 547 | /** |
| 509 | 548 | * get_futex_key() - Get parameters which are the keys for a futex |
| 510 | 549 | * @uaddr: virtual address of the futex |
| @@ -517,9 +556,15 @@ futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout, · 6 unmodified lines | ||
| 517 | 556 | * |
| 518 | 557 | * The key words are stored in @key on success. |
| 519 | 558 | * |
| 520 | − * For shared mappings, it's (page->index, file_inode(vma->vm_file), | |
| 521 | − * offset_within_page). For private mappings, it's (uaddr, current->mm). | |
| 522 | − * We can usually work out the index without swapping in the page. | |
| 559 | + * For shared mappings (when @fshared), the key is: | |
| 560 | + * ( inode->i_sequence, page->index, offset_within_page ) | |
| 561 | + * [ also see get_inode_sequence_number() ] | |
| 562 | + * | |
| 563 | + * For private mappings (or when !@fshared), the key is: | |
| 564 | + * ( current->mm, address, 0 ) | |
| 565 | + * | |
| 566 | + * This allows (cross process, where applicable) identification of the futex | |
| 567 | + * without keeping the page pinned for the duration of the FUTEX_WAIT. | |
| 523 | 568 | * |
| 524 | 569 | * lock_page() might sleep, the caller should not hold a spinlock. |
| 525 | 570 | */ |
| @@ -659,8 +704,6 @@ again: · 133 unmodified lines | ||
| 659 | 704 | key->private.mm = mm; |
| 660 | 705 | key->private.address = address; |
| 661 | 706 | |
| 662 | − get_futex_key_refs(key); /* implies smp_mb(); (B) */ | |
| 663 | − | |
| 664 | 707 | } else { |
| 665 | 708 | struct inode *inode; |
| 666 | 709 | |
| @@ -692,40 +735,14 @@ again: · 25 unmodified lines | ||
| 692 | 735 | goto again; |
| 693 | 736 | } |
| 694 | 737 | |
| 695 | − /* | |
| 696 | − * Take a reference unless it is about to be freed. Previously | |
| 697 | − * this reference was taken by ihold under the page lock | |
| 698 | − * pinning the inode in place so i_lock was unnecessary. The | |
| 699 | − * only way for this check to fail is if the inode was | |
| 700 | − * truncated in parallel which is almost certainly an | |
| 701 | − * application bug. In such a case, just retry. | |
| 702 | − * | |
| 703 | − * We are not calling into get_futex_key_refs() in file-backed | |
| 704 | − * cases, therefore a successful atomic_inc return below will | |
| 705 | − * guarantee that get_futex_key() will still imply smp_mb(); (B). | |
| 706 | − */ | |
| 707 | − if (!atomic_inc_not_zero(&inode->i_count)) { | |
| 708 | − rcu_read_unlock(); | |
| 709 | − put_page(page); | |
| 710 | − | |
| 711 | − goto again; | |
| 712 | − } | |
| 713 | − | |
| 714 | − /* Should be impossible but lets be paranoid for now */ | |
| 715 | − if (WARN_ON_ONCE(inode->i_mapping != mapping)) { | |
| 716 | − err = -EFAULT; | |
| 717 | − rcu_read_unlock(); | |
| 718 | − iput(inode); | |
| 719 | − | |
| 720 | − goto out; | |
| 721 | − } | |
| 722 | − | |
| 723 | 738 | key->both.offset |= FUT_OFF_INODE; /* inode-based key */ |
| 724 | − key->shared.inode = inode; | |
| 739 | + key->shared.i_seq = get_inode_sequence_number(inode); | |
| 725 | 740 | key->shared.pgoff = basepage_index(tail); |
| 726 | 741 | rcu_read_unlock(); |
| 727 | 742 | } |
| 728 | 743 | |
| 744 | + get_futex_key_refs(key); /* implies smp_mb(); (B) */ | |
| 745 | + | |
| 729 | 746 | out: |
| 730 | 747 | put_page(page); |
| 731 | 748 | return err; |
| @@ -519,7 +519,7 @@ NOKPROBE_SYMBOL(notify_die); · 518 unmodified lines | ||
| 519 | 519 | |
| 520 | 520 | int register_die_notifier(struct notifier_block *nb) |
| 521 | 521 | { |
| 522 | − vmalloc_sync_all(); | |
| 522 | + vmalloc_sync_mappings(); | |
| 523 | 523 | return atomic_notifier_chain_register(&die_chain, nb); |
| 524 | 524 | } |
| 525 | 525 | EXPORT_SYMBOL_GPL(register_die_notifier); |
| @@ -247,6 +247,16 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, · 246 unmodified lines | ||
| 247 | 247 | tmp = tmp->parent; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | + /* | |
| 251 | + * ENOMEM is not the most obvious choice especially for the case | |
| 252 | + * where the child subreaper has already exited and the pid | |
| 253 | + * namespace denies the creation of any new processes. But ENOMEM | |
| 254 | + * is what we have exposed to userspace for a long time and it is | |
| 255 | + * documented behavior for pid namespaces. So we can't easily | |
| 256 | + * change it even if there were an error code better suited. | |
| 257 | + */ | |
| 258 | + retval = -ENOMEM; | |
| 259 | + | |
| 250 | 260 | if (unlikely(is_child_reaper(pid))) { |
| 251 | 261 | if (pid_ns_prepare_proc(ns)) |
| 252 | 262 | goto out_free; |
| @@ -47,6 +47,7 @@ · 46 unmodified lines | ||
| 47 | 47 | #include <linux/syscalls.h> |
| 48 | 48 | #include <linux/kprobes.h> |
| 49 | 49 | #include <linux/user_namespace.h> |
| 50 | +#include <linux/time_namespace.h> | |
| 50 | 51 | #include <linux/binfmts.h> |
| 51 | 52 | |
| 52 | 53 | #include <linux/sched.h> |
| @@ -2546,6 +2547,7 @@ static int do_sysinfo(struct sysinfo *info) · 2493 unmodified lines | ||
| 2546 | 2547 | memset(info, 0, sizeof(struct sysinfo)); |
| 2547 | 2548 | |
| 2548 | 2549 | ktime_get_boottime_ts64(&tp); |
| 2550 | + timens_add_boottime(&tp); | |
| 2549 | 2551 | info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0); |
| 2550 | 2552 | |
| 2551 | 2553 | get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT); |
| @@ -1547,6 +1547,8 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end) · 1546 unmodified lines | ||
| 1547 | 1547 | rec = bsearch(&key, pg->records, pg->index, |
| 1548 | 1548 | sizeof(struct dyn_ftrace), |
| 1549 | 1549 | ftrace_cmp_recs); |
| 1550 | + if (rec) | |
| 1551 | + break; | |
| 1550 | 1552 | } |
| 1551 | 1553 | return rec; |
| 1552 | 1554 | } |
| @@ -1411,14 +1411,16 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, · 1410 unmodified lines | ||
| 1411 | 1411 | return; |
| 1412 | 1412 | rcu_read_lock(); |
| 1413 | 1413 | retry: |
| 1414 | − if (req_cpu == WORK_CPU_UNBOUND) | |
| 1415 | − cpu = wq_select_unbound_cpu(raw_smp_processor_id()); | |
| 1416 | − | |
| 1417 | 1414 | /* pwq which will be used unless @work is executing elsewhere */ |
| 1418 | − if (!(wq->flags & WQ_UNBOUND)) | |
| 1419 | − pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); | |
| 1420 | − else | |
| 1415 | + if (wq->flags & WQ_UNBOUND) { | |
| 1416 | + if (req_cpu == WORK_CPU_UNBOUND) | |
| 1417 | + cpu = wq_select_unbound_cpu(raw_smp_processor_id()); | |
| 1421 | 1418 | pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu)); |
| 1419 | + } else { | |
| 1420 | + if (req_cpu == WORK_CPU_UNBOUND) | |
| 1421 | + cpu = raw_smp_processor_id(); | |
| 1422 | + pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); | |
| 1423 | + } | |
| 1422 | 1424 | |
| 1423 | 1425 | /* |
| 1424 | 1426 | * If @work was previously on a different pool, it might still be |