aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile6
-rw-r--r--kernel/audit.c49
-rw-r--r--kernel/audit.h3
-rw-r--r--kernel/audit_tree.c92
-rw-r--r--kernel/audit_watch.c14
-rw-r--r--kernel/auditsc.c15
-rw-r--r--kernel/bpf/core.c12
-rw-r--r--kernel/events/core.c41
-rw-r--r--kernel/irq/dummychip.c1
-rw-r--r--kernel/kexec.c2
-rw-r--r--kernel/locking/rtmutex.c12
-rw-r--r--kernel/module.c9
-rw-r--r--kernel/params.c4
-rw-r--r--kernel/printk/printk.c53
-rw-r--r--kernel/rcu/tree.c16
-rw-r--r--kernel/relay.c4
-rw-r--r--kernel/sched/core.c69
-rw-r--r--kernel/sched/idle.c16
-rw-r--r--kernel/time/clockevents.c8
-rw-r--r--kernel/trace/trace.c2
-rw-r--r--kernel/trace/trace_events.c19
-rw-r--r--kernel/trace/trace_functions_graph.c8
-rw-r--r--kernel/trace/trace_output.c3
-rw-r--r--kernel/trace/trace_uprobe.c2
-rw-r--r--kernel/watchdog.c20
25 files changed, 265 insertions, 215 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 0f8f8b0bc1bf..60c302cfb4d3 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -197,9 +197,9 @@ x509.genkey:
197 @echo >>x509.genkey "x509_extensions = myexts" 197 @echo >>x509.genkey "x509_extensions = myexts"
198 @echo >>x509.genkey 198 @echo >>x509.genkey
199 @echo >>x509.genkey "[ req_distinguished_name ]" 199 @echo >>x509.genkey "[ req_distinguished_name ]"
200 @echo >>x509.genkey "O = Magrathea" 200 @echo >>x509.genkey "#O = Unspecified company"
201 @echo >>x509.genkey "CN = Glacier signing key" 201 @echo >>x509.genkey "CN = Build time autogenerated kernel key"
202 @echo >>x509.genkey "emailAddress = slartibartfast@magrathea.h2g2" 202 @echo >>x509.genkey "#emailAddress = unspecified.user@unspecified.company"
203 @echo >>x509.genkey 203 @echo >>x509.genkey
204 @echo >>x509.genkey "[ myexts ]" 204 @echo >>x509.genkey "[ myexts ]"
205 @echo >>x509.genkey "basicConstraints=critical,CA:FALSE" 205 @echo >>x509.genkey "basicConstraints=critical,CA:FALSE"
diff --git a/kernel/audit.c b/kernel/audit.c
index 72ab759a0b43..1c13e4267de6 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -43,6 +43,7 @@
43 43
44#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 44#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 45
46#include <linux/file.h>
46#include <linux/init.h> 47#include <linux/init.h>
47#include <linux/types.h> 48#include <linux/types.h>
48#include <linux/atomic.h> 49#include <linux/atomic.h>
@@ -107,6 +108,7 @@ static u32 audit_rate_limit;
107 * When set to zero, this means unlimited. */ 108 * When set to zero, this means unlimited. */
108static u32 audit_backlog_limit = 64; 109static u32 audit_backlog_limit = 64;
109#define AUDIT_BACKLOG_WAIT_TIME (60 * HZ) 110#define AUDIT_BACKLOG_WAIT_TIME (60 * HZ)
111static u32 audit_backlog_wait_time_master = AUDIT_BACKLOG_WAIT_TIME;
110static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; 112static u32 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME;
111static u32 audit_backlog_wait_overflow = 0; 113static u32 audit_backlog_wait_overflow = 0;
112 114
@@ -338,13 +340,13 @@ static int audit_set_backlog_limit(u32 limit)
338static int audit_set_backlog_wait_time(u32 timeout) 340static int audit_set_backlog_wait_time(u32 timeout)
339{ 341{
340 return audit_do_config_change("audit_backlog_wait_time", 342 return audit_do_config_change("audit_backlog_wait_time",
341 &audit_backlog_wait_time, timeout); 343 &audit_backlog_wait_time_master, timeout);
342} 344}
343 345
344static int audit_set_enabled(u32 state) 346static int audit_set_enabled(u32 state)
345{ 347{
346 int rc; 348 int rc;
347 if (state < AUDIT_OFF || state > AUDIT_LOCKED) 349 if (state > AUDIT_LOCKED)
348 return -EINVAL; 350 return -EINVAL;
349 351
350 rc = audit_do_config_change("audit_enabled", &audit_enabled, state); 352 rc = audit_do_config_change("audit_enabled", &audit_enabled, state);
@@ -663,7 +665,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
663 case AUDIT_MAKE_EQUIV: 665 case AUDIT_MAKE_EQUIV:
664 /* Only support auditd and auditctl in initial pid namespace 666 /* Only support auditd and auditctl in initial pid namespace
665 * for now. */ 667 * for now. */
666 if ((task_active_pid_ns(current) != &init_pid_ns)) 668 if (task_active_pid_ns(current) != &init_pid_ns)
667 return -EPERM; 669 return -EPERM;
668 670
669 if (!netlink_capable(skb, CAP_AUDIT_CONTROL)) 671 if (!netlink_capable(skb, CAP_AUDIT_CONTROL))
@@ -834,7 +836,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
834 s.lost = atomic_read(&audit_lost); 836 s.lost = atomic_read(&audit_lost);
835 s.backlog = skb_queue_len(&audit_skb_queue); 837 s.backlog = skb_queue_len(&audit_skb_queue);
836 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL; 838 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL;
837 s.backlog_wait_time = audit_backlog_wait_time; 839 s.backlog_wait_time = audit_backlog_wait_time_master;
838 audit_send_reply(skb, seq, AUDIT_GET, 0, 0, &s, sizeof(s)); 840 audit_send_reply(skb, seq, AUDIT_GET, 0, 0, &s, sizeof(s));
839 break; 841 break;
840 } 842 }
@@ -877,8 +879,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
877 if (s.mask & AUDIT_STATUS_BACKLOG_WAIT_TIME) { 879 if (s.mask & AUDIT_STATUS_BACKLOG_WAIT_TIME) {
878 if (sizeof(s) > (size_t)nlh->nlmsg_len) 880 if (sizeof(s) > (size_t)nlh->nlmsg_len)
879 return -EINVAL; 881 return -EINVAL;
880 if (s.backlog_wait_time < 0 || 882 if (s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
881 s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
882 return -EINVAL; 883 return -EINVAL;
883 err = audit_set_backlog_wait_time(s.backlog_wait_time); 884 err = audit_set_backlog_wait_time(s.backlog_wait_time);
884 if (err < 0) 885 if (err < 0)
@@ -1385,7 +1386,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
1385 return NULL; 1386 return NULL;
1386 } 1387 }
1387 1388
1388 audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME; 1389 if (!reserve)
1390 audit_backlog_wait_time = audit_backlog_wait_time_master;
1389 1391
1390 ab = audit_buffer_alloc(ctx, gfp_mask, type); 1392 ab = audit_buffer_alloc(ctx, gfp_mask, type);
1391 if (!ab) { 1393 if (!ab) {
@@ -1759,7 +1761,7 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
1759 } else 1761 } else
1760 audit_log_format(ab, " name=(null)"); 1762 audit_log_format(ab, " name=(null)");
1761 1763
1762 if (n->ino != (unsigned long)-1) { 1764 if (n->ino != (unsigned long)-1)
1763 audit_log_format(ab, " inode=%lu" 1765 audit_log_format(ab, " inode=%lu"
1764 " dev=%02x:%02x mode=%#ho" 1766 " dev=%02x:%02x mode=%#ho"
1765 " ouid=%u ogid=%u rdev=%02x:%02x", 1767 " ouid=%u ogid=%u rdev=%02x:%02x",
@@ -1771,7 +1773,6 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
1771 from_kgid(&init_user_ns, n->gid), 1773 from_kgid(&init_user_ns, n->gid),
1772 MAJOR(n->rdev), 1774 MAJOR(n->rdev),
1773 MINOR(n->rdev)); 1775 MINOR(n->rdev));
1774 }
1775 if (n->osid != 0) { 1776 if (n->osid != 0) {
1776 char *ctx = NULL; 1777 char *ctx = NULL;
1777 u32 len; 1778 u32 len;
@@ -1838,11 +1839,29 @@ error_path:
1838} 1839}
1839EXPORT_SYMBOL(audit_log_task_context); 1840EXPORT_SYMBOL(audit_log_task_context);
1840 1841
1842void audit_log_d_path_exe(struct audit_buffer *ab,
1843 struct mm_struct *mm)
1844{
1845 struct file *exe_file;
1846
1847 if (!mm)
1848 goto out_null;
1849
1850 exe_file = get_mm_exe_file(mm);
1851 if (!exe_file)
1852 goto out_null;
1853
1854 audit_log_d_path(ab, " exe=", &exe_file->f_path);
1855 fput(exe_file);
1856 return;
1857out_null:
1858 audit_log_format(ab, " exe=(null)");
1859}
1860
1841void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) 1861void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1842{ 1862{
1843 const struct cred *cred; 1863 const struct cred *cred;
1844 char comm[sizeof(tsk->comm)]; 1864 char comm[sizeof(tsk->comm)];
1845 struct mm_struct *mm = tsk->mm;
1846 char *tty; 1865 char *tty;
1847 1866
1848 if (!ab) 1867 if (!ab)
@@ -1878,13 +1897,7 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1878 audit_log_format(ab, " comm="); 1897 audit_log_format(ab, " comm=");
1879 audit_log_untrustedstring(ab, get_task_comm(comm, tsk)); 1898 audit_log_untrustedstring(ab, get_task_comm(comm, tsk));
1880 1899
1881 if (mm) { 1900 audit_log_d_path_exe(ab, tsk->mm);
1882 down_read(&mm->mmap_sem);
1883 if (mm->exe_file)
1884 audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
1885 up_read(&mm->mmap_sem);
1886 } else
1887 audit_log_format(ab, " exe=(null)");
1888 audit_log_task_context(ab); 1901 audit_log_task_context(ab);
1889} 1902}
1890EXPORT_SYMBOL(audit_log_task_info); 1903EXPORT_SYMBOL(audit_log_task_info);
@@ -1915,7 +1928,7 @@ void audit_log_link_denied(const char *operation, struct path *link)
1915 1928
1916 /* Generate AUDIT_PATH record with object. */ 1929 /* Generate AUDIT_PATH record with object. */
1917 name->type = AUDIT_TYPE_NORMAL; 1930 name->type = AUDIT_TYPE_NORMAL;
1918 audit_copy_inode(name, link->dentry, link->dentry->d_inode); 1931 audit_copy_inode(name, link->dentry, d_backing_inode(link->dentry));
1919 audit_log_name(current->audit_context, name, link, 0, NULL); 1932 audit_log_name(current->audit_context, name, link, 0, NULL);
1920out: 1933out:
1921 kfree(name); 1934 kfree(name);
diff --git a/kernel/audit.h b/kernel/audit.h
index 1caa0d345d90..d641f9bb3ed0 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -257,6 +257,9 @@ extern struct list_head audit_filter_list[];
257 257
258extern struct audit_entry *audit_dupe_rule(struct audit_krule *old); 258extern struct audit_entry *audit_dupe_rule(struct audit_krule *old);
259 259
260extern void audit_log_d_path_exe(struct audit_buffer *ab,
261 struct mm_struct *mm);
262
260/* audit watch functions */ 263/* audit watch functions */
261#ifdef CONFIG_AUDIT_WATCH 264#ifdef CONFIG_AUDIT_WATCH
262extern void audit_put_watch(struct audit_watch *watch); 265extern void audit_put_watch(struct audit_watch *watch);
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 2e0c97427b33..b0f9877273fc 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -37,6 +37,7 @@ struct audit_chunk {
37 37
38static LIST_HEAD(tree_list); 38static LIST_HEAD(tree_list);
39static LIST_HEAD(prune_list); 39static LIST_HEAD(prune_list);
40static struct task_struct *prune_thread;
40 41
41/* 42/*
42 * One struct chunk is attached to each inode of interest. 43 * One struct chunk is attached to each inode of interest.
@@ -576,7 +577,7 @@ int audit_remove_tree_rule(struct audit_krule *rule)
576 577
577static int compare_root(struct vfsmount *mnt, void *arg) 578static int compare_root(struct vfsmount *mnt, void *arg)
578{ 579{
579 return mnt->mnt_root->d_inode == arg; 580 return d_backing_inode(mnt->mnt_root) == arg;
580} 581}
581 582
582void audit_trim_trees(void) 583void audit_trim_trees(void)
@@ -648,7 +649,58 @@ void audit_put_tree(struct audit_tree *tree)
648 649
649static int tag_mount(struct vfsmount *mnt, void *arg) 650static int tag_mount(struct vfsmount *mnt, void *arg)
650{ 651{
651 return tag_chunk(mnt->mnt_root->d_inode, arg); 652 return tag_chunk(d_backing_inode(mnt->mnt_root), arg);
653}
654
655/*
656 * That gets run when evict_chunk() ends up needing to kill audit_tree.
657 * Runs from a separate thread.
658 */
659static int prune_tree_thread(void *unused)
660{
661 for (;;) {
662 set_current_state(TASK_INTERRUPTIBLE);
663 if (list_empty(&prune_list))
664 schedule();
665 __set_current_state(TASK_RUNNING);
666
667 mutex_lock(&audit_cmd_mutex);
668 mutex_lock(&audit_filter_mutex);
669
670 while (!list_empty(&prune_list)) {
671 struct audit_tree *victim;
672
673 victim = list_entry(prune_list.next,
674 struct audit_tree, list);
675 list_del_init(&victim->list);
676
677 mutex_unlock(&audit_filter_mutex);
678
679 prune_one(victim);
680
681 mutex_lock(&audit_filter_mutex);
682 }
683
684 mutex_unlock(&audit_filter_mutex);
685 mutex_unlock(&audit_cmd_mutex);
686 }
687 return 0;
688}
689
690static int audit_launch_prune(void)
691{
692 if (prune_thread)
693 return 0;
694 prune_thread = kthread_create(prune_tree_thread, NULL,
695 "audit_prune_tree");
696 if (IS_ERR(prune_thread)) {
697 pr_err("cannot start thread audit_prune_tree");
698 prune_thread = NULL;
699 return -ENOMEM;
700 } else {
701 wake_up_process(prune_thread);
702 return 0;
703 }
652} 704}
653 705
654/* called with audit_filter_mutex */ 706/* called with audit_filter_mutex */
@@ -674,6 +726,12 @@ int audit_add_tree_rule(struct audit_krule *rule)
674 /* do not set rule->tree yet */ 726 /* do not set rule->tree yet */
675 mutex_unlock(&audit_filter_mutex); 727 mutex_unlock(&audit_filter_mutex);
676 728
729 if (unlikely(!prune_thread)) {
730 err = audit_launch_prune();
731 if (err)
732 goto Err;
733 }
734
677 err = kern_path(tree->pathname, 0, &path); 735 err = kern_path(tree->pathname, 0, &path);
678 if (err) 736 if (err)
679 goto Err; 737 goto Err;
@@ -811,36 +869,10 @@ int audit_tag_tree(char *old, char *new)
811 return failed; 869 return failed;
812} 870}
813 871
814/*
815 * That gets run when evict_chunk() ends up needing to kill audit_tree.
816 * Runs from a separate thread.
817 */
818static int prune_tree_thread(void *unused)
819{
820 mutex_lock(&audit_cmd_mutex);
821 mutex_lock(&audit_filter_mutex);
822
823 while (!list_empty(&prune_list)) {
824 struct audit_tree *victim;
825
826 victim = list_entry(prune_list.next, struct audit_tree, list);
827 list_del_init(&victim->list);
828
829 mutex_unlock(&audit_filter_mutex);
830
831 prune_one(victim);
832
833 mutex_lock(&audit_filter_mutex);
834 }
835
836 mutex_unlock(&audit_filter_mutex);
837 mutex_unlock(&audit_cmd_mutex);
838 return 0;
839}
840 872
841static void audit_schedule_prune(void) 873static void audit_schedule_prune(void)
842{ 874{
843 kthread_run(prune_tree_thread, NULL, "audit_prune_tree"); 875 wake_up_process(prune_thread);
844} 876}
845 877
846/* 878/*
@@ -907,9 +939,9 @@ static void evict_chunk(struct audit_chunk *chunk)
907 for (n = 0; n < chunk->count; n++) 939 for (n = 0; n < chunk->count; n++)
908 list_del_init(&chunk->owners[n].list); 940 list_del_init(&chunk->owners[n].list);
909 spin_unlock(&hash_lock); 941 spin_unlock(&hash_lock);
942 mutex_unlock(&audit_filter_mutex);
910 if (need_prune) 943 if (need_prune)
911 audit_schedule_prune(); 944 audit_schedule_prune();
912 mutex_unlock(&audit_filter_mutex);
913} 945}
914 946
915static int audit_tree_handle_event(struct fsnotify_group *group, 947static int audit_tree_handle_event(struct fsnotify_group *group,
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index ad9c1682f616..6e30024d9aac 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -146,7 +146,7 @@ int audit_watch_compare(struct audit_watch *watch, unsigned long ino, dev_t dev)
146/* Initialize a parent watch entry. */ 146/* Initialize a parent watch entry. */
147static struct audit_parent *audit_init_parent(struct path *path) 147static struct audit_parent *audit_init_parent(struct path *path)
148{ 148{
149 struct inode *inode = path->dentry->d_inode; 149 struct inode *inode = d_backing_inode(path->dentry);
150 struct audit_parent *parent; 150 struct audit_parent *parent;
151 int ret; 151 int ret;
152 152
@@ -361,11 +361,11 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent)
361 struct dentry *d = kern_path_locked(watch->path, parent); 361 struct dentry *d = kern_path_locked(watch->path, parent);
362 if (IS_ERR(d)) 362 if (IS_ERR(d))
363 return PTR_ERR(d); 363 return PTR_ERR(d);
364 mutex_unlock(&parent->dentry->d_inode->i_mutex); 364 mutex_unlock(&d_backing_inode(parent->dentry)->i_mutex);
365 if (d->d_inode) { 365 if (d_is_positive(d)) {
366 /* update watch filter fields */ 366 /* update watch filter fields */
367 watch->dev = d->d_inode->i_sb->s_dev; 367 watch->dev = d_backing_inode(d)->i_sb->s_dev;
368 watch->ino = d->d_inode->i_ino; 368 watch->ino = d_backing_inode(d)->i_ino;
369 } 369 }
370 dput(d); 370 dput(d);
371 return 0; 371 return 0;
@@ -426,7 +426,7 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
426 return ret; 426 return ret;
427 427
428 /* either find an old parent or attach a new one */ 428 /* either find an old parent or attach a new one */
429 parent = audit_find_parent(parent_path.dentry->d_inode); 429 parent = audit_find_parent(d_backing_inode(parent_path.dentry));
430 if (!parent) { 430 if (!parent) {
431 parent = audit_init_parent(&parent_path); 431 parent = audit_init_parent(&parent_path);
432 if (IS_ERR(parent)) { 432 if (IS_ERR(parent)) {
@@ -482,7 +482,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
482 482
483 switch (data_type) { 483 switch (data_type) {
484 case (FSNOTIFY_EVENT_PATH): 484 case (FSNOTIFY_EVENT_PATH):
485 inode = ((struct path *)data)->dentry->d_inode; 485 inode = d_backing_inode(((struct path *)data)->dentry);
486 break; 486 break;
487 case (FSNOTIFY_EVENT_INODE): 487 case (FSNOTIFY_EVENT_INODE):
488 inode = (struct inode *)data; 488 inode = (struct inode *)data;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index dc4ae70a7413..9fb9d1cb83ce 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1629,7 +1629,7 @@ retry:
1629 rcu_read_lock(); 1629 rcu_read_lock();
1630 seq = read_seqbegin(&rename_lock); 1630 seq = read_seqbegin(&rename_lock);
1631 for(;;) { 1631 for(;;) {
1632 struct inode *inode = d->d_inode; 1632 struct inode *inode = d_backing_inode(d);
1633 if (inode && unlikely(!hlist_empty(&inode->i_fsnotify_marks))) { 1633 if (inode && unlikely(!hlist_empty(&inode->i_fsnotify_marks))) {
1634 struct audit_chunk *chunk; 1634 struct audit_chunk *chunk;
1635 chunk = audit_tree_lookup(inode); 1635 chunk = audit_tree_lookup(inode);
@@ -1754,7 +1754,7 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
1754 unsigned int flags) 1754 unsigned int flags)
1755{ 1755{
1756 struct audit_context *context = current->audit_context; 1756 struct audit_context *context = current->audit_context;
1757 const struct inode *inode = dentry->d_inode; 1757 const struct inode *inode = d_backing_inode(dentry);
1758 struct audit_names *n; 1758 struct audit_names *n;
1759 bool parent = flags & AUDIT_INODE_PARENT; 1759 bool parent = flags & AUDIT_INODE_PARENT;
1760 1760
@@ -1853,7 +1853,7 @@ void __audit_inode_child(const struct inode *parent,
1853 const unsigned char type) 1853 const unsigned char type)
1854{ 1854{
1855 struct audit_context *context = current->audit_context; 1855 struct audit_context *context = current->audit_context;
1856 const struct inode *inode = dentry->d_inode; 1856 const struct inode *inode = d_backing_inode(dentry);
1857 const char *dname = dentry->d_name.name; 1857 const char *dname = dentry->d_name.name;
1858 struct audit_names *n, *found_parent = NULL, *found_child = NULL; 1858 struct audit_names *n, *found_parent = NULL, *found_child = NULL;
1859 1859
@@ -2361,7 +2361,6 @@ static void audit_log_task(struct audit_buffer *ab)
2361 kuid_t auid, uid; 2361 kuid_t auid, uid;
2362 kgid_t gid; 2362 kgid_t gid;
2363 unsigned int sessionid; 2363 unsigned int sessionid;
2364 struct mm_struct *mm = current->mm;
2365 char comm[sizeof(current->comm)]; 2364 char comm[sizeof(current->comm)];
2366 2365
2367 auid = audit_get_loginuid(current); 2366 auid = audit_get_loginuid(current);
@@ -2376,13 +2375,7 @@ static void audit_log_task(struct audit_buffer *ab)
2376 audit_log_task_context(ab); 2375 audit_log_task_context(ab);
2377 audit_log_format(ab, " pid=%d comm=", task_pid_nr(current)); 2376 audit_log_format(ab, " pid=%d comm=", task_pid_nr(current));
2378 audit_log_untrustedstring(ab, get_task_comm(comm, current)); 2377 audit_log_untrustedstring(ab, get_task_comm(comm, current));
2379 if (mm) { 2378 audit_log_d_path_exe(ab, current->mm);
2380 down_read(&mm->mmap_sem);
2381 if (mm->exe_file)
2382 audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
2383 up_read(&mm->mmap_sem);
2384 } else
2385 audit_log_format(ab, " exe=(null)");
2386} 2379}
2387 2380
2388/** 2381/**
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 4139a0f8b558..54f0e7fcd0e2 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -357,8 +357,8 @@ select_insn:
357 ALU64_MOD_X: 357 ALU64_MOD_X:
358 if (unlikely(SRC == 0)) 358 if (unlikely(SRC == 0))
359 return 0; 359 return 0;
360 tmp = DST; 360 div64_u64_rem(DST, SRC, &tmp);
361 DST = do_div(tmp, SRC); 361 DST = tmp;
362 CONT; 362 CONT;
363 ALU_MOD_X: 363 ALU_MOD_X:
364 if (unlikely(SRC == 0)) 364 if (unlikely(SRC == 0))
@@ -367,8 +367,8 @@ select_insn:
367 DST = do_div(tmp, (u32) SRC); 367 DST = do_div(tmp, (u32) SRC);
368 CONT; 368 CONT;
369 ALU64_MOD_K: 369 ALU64_MOD_K:
370 tmp = DST; 370 div64_u64_rem(DST, IMM, &tmp);
371 DST = do_div(tmp, IMM); 371 DST = tmp;
372 CONT; 372 CONT;
373 ALU_MOD_K: 373 ALU_MOD_K:
374 tmp = (u32) DST; 374 tmp = (u32) DST;
@@ -377,7 +377,7 @@ select_insn:
377 ALU64_DIV_X: 377 ALU64_DIV_X:
378 if (unlikely(SRC == 0)) 378 if (unlikely(SRC == 0))
379 return 0; 379 return 0;
380 do_div(DST, SRC); 380 DST = div64_u64(DST, SRC);
381 CONT; 381 CONT;
382 ALU_DIV_X: 382 ALU_DIV_X:
383 if (unlikely(SRC == 0)) 383 if (unlikely(SRC == 0))
@@ -387,7 +387,7 @@ select_insn:
387 DST = (u32) tmp; 387 DST = (u32) tmp;
388 CONT; 388 CONT;
389 ALU64_DIV_K: 389 ALU64_DIV_K:
390 do_div(DST, IMM); 390 DST = div64_u64(DST, IMM);
391 CONT; 391 CONT;
392 ALU_DIV_K: 392 ALU_DIV_K:
393 tmp = (u32) DST; 393 tmp = (u32) DST;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d9c93f36e379..1c6c2826af1e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -889,10 +889,30 @@ static void put_ctx(struct perf_event_context *ctx)
889 * Those places that change perf_event::ctx will hold both 889 * Those places that change perf_event::ctx will hold both
890 * perf_event_ctx::mutex of the 'old' and 'new' ctx value. 890 * perf_event_ctx::mutex of the 'old' and 'new' ctx value.
891 * 891 *
892 * Lock ordering is by mutex address. There is one other site where 892 * Lock ordering is by mutex address. There are two other sites where
893 * perf_event_context::mutex nests and that is put_event(). But remember that 893 * perf_event_context::mutex nests and those are:
894 * that is a parent<->child context relation, and migration does not affect 894 *
895 * children, therefore these two orderings should not interact. 895 * - perf_event_exit_task_context() [ child , 0 ]
896 * __perf_event_exit_task()
897 * sync_child_event()
898 * put_event() [ parent, 1 ]
899 *
900 * - perf_event_init_context() [ parent, 0 ]
901 * inherit_task_group()
902 * inherit_group()
903 * inherit_event()
904 * perf_event_alloc()
905 * perf_init_event()
906 * perf_try_init_event() [ child , 1 ]
907 *
908 * While it appears there is an obvious deadlock here -- the parent and child
909 * nesting levels are inverted between the two. This is in fact safe because
910 * life-time rules separate them. That is an exiting task cannot fork, and a
911 * spawning task cannot (yet) exit.
912 *
913 * But remember that that these are parent<->child context relations, and
914 * migration does not affect children, therefore these two orderings should not
915 * interact.
896 * 916 *
897 * The change in perf_event::ctx does not affect children (as claimed above) 917 * The change in perf_event::ctx does not affect children (as claimed above)
898 * because the sys_perf_event_open() case will install a new event and break 918 * because the sys_perf_event_open() case will install a new event and break
@@ -3633,9 +3653,6 @@ static void perf_remove_from_owner(struct perf_event *event)
3633 } 3653 }
3634} 3654}
3635 3655
3636/*
3637 * Called when the last reference to the file is gone.
3638 */
3639static void put_event(struct perf_event *event) 3656static void put_event(struct perf_event *event)
3640{ 3657{
3641 struct perf_event_context *ctx; 3658 struct perf_event_context *ctx;
@@ -3673,6 +3690,9 @@ int perf_event_release_kernel(struct perf_event *event)
3673} 3690}
3674EXPORT_SYMBOL_GPL(perf_event_release_kernel); 3691EXPORT_SYMBOL_GPL(perf_event_release_kernel);
3675 3692
3693/*
3694 * Called when the last reference to the file is gone.
3695 */
3676static int perf_release(struct inode *inode, struct file *file) 3696static int perf_release(struct inode *inode, struct file *file)
3677{ 3697{
3678 put_event(file->private_data); 3698 put_event(file->private_data);
@@ -7345,7 +7365,12 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
7345 return -ENODEV; 7365 return -ENODEV;
7346 7366
7347 if (event->group_leader != event) { 7367 if (event->group_leader != event) {
7348 ctx = perf_event_ctx_lock(event->group_leader); 7368 /*
7369 * This ctx->mutex can nest when we're called through
7370 * inheritance. See the perf_event_ctx_lock_nested() comment.
7371 */
7372 ctx = perf_event_ctx_lock_nested(event->group_leader,
7373 SINGLE_DEPTH_NESTING);
7349 BUG_ON(!ctx); 7374 BUG_ON(!ctx);
7350 } 7375 }
7351 7376
diff --git a/kernel/irq/dummychip.c b/kernel/irq/dummychip.c
index 988dc58e8847..2feb6feca0cc 100644
--- a/kernel/irq/dummychip.c
+++ b/kernel/irq/dummychip.c
@@ -57,5 +57,6 @@ struct irq_chip dummy_irq_chip = {
57 .irq_ack = noop, 57 .irq_ack = noop,
58 .irq_mask = noop, 58 .irq_mask = noop,
59 .irq_unmask = noop, 59 .irq_unmask = noop,
60 .flags = IRQCHIP_SKIP_SET_WAKE,
60}; 61};
61EXPORT_SYMBOL_GPL(dummy_irq_chip); 62EXPORT_SYMBOL_GPL(dummy_irq_chip);
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 38c25b1f2fd5..7a36fdcca5bf 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -707,7 +707,7 @@ static struct page *kimage_alloc_normal_control_pages(struct kimage *image,
707 do { 707 do {
708 unsigned long pfn, epfn, addr, eaddr; 708 unsigned long pfn, epfn, addr, eaddr;
709 709
710 pages = kimage_alloc_pages(GFP_KERNEL, order); 710 pages = kimage_alloc_pages(KEXEC_CONTROL_MEMORY_GFP, order);
711 if (!pages) 711 if (!pages)
712 break; 712 break;
713 pfn = page_to_pfn(pages); 713 pfn = page_to_pfn(pages);
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 8626437acf0c..8b678cac7fbe 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -265,15 +265,17 @@ struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
265} 265}
266 266
267/* 267/*
268 * Called by sched_setscheduler() to check whether the priority change 268 * Called by sched_setscheduler() to get the priority which will be
269 * is overruled by a possible priority boosting. 269 * effective after the change.
270 */ 270 */
271int rt_mutex_check_prio(struct task_struct *task, int newprio) 271int rt_mutex_get_effective_prio(struct task_struct *task, int newprio)
272{ 272{
273 if (!task_has_pi_waiters(task)) 273 if (!task_has_pi_waiters(task))
274 return 0; 274 return newprio;
275 275
276 return task_top_pi_waiter(task)->task->prio <= newprio; 276 if (task_top_pi_waiter(task)->task->prio <= newprio)
277 return task_top_pi_waiter(task)->task->prio;
278 return newprio;
277} 279}
278 280
279/* 281/*
diff --git a/kernel/module.c b/kernel/module.c
index 650b038ae520..42a1d2afb217 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -387,9 +387,9 @@ static bool check_symbol(const struct symsearch *syms,
387 pr_warn("Symbol %s is marked as UNUSED, however this module is " 387 pr_warn("Symbol %s is marked as UNUSED, however this module is "
388 "using it.\n", fsa->name); 388 "using it.\n", fsa->name);
389 pr_warn("This symbol will go away in the future.\n"); 389 pr_warn("This symbol will go away in the future.\n");
390 pr_warn("Please evalute if this is the right api to use and if " 390 pr_warn("Please evaluate if this is the right api to use and "
391 "it really is, submit a report the linux kernel " 391 "if it really is, submit a report to the linux kernel "
392 "mailinglist together with submitting your code for " 392 "mailing list together with submitting your code for "
393 "inclusion.\n"); 393 "inclusion.\n");
394 } 394 }
395#endif 395#endif
@@ -2511,7 +2511,8 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
2511 return err; 2511 return err;
2512 2512
2513 /* Suck in entire file: we'll want most of it. */ 2513 /* Suck in entire file: we'll want most of it. */
2514 info->hdr = vmalloc(info->len); 2514 info->hdr = __vmalloc(info->len,
2515 GFP_KERNEL | __GFP_HIGHMEM | __GFP_NOWARN, PAGE_KERNEL);
2515 if (!info->hdr) 2516 if (!info->hdr)
2516 return -ENOMEM; 2517 return -ENOMEM;
2517 2518
diff --git a/kernel/params.c b/kernel/params.c
index 728e05b167de..a22d6a759b1a 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -173,9 +173,9 @@ static char *next_arg(char *args, char **param, char **val)
173 if (args[i-1] == '"') 173 if (args[i-1] == '"')
174 args[i-1] = '\0'; 174 args[i-1] = '\0';
175 } 175 }
176 if (quoted && args[i-1] == '"')
177 args[i-1] = '\0';
178 } 176 }
177 if (quoted && args[i-1] == '"')
178 args[i-1] = '\0';
179 179
180 if (args[i]) { 180 if (args[i]) {
181 args[i] = '\0'; 181 args[i] = '\0';
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 879edfc5ee52..c099b082cd02 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2017,24 +2017,6 @@ int add_preferred_console(char *name, int idx, char *options)
2017 return __add_preferred_console(name, idx, options, NULL); 2017 return __add_preferred_console(name, idx, options, NULL);
2018} 2018}
2019 2019
2020int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options)
2021{
2022 struct console_cmdline *c;
2023 int i;
2024
2025 for (i = 0, c = console_cmdline;
2026 i < MAX_CMDLINECONSOLES && c->name[0];
2027 i++, c++)
2028 if (strcmp(c->name, name) == 0 && c->index == idx) {
2029 strlcpy(c->name, name_new, sizeof(c->name));
2030 c->options = options;
2031 c->index = idx_new;
2032 return i;
2033 }
2034 /* not found */
2035 return -1;
2036}
2037
2038bool console_suspend_enabled = true; 2020bool console_suspend_enabled = true;
2039EXPORT_SYMBOL(console_suspend_enabled); 2021EXPORT_SYMBOL(console_suspend_enabled);
2040 2022
@@ -2436,9 +2418,6 @@ void register_console(struct console *newcon)
2436 if (preferred_console < 0 || bcon || !console_drivers) 2418 if (preferred_console < 0 || bcon || !console_drivers)
2437 preferred_console = selected_console; 2419 preferred_console = selected_console;
2438 2420
2439 if (newcon->early_setup)
2440 newcon->early_setup();
2441
2442 /* 2421 /*
2443 * See if we want to use this console driver. If we 2422 * See if we want to use this console driver. If we
2444 * didn't select a console we take the first one 2423 * didn't select a console we take the first one
@@ -2464,23 +2443,27 @@ void register_console(struct console *newcon)
2464 for (i = 0, c = console_cmdline; 2443 for (i = 0, c = console_cmdline;
2465 i < MAX_CMDLINECONSOLES && c->name[0]; 2444 i < MAX_CMDLINECONSOLES && c->name[0];
2466 i++, c++) { 2445 i++, c++) {
2467 BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name)); 2446 if (!newcon->match ||
2468 if (strcmp(c->name, newcon->name) != 0) 2447 newcon->match(newcon, c->name, c->index, c->options) != 0) {
2469 continue; 2448 /* default matching */
2470 if (newcon->index >= 0 && 2449 BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
2471 newcon->index != c->index) 2450 if (strcmp(c->name, newcon->name) != 0)
2472 continue; 2451 continue;
2473 if (newcon->index < 0) 2452 if (newcon->index >= 0 &&
2474 newcon->index = c->index; 2453 newcon->index != c->index)
2454 continue;
2455 if (newcon->index < 0)
2456 newcon->index = c->index;
2475 2457
2476 if (_braille_register_console(newcon, c)) 2458 if (_braille_register_console(newcon, c))
2477 return; 2459 return;
2460
2461 if (newcon->setup &&
2462 newcon->setup(newcon, c->options) != 0)
2463 break;
2464 }
2478 2465
2479 if (newcon->setup &&
2480 newcon->setup(newcon, console_cmdline[i].options) != 0)
2481 break;
2482 newcon->flags |= CON_ENABLED; 2466 newcon->flags |= CON_ENABLED;
2483 newcon->index = c->index;
2484 if (i == selected_console) { 2467 if (i == selected_console) {
2485 newcon->flags |= CON_CONSDEV; 2468 newcon->flags |= CON_CONSDEV;
2486 preferred_console = selected_console; 2469 preferred_console = selected_console;
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 233165da782f..8cf7304b2867 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -162,11 +162,14 @@ static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
162static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO; 162static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO;
163module_param(kthread_prio, int, 0644); 163module_param(kthread_prio, int, 0644);
164 164
165/* Delay in jiffies for grace-period initialization delays. */ 165/* Delay in jiffies for grace-period initialization delays, debug only. */
166static int gp_init_delay = IS_ENABLED(CONFIG_RCU_TORTURE_TEST_SLOW_INIT) 166#ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT
167 ? CONFIG_RCU_TORTURE_TEST_SLOW_INIT_DELAY 167static int gp_init_delay = CONFIG_RCU_TORTURE_TEST_SLOW_INIT_DELAY;
168 : 0;
169module_param(gp_init_delay, int, 0644); 168module_param(gp_init_delay, int, 0644);
169#else /* #ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT */
170static const int gp_init_delay;
171#endif /* #else #ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT */
172#define PER_RCU_NODE_PERIOD 10 /* Number of grace periods between delays. */
170 173
171/* 174/*
172 * Track the rcutorture test sequence number and the update version 175 * Track the rcutorture test sequence number and the update version
@@ -1843,9 +1846,8 @@ static int rcu_gp_init(struct rcu_state *rsp)
1843 raw_spin_unlock_irq(&rnp->lock); 1846 raw_spin_unlock_irq(&rnp->lock);
1844 cond_resched_rcu_qs(); 1847 cond_resched_rcu_qs();
1845 ACCESS_ONCE(rsp->gp_activity) = jiffies; 1848 ACCESS_ONCE(rsp->gp_activity) = jiffies;
1846 if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_SLOW_INIT) && 1849 if (gp_init_delay > 0 &&
1847 gp_init_delay > 0 && 1850 !(rsp->gpnum % (rcu_num_nodes * PER_RCU_NODE_PERIOD)))
1848 !(rsp->gpnum % (rcu_num_nodes * 10)))
1849 schedule_timeout_uninterruptible(gp_init_delay); 1851 schedule_timeout_uninterruptible(gp_init_delay);
1850 } 1852 }
1851 1853
diff --git a/kernel/relay.c b/kernel/relay.c
index 5a56d3c8dc03..e9dbaeb8fd65 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -407,7 +407,7 @@ static inline void relay_set_buf_dentry(struct rchan_buf *buf,
407 struct dentry *dentry) 407 struct dentry *dentry)
408{ 408{
409 buf->dentry = dentry; 409 buf->dentry = dentry;
410 buf->dentry->d_inode->i_size = buf->early_bytes; 410 d_inode(buf->dentry)->i_size = buf->early_bytes;
411} 411}
412 412
413static struct dentry *relay_create_buf_file(struct rchan *chan, 413static struct dentry *relay_create_buf_file(struct rchan *chan,
@@ -733,7 +733,7 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
733 buf->padding[old_subbuf] = buf->prev_padding; 733 buf->padding[old_subbuf] = buf->prev_padding;
734 buf->subbufs_produced++; 734 buf->subbufs_produced++;
735 if (buf->dentry) 735 if (buf->dentry)
736 buf->dentry->d_inode->i_size += 736 d_inode(buf->dentry)->i_size +=
737 buf->chan->subbuf_size - 737 buf->chan->subbuf_size -
738 buf->padding[old_subbuf]; 738 buf->padding[old_subbuf];
739 else 739 else
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e84aeb280777..ecb7c4216350 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -995,13 +995,6 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
995 rq_clock_skip_update(rq, true); 995 rq_clock_skip_update(rq, true);
996} 996}
997 997
998static ATOMIC_NOTIFIER_HEAD(task_migration_notifier);
999
1000void register_task_migration_notifier(struct notifier_block *n)
1001{
1002 atomic_notifier_chain_register(&task_migration_notifier, n);
1003}
1004
1005#ifdef CONFIG_SMP 998#ifdef CONFIG_SMP
1006void set_task_cpu(struct task_struct *p, unsigned int new_cpu) 999void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
1007{ 1000{
@@ -1032,18 +1025,10 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
1032 trace_sched_migrate_task(p, new_cpu); 1025 trace_sched_migrate_task(p, new_cpu);
1033 1026
1034 if (task_cpu(p) != new_cpu) { 1027 if (task_cpu(p) != new_cpu) {
1035 struct task_migration_notifier tmn;
1036
1037 if (p->sched_class->migrate_task_rq) 1028 if (p->sched_class->migrate_task_rq)
1038 p->sched_class->migrate_task_rq(p, new_cpu); 1029 p->sched_class->migrate_task_rq(p, new_cpu);
1039 p->se.nr_migrations++; 1030 p->se.nr_migrations++;
1040 perf_sw_event_sched(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 0); 1031 perf_sw_event_sched(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 0);
1041
1042 tmn.task = p;
1043 tmn.from_cpu = task_cpu(p);
1044 tmn.to_cpu = new_cpu;
1045
1046 atomic_notifier_call_chain(&task_migration_notifier, 0, &tmn);
1047 } 1032 }
1048 1033
1049 __set_task_cpu(p, new_cpu); 1034 __set_task_cpu(p, new_cpu);
@@ -3294,15 +3279,18 @@ static void __setscheduler_params(struct task_struct *p,
3294 3279
3295/* Actually do priority change: must hold pi & rq lock. */ 3280/* Actually do priority change: must hold pi & rq lock. */
3296static void __setscheduler(struct rq *rq, struct task_struct *p, 3281static void __setscheduler(struct rq *rq, struct task_struct *p,
3297 const struct sched_attr *attr) 3282 const struct sched_attr *attr, bool keep_boost)
3298{ 3283{
3299 __setscheduler_params(p, attr); 3284 __setscheduler_params(p, attr);
3300 3285
3301 /* 3286 /*
3302 * If we get here, there was no pi waiters boosting the 3287 * Keep a potential priority boosting if called from
3303 * task. It is safe to use the normal prio. 3288 * sched_setscheduler().
3304 */ 3289 */
3305 p->prio = normal_prio(p); 3290 if (keep_boost)
3291 p->prio = rt_mutex_get_effective_prio(p, normal_prio(p));
3292 else
3293 p->prio = normal_prio(p);
3306 3294
3307 if (dl_prio(p->prio)) 3295 if (dl_prio(p->prio))
3308 p->sched_class = &dl_sched_class; 3296 p->sched_class = &dl_sched_class;
@@ -3402,7 +3390,7 @@ static int __sched_setscheduler(struct task_struct *p,
3402 int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 : 3390 int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 :
3403 MAX_RT_PRIO - 1 - attr->sched_priority; 3391 MAX_RT_PRIO - 1 - attr->sched_priority;
3404 int retval, oldprio, oldpolicy = -1, queued, running; 3392 int retval, oldprio, oldpolicy = -1, queued, running;
3405 int policy = attr->sched_policy; 3393 int new_effective_prio, policy = attr->sched_policy;
3406 unsigned long flags; 3394 unsigned long flags;
3407 const struct sched_class *prev_class; 3395 const struct sched_class *prev_class;
3408 struct rq *rq; 3396 struct rq *rq;
@@ -3584,15 +3572,14 @@ change:
3584 oldprio = p->prio; 3572 oldprio = p->prio;
3585 3573
3586 /* 3574 /*
3587 * Special case for priority boosted tasks. 3575 * Take priority boosted tasks into account. If the new
3588 * 3576 * effective priority is unchanged, we just store the new
3589 * If the new priority is lower or equal (user space view)
3590 * than the current (boosted) priority, we just store the new
3591 * normal parameters and do not touch the scheduler class and 3577 * normal parameters and do not touch the scheduler class and
3592 * the runqueue. This will be done when the task deboost 3578 * the runqueue. This will be done when the task deboost
3593 * itself. 3579 * itself.
3594 */ 3580 */
3595 if (rt_mutex_check_prio(p, newprio)) { 3581 new_effective_prio = rt_mutex_get_effective_prio(p, newprio);
3582 if (new_effective_prio == oldprio) {
3596 __setscheduler_params(p, attr); 3583 __setscheduler_params(p, attr);
3597 task_rq_unlock(rq, p, &flags); 3584 task_rq_unlock(rq, p, &flags);
3598 return 0; 3585 return 0;
@@ -3606,7 +3593,7 @@ change:
3606 put_prev_task(rq, p); 3593 put_prev_task(rq, p);
3607 3594
3608 prev_class = p->sched_class; 3595 prev_class = p->sched_class;
3609 __setscheduler(rq, p, attr); 3596 __setscheduler(rq, p, attr, true);
3610 3597
3611 if (running) 3598 if (running)
3612 p->sched_class->set_curr_task(rq); 3599 p->sched_class->set_curr_task(rq);
@@ -6991,27 +6978,23 @@ static int cpuset_cpu_inactive(struct notifier_block *nfb, unsigned long action,
6991 unsigned long flags; 6978 unsigned long flags;
6992 long cpu = (long)hcpu; 6979 long cpu = (long)hcpu;
6993 struct dl_bw *dl_b; 6980 struct dl_bw *dl_b;
6981 bool overflow;
6982 int cpus;
6994 6983
6995 switch (action & ~CPU_TASKS_FROZEN) { 6984 switch (action) {
6996 case CPU_DOWN_PREPARE: 6985 case CPU_DOWN_PREPARE:
6997 /* explicitly allow suspend */ 6986 rcu_read_lock_sched();
6998 if (!(action & CPU_TASKS_FROZEN)) { 6987 dl_b = dl_bw_of(cpu);
6999 bool overflow;
7000 int cpus;
7001
7002 rcu_read_lock_sched();
7003 dl_b = dl_bw_of(cpu);
7004 6988
7005 raw_spin_lock_irqsave(&dl_b->lock, flags); 6989 raw_spin_lock_irqsave(&dl_b->lock, flags);
7006 cpus = dl_bw_cpus(cpu); 6990 cpus = dl_bw_cpus(cpu);
7007 overflow = __dl_overflow(dl_b, cpus, 0, 0); 6991 overflow = __dl_overflow(dl_b, cpus, 0, 0);
7008 raw_spin_unlock_irqrestore(&dl_b->lock, flags); 6992 raw_spin_unlock_irqrestore(&dl_b->lock, flags);
7009 6993
7010 rcu_read_unlock_sched(); 6994 rcu_read_unlock_sched();
7011 6995
7012 if (overflow) 6996 if (overflow)
7013 return notifier_from_errno(-EBUSY); 6997 return notifier_from_errno(-EBUSY);
7014 }
7015 cpuset_update_active_cpus(false); 6998 cpuset_update_active_cpus(false);
7016 break; 6999 break;
7017 case CPU_DOWN_PREPARE_FROZEN: 7000 case CPU_DOWN_PREPARE_FROZEN:
@@ -7340,7 +7323,7 @@ static void normalize_task(struct rq *rq, struct task_struct *p)
7340 queued = task_on_rq_queued(p); 7323 queued = task_on_rq_queued(p);
7341 if (queued) 7324 if (queued)
7342 dequeue_task(rq, p, 0); 7325 dequeue_task(rq, p, 0);
7343 __setscheduler(rq, p, &attr); 7326 __setscheduler(rq, p, &attr, false);
7344 if (queued) { 7327 if (queued) {
7345 enqueue_task(rq, p, 0); 7328 enqueue_task(rq, p, 0);
7346 resched_curr(rq); 7329 resched_curr(rq);
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index deef1caa94c6..fefcb1fa5160 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -81,7 +81,6 @@ static void cpuidle_idle_call(void)
81 struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); 81 struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
82 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); 82 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
83 int next_state, entered_state; 83 int next_state, entered_state;
84 unsigned int broadcast;
85 bool reflect; 84 bool reflect;
86 85
87 /* 86 /*
@@ -150,17 +149,6 @@ static void cpuidle_idle_call(void)
150 goto exit_idle; 149 goto exit_idle;
151 } 150 }
152 151
153 broadcast = drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP;
154
155 /*
156 * Tell the time framework to switch to a broadcast timer
157 * because our local timer will be shutdown. If a local timer
158 * is used from another cpu as a broadcast timer, this call may
159 * fail if it is not available
160 */
161 if (broadcast && tick_broadcast_enter())
162 goto use_default;
163
164 /* Take note of the planned idle state. */ 152 /* Take note of the planned idle state. */
165 idle_set_state(this_rq(), &drv->states[next_state]); 153 idle_set_state(this_rq(), &drv->states[next_state]);
166 154
@@ -174,8 +162,8 @@ static void cpuidle_idle_call(void)
174 /* The cpu is no longer idle or about to enter idle. */ 162 /* The cpu is no longer idle or about to enter idle. */
175 idle_set_state(this_rq(), NULL); 163 idle_set_state(this_rq(), NULL);
176 164
177 if (broadcast) 165 if (entered_state == -EBUSY)
178 tick_broadcast_exit(); 166 goto use_default;
179 167
180 /* 168 /*
181 * Give the governor an opportunity to reflect on the outcome 169 * Give the governor an opportunity to reflect on the outcome
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 25d942d1da27..637a09461c1d 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -117,11 +117,7 @@ static int __clockevents_set_state(struct clock_event_device *dev,
117 /* Transition with new state-specific callbacks */ 117 /* Transition with new state-specific callbacks */
118 switch (state) { 118 switch (state) {
119 case CLOCK_EVT_STATE_DETACHED: 119 case CLOCK_EVT_STATE_DETACHED:
120 /* 120 /* The clockevent device is getting replaced. Shut it down. */
121 * This is an internal state, which is guaranteed to go from
122 * SHUTDOWN to DETACHED. No driver interaction required.
123 */
124 return 0;
125 121
126 case CLOCK_EVT_STATE_SHUTDOWN: 122 case CLOCK_EVT_STATE_SHUTDOWN:
127 return dev->set_state_shutdown(dev); 123 return dev->set_state_shutdown(dev);
@@ -440,7 +436,7 @@ int clockevents_unbind_device(struct clock_event_device *ced, int cpu)
440 mutex_unlock(&clockevents_mutex); 436 mutex_unlock(&clockevents_mutex);
441 return ret; 437 return ret;
442} 438}
443EXPORT_SYMBOL_GPL(clockevents_unbind); 439EXPORT_SYMBOL_GPL(clockevents_unbind_device);
444 440
445/* Sanity check of state transition callbacks */ 441/* Sanity check of state transition callbacks */
446static int clockevents_sanity_check(struct clock_event_device *dev) 442static int clockevents_sanity_check(struct clock_event_device *dev)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 91eecaaa43e0..05330494a0df 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6079,7 +6079,7 @@ trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
6079 struct dentry *ret = trace_create_file(name, mode, parent, data, fops); 6079 struct dentry *ret = trace_create_file(name, mode, parent, data, fops);
6080 6080
6081 if (ret) /* See tracing_get_cpu() */ 6081 if (ret) /* See tracing_get_cpu() */
6082 ret->d_inode->i_cdev = (void *)(cpu + 1); 6082 d_inode(ret)->i_cdev = (void *)(cpu + 1);
6083 return ret; 6083 return ret;
6084} 6084}
6085 6085
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7da1dfeb322e..c4de47fc5cca 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -494,8 +494,8 @@ static void remove_event_file_dir(struct ftrace_event_file *file)
494 if (dir) { 494 if (dir) {
495 spin_lock(&dir->d_lock); /* probably unneeded */ 495 spin_lock(&dir->d_lock); /* probably unneeded */
496 list_for_each_entry(child, &dir->d_subdirs, d_child) { 496 list_for_each_entry(child, &dir->d_subdirs, d_child) {
497 if (child->d_inode) /* probably unneeded */ 497 if (d_really_is_positive(child)) /* probably unneeded */
498 child->d_inode->i_private = NULL; 498 d_inode(child)->i_private = NULL;
499 } 499 }
500 spin_unlock(&dir->d_lock); 500 spin_unlock(&dir->d_lock);
501 501
@@ -565,6 +565,7 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
565static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set) 565static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
566{ 566{
567 char *event = NULL, *sub = NULL, *match; 567 char *event = NULL, *sub = NULL, *match;
568 int ret;
568 569
569 /* 570 /*
570 * The buf format can be <subsystem>:<event-name> 571 * The buf format can be <subsystem>:<event-name>
@@ -590,7 +591,13 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
590 event = NULL; 591 event = NULL;
591 } 592 }
592 593
593 return __ftrace_set_clr_event(tr, match, sub, event, set); 594 ret = __ftrace_set_clr_event(tr, match, sub, event, set);
595
596 /* Put back the colon to allow this to be called again */
597 if (buf)
598 *(buf - 1) = ':';
599
600 return ret;
594} 601}
595 602
596/** 603/**
@@ -1753,6 +1760,8 @@ static void update_event_printk(struct ftrace_event_call *call,
1753 ptr++; 1760 ptr++;
1754 /* Check for alpha chars like ULL */ 1761 /* Check for alpha chars like ULL */
1755 } while (isalnum(*ptr)); 1762 } while (isalnum(*ptr));
1763 if (!*ptr)
1764 break;
1756 /* 1765 /*
1757 * A number must have some kind of delimiter after 1766 * A number must have some kind of delimiter after
1758 * it, and we can ignore that too. 1767 * it, and we can ignore that too.
@@ -1779,12 +1788,16 @@ static void update_event_printk(struct ftrace_event_call *call,
1779 do { 1788 do {
1780 ptr++; 1789 ptr++;
1781 } while (isalnum(*ptr) || *ptr == '_'); 1790 } while (isalnum(*ptr) || *ptr == '_');
1791 if (!*ptr)
1792 break;
1782 /* 1793 /*
1783 * If what comes after this variable is a '.' or 1794 * If what comes after this variable is a '.' or
1784 * '->' then we can continue to ignore that string. 1795 * '->' then we can continue to ignore that string.
1785 */ 1796 */
1786 if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) { 1797 if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) {
1787 ptr += *ptr == '.' ? 1 : 2; 1798 ptr += *ptr == '.' ? 1 : 2;
1799 if (!*ptr)
1800 break;
1788 goto skip_more; 1801 goto skip_more;
1789 } 1802 }
1790 /* 1803 /*
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 9cfea4c6d314..a51e79688455 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -1308,15 +1308,19 @@ void graph_trace_open(struct trace_iterator *iter)
1308{ 1308{
1309 /* pid and depth on the last trace processed */ 1309 /* pid and depth on the last trace processed */
1310 struct fgraph_data *data; 1310 struct fgraph_data *data;
1311 gfp_t gfpflags;
1311 int cpu; 1312 int cpu;
1312 1313
1313 iter->private = NULL; 1314 iter->private = NULL;
1314 1315
1315 data = kzalloc(sizeof(*data), GFP_KERNEL); 1316 /* We can be called in atomic context via ftrace_dump() */
1317 gfpflags = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
1318
1319 data = kzalloc(sizeof(*data), gfpflags);
1316 if (!data) 1320 if (!data)
1317 goto out_err; 1321 goto out_err;
1318 1322
1319 data->cpu_data = alloc_percpu(struct fgraph_cpu_data); 1323 data->cpu_data = alloc_percpu_gfp(struct fgraph_cpu_data, gfpflags);
1320 if (!data->cpu_data) 1324 if (!data->cpu_data)
1321 goto out_err_free; 1325 goto out_err_free;
1322 1326
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 692bf7184c8c..25a086bcb700 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -178,12 +178,13 @@ ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
178EXPORT_SYMBOL(ftrace_print_hex_seq); 178EXPORT_SYMBOL(ftrace_print_hex_seq);
179 179
180const char * 180const char *
181ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len, 181ftrace_print_array_seq(struct trace_seq *p, const void *buf, int count,
182 size_t el_size) 182 size_t el_size)
183{ 183{
184 const char *ret = trace_seq_buffer_ptr(p); 184 const char *ret = trace_seq_buffer_ptr(p);
185 const char *prefix = ""; 185 const char *prefix = "";
186 void *ptr = (void *)buf; 186 void *ptr = (void *)buf;
187 size_t buf_len = count * el_size;
187 188
188 trace_seq_putc(p, '{'); 189 trace_seq_putc(p, '{');
189 190
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index d60fe62ec4fa..6dd022c7b5bc 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -443,7 +443,7 @@ static int create_trace_uprobe(int argc, char **argv)
443 if (ret) 443 if (ret)
444 goto fail_address_parse; 444 goto fail_address_parse;
445 445
446 inode = igrab(path.dentry->d_inode); 446 inode = igrab(d_inode(path.dentry));
447 path_put(&path); 447 path_put(&path);
448 448
449 if (!inode || !S_ISREG(inode->i_mode)) { 449 if (!inode || !S_ISREG(inode->i_mode)) {
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 2316f50b07a4..506edcc500c4 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -41,6 +41,8 @@
41#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) 41#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
42#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) 42#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
43 43
44static DEFINE_MUTEX(watchdog_proc_mutex);
45
44#ifdef CONFIG_HARDLOCKUP_DETECTOR 46#ifdef CONFIG_HARDLOCKUP_DETECTOR
45static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED; 47static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
46#else 48#else
@@ -608,26 +610,36 @@ void watchdog_nmi_enable_all(void)
608{ 610{
609 int cpu; 611 int cpu;
610 612
611 if (!watchdog_user_enabled) 613 mutex_lock(&watchdog_proc_mutex);
612 return; 614
615 if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
616 goto unlock;
613 617
614 get_online_cpus(); 618 get_online_cpus();
615 for_each_online_cpu(cpu) 619 for_each_online_cpu(cpu)
616 watchdog_nmi_enable(cpu); 620 watchdog_nmi_enable(cpu);
617 put_online_cpus(); 621 put_online_cpus();
622
623unlock:
624 mutex_lock(&watchdog_proc_mutex);
618} 625}
619 626
620void watchdog_nmi_disable_all(void) 627void watchdog_nmi_disable_all(void)
621{ 628{
622 int cpu; 629 int cpu;
623 630
631 mutex_lock(&watchdog_proc_mutex);
632
624 if (!watchdog_running) 633 if (!watchdog_running)
625 return; 634 goto unlock;
626 635
627 get_online_cpus(); 636 get_online_cpus();
628 for_each_online_cpu(cpu) 637 for_each_online_cpu(cpu)
629 watchdog_nmi_disable(cpu); 638 watchdog_nmi_disable(cpu);
630 put_online_cpus(); 639 put_online_cpus();
640
641unlock:
642 mutex_unlock(&watchdog_proc_mutex);
631} 643}
632#else 644#else
633static int watchdog_nmi_enable(unsigned int cpu) { return 0; } 645static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
@@ -744,8 +756,6 @@ static int proc_watchdog_update(void)
744 756
745} 757}
746 758
747static DEFINE_MUTEX(watchdog_proc_mutex);
748
749/* 759/*
750 * common function for watchdog, nmi_watchdog and soft_watchdog parameter 760 * common function for watchdog, nmi_watchdog and soft_watchdog parameter
751 * 761 *