diff options
Diffstat (limited to 'kernel')
44 files changed, 213 insertions, 329 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index b96bf69183f4..486c968214d9 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* audit.c -- Auditing support | 2 | /* audit.c -- Auditing support |
2 | * Gateway between the kernel (e.g., selinux) and the user-space audit daemon. | 3 | * Gateway between the kernel (e.g., selinux) and the user-space audit daemon. |
3 | * System-call specific features have moved to auditsc.c | 4 | * System-call specific features have moved to auditsc.c |
@@ -5,20 +6,6 @@ | |||
5 | * Copyright 2003-2007 Red Hat Inc., Durham, North Carolina. | 6 | * Copyright 2003-2007 Red Hat Inc., Durham, North Carolina. |
6 | * All Rights Reserved. | 7 | * All Rights Reserved. |
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | * Written by Rickard E. (Rik) Faith <faith@redhat.com> | 9 | * Written by Rickard E. (Rik) Faith <faith@redhat.com> |
23 | * | 10 | * |
24 | * Goals: 1) Integrate fully with Security Modules. | 11 | * Goals: 1) Integrate fully with Security Modules. |
diff --git a/kernel/audit.h b/kernel/audit.h index 2071725a999f..6c076d4982da 100644 --- a/kernel/audit.h +++ b/kernel/audit.h | |||
@@ -1,22 +1,9 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
1 | /* audit -- definition of audit_context structure and supporting types | 2 | /* audit -- definition of audit_context structure and supporting types |
2 | * | 3 | * |
3 | * Copyright 2003-2004 Red Hat, Inc. | 4 | * Copyright 2003-2004 Red Hat, Inc. |
4 | * Copyright 2005 Hewlett-Packard Development Company, L.P. | 5 | * Copyright 2005 Hewlett-Packard Development Company, L.P. |
5 | * Copyright 2005 IBM Corporation | 6 | * Copyright 2005 IBM Corporation |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | 7 | */ |
21 | 8 | ||
22 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c index b5737b826951..f0d243318452 100644 --- a/kernel/audit_fsnotify.c +++ b/kernel/audit_fsnotify.c | |||
@@ -1,18 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* audit_fsnotify.c -- tracking inodes | 2 | /* audit_fsnotify.c -- tracking inodes |
2 | * | 3 | * |
3 | * Copyright 2003-2009,2014-2015 Red Hat, Inc. | 4 | * Copyright 2003-2009,2014-2015 Red Hat, Inc. |
4 | * Copyright 2005 Hewlett-Packard Development Company, L.P. | 5 | * Copyright 2005 Hewlett-Packard Development Company, L.P. |
5 | * Copyright 2005 IBM Corporation | 6 | * Copyright 2005 IBM Corporation |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | 7 | */ |
17 | 8 | ||
18 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index b50c574223fa..1f31c2f1e6fc 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
@@ -1,22 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* audit_watch.c -- watching inodes | 2 | /* audit_watch.c -- watching inodes |
2 | * | 3 | * |
3 | * Copyright 2003-2009 Red Hat, Inc. | 4 | * Copyright 2003-2009 Red Hat, Inc. |
4 | * Copyright 2005 Hewlett-Packard Development Company, L.P. | 5 | * Copyright 2005 Hewlett-Packard Development Company, L.P. |
5 | * Copyright 2005 IBM Corporation | 6 | * Copyright 2005 IBM Corporation |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | 7 | */ |
21 | 8 | ||
22 | #include <linux/file.h> | 9 | #include <linux/file.h> |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 303fb04770ce..9f8e190e3bea 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -1,22 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* auditfilter.c -- filtering of audit events | 2 | /* auditfilter.c -- filtering of audit events |
2 | * | 3 | * |
3 | * Copyright 2003-2004 Red Hat, Inc. | 4 | * Copyright 2003-2004 Red Hat, Inc. |
4 | * Copyright 2005 Hewlett-Packard Development Company, L.P. | 5 | * Copyright 2005 Hewlett-Packard Development Company, L.P. |
5 | * Copyright 2005 IBM Corporation | 6 | * Copyright 2005 IBM Corporation |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | 7 | */ |
21 | 8 | ||
22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c index e6ef4401a138..1b6b9349cb85 100644 --- a/kernel/bpf/bpf_lru_list.c +++ b/kernel/bpf/bpf_lru_list.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* Copyright (c) 2016 Facebook | 2 | /* Copyright (c) 2016 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #include <linux/cpumask.h> | 4 | #include <linux/cpumask.h> |
8 | #include <linux/spinlock.h> | 5 | #include <linux/spinlock.h> |
diff --git a/kernel/bpf/bpf_lru_list.h b/kernel/bpf/bpf_lru_list.h index 7d4f89b7cb84..f02504640e18 100644 --- a/kernel/bpf/bpf_lru_list.h +++ b/kernel/bpf/bpf_lru_list.h | |||
@@ -1,8 +1,5 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-only */ | ||
1 | /* Copyright (c) 2016 Facebook | 2 | /* Copyright (c) 2016 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #ifndef __BPF_LRU_LIST_H_ | 4 | #ifndef __BPF_LRU_LIST_H_ |
8 | #define __BPF_LRU_LIST_H_ | 5 | #define __BPF_LRU_LIST_H_ |
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 242a643af82f..7c473f208a10 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Linux Socket Filter - Kernel level socket filtering | 3 | * Linux Socket Filter - Kernel level socket filtering |
3 | * | 4 | * |
@@ -12,11 +13,6 @@ | |||
12 | * Alexei Starovoitov <ast@plumgrid.com> | 13 | * Alexei Starovoitov <ast@plumgrid.com> |
13 | * Daniel Borkmann <dborkman@redhat.com> | 14 | * Daniel Borkmann <dborkman@redhat.com> |
14 | * | 15 | * |
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License | ||
17 | * as published by the Free Software Foundation; either version | ||
18 | * 2 of the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Andi Kleen - Fix a few bad bugs and races. | 16 | * Andi Kleen - Fix a few bad bugs and races. |
21 | * Kris Katterjohn - Added many additional checks in bpf_check_classic() | 17 | * Kris Katterjohn - Added many additional checks in bpf_check_classic() |
22 | */ | 18 | */ |
diff --git a/kernel/bpf/map_in_map.c b/kernel/bpf/map_in_map.c index 3dff41403583..fab4fb134547 100644 --- a/kernel/bpf/map_in_map.c +++ b/kernel/bpf/map_in_map.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* Copyright (c) 2017 Facebook | 2 | /* Copyright (c) 2017 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
8 | #include <linux/bpf.h> | 5 | #include <linux/bpf.h> |
diff --git a/kernel/bpf/map_in_map.h b/kernel/bpf/map_in_map.h index 6183db9ec08c..a507bf6ef8b9 100644 --- a/kernel/bpf/map_in_map.h +++ b/kernel/bpf/map_in_map.h | |||
@@ -1,8 +1,5 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-only */ | ||
1 | /* Copyright (c) 2017 Facebook | 2 | /* Copyright (c) 2017 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #ifndef __MAP_IN_MAP_H__ | 4 | #ifndef __MAP_IN_MAP_H__ |
8 | #define __MAP_IN_MAP_H__ | 5 | #define __MAP_IN_MAP_H__ |
diff --git a/kernel/bpf/percpu_freelist.c b/kernel/bpf/percpu_freelist.c index 0c1b4ba9e90e..6e090140b924 100644 --- a/kernel/bpf/percpu_freelist.c +++ b/kernel/bpf/percpu_freelist.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* Copyright (c) 2016 Facebook | 2 | /* Copyright (c) 2016 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #include "percpu_freelist.h" | 4 | #include "percpu_freelist.h" |
8 | 5 | ||
diff --git a/kernel/bpf/percpu_freelist.h b/kernel/bpf/percpu_freelist.h index c3960118e617..fbf8a8a28979 100644 --- a/kernel/bpf/percpu_freelist.h +++ b/kernel/bpf/percpu_freelist.h | |||
@@ -1,8 +1,5 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-only */ | ||
1 | /* Copyright (c) 2016 Facebook | 2 | /* Copyright (c) 2016 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #ifndef __PERCPU_FREELIST_H__ | 4 | #ifndef __PERCPU_FREELIST_H__ |
8 | #define __PERCPU_FREELIST_H__ | 5 | #define __PERCPU_FREELIST_H__ |
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index 950ab2f28922..d38e49f943a1 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* Copyright (c) 2016 Facebook | 2 | /* Copyright (c) 2016 Facebook |
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | 3 | */ |
7 | #include <linux/bpf.h> | 4 | #include <linux/bpf.h> |
8 | #include <linux/jhash.h> | 5 | #include <linux/jhash.h> |
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 217cec4e22c6..426a0026225c 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -1810,11 +1810,13 @@ int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node, | |||
1810 | 1810 | ||
1811 | enum cgroup2_param { | 1811 | enum cgroup2_param { |
1812 | Opt_nsdelegate, | 1812 | Opt_nsdelegate, |
1813 | Opt_memory_localevents, | ||
1813 | nr__cgroup2_params | 1814 | nr__cgroup2_params |
1814 | }; | 1815 | }; |
1815 | 1816 | ||
1816 | static const struct fs_parameter_spec cgroup2_param_specs[] = { | 1817 | static const struct fs_parameter_spec cgroup2_param_specs[] = { |
1817 | fsparam_flag ("nsdelegate", Opt_nsdelegate), | 1818 | fsparam_flag("nsdelegate", Opt_nsdelegate), |
1819 | fsparam_flag("memory_localevents", Opt_memory_localevents), | ||
1818 | {} | 1820 | {} |
1819 | }; | 1821 | }; |
1820 | 1822 | ||
@@ -1837,6 +1839,9 @@ static int cgroup2_parse_param(struct fs_context *fc, struct fs_parameter *param | |||
1837 | case Opt_nsdelegate: | 1839 | case Opt_nsdelegate: |
1838 | ctx->flags |= CGRP_ROOT_NS_DELEGATE; | 1840 | ctx->flags |= CGRP_ROOT_NS_DELEGATE; |
1839 | return 0; | 1841 | return 0; |
1842 | case Opt_memory_localevents: | ||
1843 | ctx->flags |= CGRP_ROOT_MEMORY_LOCAL_EVENTS; | ||
1844 | return 0; | ||
1840 | } | 1845 | } |
1841 | return -EINVAL; | 1846 | return -EINVAL; |
1842 | } | 1847 | } |
@@ -1848,6 +1853,11 @@ static void apply_cgroup_root_flags(unsigned int root_flags) | |||
1848 | cgrp_dfl_root.flags |= CGRP_ROOT_NS_DELEGATE; | 1853 | cgrp_dfl_root.flags |= CGRP_ROOT_NS_DELEGATE; |
1849 | else | 1854 | else |
1850 | cgrp_dfl_root.flags &= ~CGRP_ROOT_NS_DELEGATE; | 1855 | cgrp_dfl_root.flags &= ~CGRP_ROOT_NS_DELEGATE; |
1856 | |||
1857 | if (root_flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) | ||
1858 | cgrp_dfl_root.flags |= CGRP_ROOT_MEMORY_LOCAL_EVENTS; | ||
1859 | else | ||
1860 | cgrp_dfl_root.flags &= ~CGRP_ROOT_MEMORY_LOCAL_EVENTS; | ||
1851 | } | 1861 | } |
1852 | } | 1862 | } |
1853 | 1863 | ||
@@ -1855,6 +1865,8 @@ static int cgroup_show_options(struct seq_file *seq, struct kernfs_root *kf_root | |||
1855 | { | 1865 | { |
1856 | if (cgrp_dfl_root.flags & CGRP_ROOT_NS_DELEGATE) | 1866 | if (cgrp_dfl_root.flags & CGRP_ROOT_NS_DELEGATE) |
1857 | seq_puts(seq, ",nsdelegate"); | 1867 | seq_puts(seq, ",nsdelegate"); |
1868 | if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) | ||
1869 | seq_puts(seq, ",memory_localevents"); | ||
1858 | return 0; | 1870 | return 0; |
1859 | } | 1871 | } |
1860 | 1872 | ||
@@ -6325,7 +6337,7 @@ static struct kobj_attribute cgroup_delegate_attr = __ATTR_RO(delegate); | |||
6325 | static ssize_t features_show(struct kobject *kobj, struct kobj_attribute *attr, | 6337 | static ssize_t features_show(struct kobject *kobj, struct kobj_attribute *attr, |
6326 | char *buf) | 6338 | char *buf) |
6327 | { | 6339 | { |
6328 | return snprintf(buf, PAGE_SIZE, "nsdelegate\n"); | 6340 | return snprintf(buf, PAGE_SIZE, "nsdelegate\nmemory_localevents\n"); |
6329 | } | 6341 | } |
6330 | static struct kobj_attribute cgroup_features_attr = __ATTR_RO(features); | 6342 | static struct kobj_attribute cgroup_features_attr = __ATTR_RO(features); |
6331 | 6343 | ||
diff --git a/kernel/cred.c b/kernel/cred.c index 45d77284aed0..e74ffdc98a92 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -1,12 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* Task credentials management - see Documentation/security/credentials.rst | 2 | /* Task credentials management - see Documentation/security/credentials.rst |
2 | * | 3 | * |
3 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. | 4 | * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 5 | * Written by David Howells (dhowells@redhat.com) |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | */ | 6 | */ |
11 | #include <linux/export.h> | 7 | #include <linux/export.h> |
12 | #include <linux/cred.h> | 8 | #include <linux/cred.h> |
diff --git a/kernel/events/internal.h b/kernel/events/internal.h index 79c47076700a..3aef4191798c 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h | |||
@@ -24,7 +24,7 @@ struct ring_buffer { | |||
24 | atomic_t poll; /* POLL_ for wakeups */ | 24 | atomic_t poll; /* POLL_ for wakeups */ |
25 | 25 | ||
26 | local_t head; /* write position */ | 26 | local_t head; /* write position */ |
27 | local_t nest; /* nested writers */ | 27 | unsigned int nest; /* nested writers */ |
28 | local_t events; /* event limit */ | 28 | local_t events; /* event limit */ |
29 | local_t wakeup; /* wakeup stamp */ | 29 | local_t wakeup; /* wakeup stamp */ |
30 | local_t lost; /* nr records lost */ | 30 | local_t lost; /* nr records lost */ |
@@ -41,7 +41,7 @@ struct ring_buffer { | |||
41 | 41 | ||
42 | /* AUX area */ | 42 | /* AUX area */ |
43 | long aux_head; | 43 | long aux_head; |
44 | local_t aux_nest; | 44 | unsigned int aux_nest; |
45 | long aux_wakeup; /* last aux_watermark boundary crossed by aux_head */ | 45 | long aux_wakeup; /* last aux_watermark boundary crossed by aux_head */ |
46 | unsigned long aux_pgoff; | 46 | unsigned long aux_pgoff; |
47 | int aux_nr_pages; | 47 | int aux_nr_pages; |
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 674b35383491..ffb59a4ef4ff 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c | |||
@@ -38,7 +38,12 @@ static void perf_output_get_handle(struct perf_output_handle *handle) | |||
38 | struct ring_buffer *rb = handle->rb; | 38 | struct ring_buffer *rb = handle->rb; |
39 | 39 | ||
40 | preempt_disable(); | 40 | preempt_disable(); |
41 | local_inc(&rb->nest); | 41 | |
42 | /* | ||
43 | * Avoid an explicit LOAD/STORE such that architectures with memops | ||
44 | * can use them. | ||
45 | */ | ||
46 | (*(volatile unsigned int *)&rb->nest)++; | ||
42 | handle->wakeup = local_read(&rb->wakeup); | 47 | handle->wakeup = local_read(&rb->wakeup); |
43 | } | 48 | } |
44 | 49 | ||
@@ -46,17 +51,35 @@ static void perf_output_put_handle(struct perf_output_handle *handle) | |||
46 | { | 51 | { |
47 | struct ring_buffer *rb = handle->rb; | 52 | struct ring_buffer *rb = handle->rb; |
48 | unsigned long head; | 53 | unsigned long head; |
54 | unsigned int nest; | ||
55 | |||
56 | /* | ||
57 | * If this isn't the outermost nesting, we don't have to update | ||
58 | * @rb->user_page->data_head. | ||
59 | */ | ||
60 | nest = READ_ONCE(rb->nest); | ||
61 | if (nest > 1) { | ||
62 | WRITE_ONCE(rb->nest, nest - 1); | ||
63 | goto out; | ||
64 | } | ||
49 | 65 | ||
50 | again: | 66 | again: |
67 | /* | ||
68 | * In order to avoid publishing a head value that goes backwards, | ||
69 | * we must ensure the load of @rb->head happens after we've | ||
70 | * incremented @rb->nest. | ||
71 | * | ||
72 | * Otherwise we can observe a @rb->head value before one published | ||
73 | * by an IRQ/NMI happening between the load and the increment. | ||
74 | */ | ||
75 | barrier(); | ||
51 | head = local_read(&rb->head); | 76 | head = local_read(&rb->head); |
52 | 77 | ||
53 | /* | 78 | /* |
54 | * IRQ/NMI can happen here, which means we can miss a head update. | 79 | * IRQ/NMI can happen here and advance @rb->head, causing our |
80 | * load above to be stale. | ||
55 | */ | 81 | */ |
56 | 82 | ||
57 | if (!local_dec_and_test(&rb->nest)) | ||
58 | goto out; | ||
59 | |||
60 | /* | 83 | /* |
61 | * Since the mmap() consumer (userspace) can run on a different CPU: | 84 | * Since the mmap() consumer (userspace) can run on a different CPU: |
62 | * | 85 | * |
@@ -84,14 +107,23 @@ again: | |||
84 | * See perf_output_begin(). | 107 | * See perf_output_begin(). |
85 | */ | 108 | */ |
86 | smp_wmb(); /* B, matches C */ | 109 | smp_wmb(); /* B, matches C */ |
87 | rb->user_page->data_head = head; | 110 | WRITE_ONCE(rb->user_page->data_head, head); |
88 | 111 | ||
89 | /* | 112 | /* |
90 | * Now check if we missed an update -- rely on previous implied | 113 | * We must publish the head before decrementing the nest count, |
91 | * compiler barriers to force a re-read. | 114 | * otherwise an IRQ/NMI can publish a more recent head value and our |
115 | * write will (temporarily) publish a stale value. | ||
92 | */ | 116 | */ |
117 | barrier(); | ||
118 | WRITE_ONCE(rb->nest, 0); | ||
119 | |||
120 | /* | ||
121 | * Ensure we decrement @rb->nest before we validate the @rb->head. | ||
122 | * Otherwise we cannot be sure we caught the 'last' nested update. | ||
123 | */ | ||
124 | barrier(); | ||
93 | if (unlikely(head != local_read(&rb->head))) { | 125 | if (unlikely(head != local_read(&rb->head))) { |
94 | local_inc(&rb->nest); | 126 | WRITE_ONCE(rb->nest, 1); |
95 | goto again; | 127 | goto again; |
96 | } | 128 | } |
97 | 129 | ||
@@ -330,6 +362,7 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, | |||
330 | struct perf_event *output_event = event; | 362 | struct perf_event *output_event = event; |
331 | unsigned long aux_head, aux_tail; | 363 | unsigned long aux_head, aux_tail; |
332 | struct ring_buffer *rb; | 364 | struct ring_buffer *rb; |
365 | unsigned int nest; | ||
333 | 366 | ||
334 | if (output_event->parent) | 367 | if (output_event->parent) |
335 | output_event = output_event->parent; | 368 | output_event = output_event->parent; |
@@ -360,13 +393,16 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, | |||
360 | if (!refcount_inc_not_zero(&rb->aux_refcount)) | 393 | if (!refcount_inc_not_zero(&rb->aux_refcount)) |
361 | goto err; | 394 | goto err; |
362 | 395 | ||
396 | nest = READ_ONCE(rb->aux_nest); | ||
363 | /* | 397 | /* |
364 | * Nesting is not supported for AUX area, make sure nested | 398 | * Nesting is not supported for AUX area, make sure nested |
365 | * writers are caught early | 399 | * writers are caught early |
366 | */ | 400 | */ |
367 | if (WARN_ON_ONCE(local_xchg(&rb->aux_nest, 1))) | 401 | if (WARN_ON_ONCE(nest)) |
368 | goto err_put; | 402 | goto err_put; |
369 | 403 | ||
404 | WRITE_ONCE(rb->aux_nest, nest + 1); | ||
405 | |||
370 | aux_head = rb->aux_head; | 406 | aux_head = rb->aux_head; |
371 | 407 | ||
372 | handle->rb = rb; | 408 | handle->rb = rb; |
@@ -394,7 +430,7 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, | |||
394 | if (!handle->size) { /* A, matches D */ | 430 | if (!handle->size) { /* A, matches D */ |
395 | event->pending_disable = smp_processor_id(); | 431 | event->pending_disable = smp_processor_id(); |
396 | perf_output_wakeup(handle); | 432 | perf_output_wakeup(handle); |
397 | local_set(&rb->aux_nest, 0); | 433 | WRITE_ONCE(rb->aux_nest, 0); |
398 | goto err_put; | 434 | goto err_put; |
399 | } | 435 | } |
400 | } | 436 | } |
@@ -471,7 +507,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) | |||
471 | perf_event_aux_event(handle->event, aux_head, size, | 507 | perf_event_aux_event(handle->event, aux_head, size, |
472 | handle->aux_flags); | 508 | handle->aux_flags); |
473 | 509 | ||
474 | rb->user_page->aux_head = rb->aux_head; | 510 | WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); |
475 | if (rb_need_aux_wakeup(rb)) | 511 | if (rb_need_aux_wakeup(rb)) |
476 | wakeup = true; | 512 | wakeup = true; |
477 | 513 | ||
@@ -483,7 +519,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) | |||
483 | 519 | ||
484 | handle->event = NULL; | 520 | handle->event = NULL; |
485 | 521 | ||
486 | local_set(&rb->aux_nest, 0); | 522 | WRITE_ONCE(rb->aux_nest, 0); |
487 | /* can't be last */ | 523 | /* can't be last */ |
488 | rb_free_aux(rb); | 524 | rb_free_aux(rb); |
489 | ring_buffer_put(rb); | 525 | ring_buffer_put(rb); |
@@ -503,7 +539,7 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size) | |||
503 | 539 | ||
504 | rb->aux_head += size; | 540 | rb->aux_head += size; |
505 | 541 | ||
506 | rb->user_page->aux_head = rb->aux_head; | 542 | WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); |
507 | if (rb_need_aux_wakeup(rb)) { | 543 | if (rb_need_aux_wakeup(rb)) { |
508 | perf_output_wakeup(handle); | 544 | perf_output_wakeup(handle); |
509 | handle->wakeup = rb->aux_wakeup + rb->aux_watermark; | 545 | handle->wakeup = rb->aux_wakeup + rb->aux_watermark; |
diff --git a/kernel/extable.c b/kernel/extable.c index 6a5b61ebc66c..e23cce6e6092 100644 --- a/kernel/extable.c +++ b/kernel/extable.c | |||
@@ -1,19 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* Rewritten by Rusty Russell, on the backs of many others... | 2 | /* Rewritten by Rusty Russell, on the backs of many others... |
2 | Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM. | 3 | Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM. |
3 | 4 | ||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | 5 | */ |
18 | #include <linux/ftrace.h> | 6 | #include <linux/ftrace.h> |
19 | #include <linux/memory.h> | 7 | #include <linux/memory.h> |
diff --git a/kernel/fork.c b/kernel/fork.c index b2b87d450b80..75675b9bf6df 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -123,7 +123,7 @@ | |||
123 | unsigned long total_forks; /* Handle normal Linux uptimes. */ | 123 | unsigned long total_forks; /* Handle normal Linux uptimes. */ |
124 | int nr_threads; /* The idle threads do not count.. */ | 124 | int nr_threads; /* The idle threads do not count.. */ |
125 | 125 | ||
126 | int max_threads; /* tunable limit on nr_threads */ | 126 | static int max_threads; /* tunable limit on nr_threads */ |
127 | 127 | ||
128 | DEFINE_PER_CPU(unsigned long, process_counts) = 0; | 128 | DEFINE_PER_CPU(unsigned long, process_counts) = 0; |
129 | 129 | ||
diff --git a/kernel/futex.c b/kernel/futex.c index 49bf20a8c512..6d50728ef2e7 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Fast Userspace Mutexes (which I call "Futexes!"). | 3 | * Fast Userspace Mutexes (which I call "Futexes!"). |
3 | * (C) Rusty Russell, IBM 2002 | 4 | * (C) Rusty Russell, IBM 2002 |
@@ -29,20 +30,6 @@ | |||
29 | * | 30 | * |
30 | * "The futexes are also cursed." | 31 | * "The futexes are also cursed." |
31 | * "But they come in a choice of three flavours!" | 32 | * "But they come in a choice of three flavours!" |
32 | * | ||
33 | * This program is free software; you can redistribute it and/or modify | ||
34 | * it under the terms of the GNU General Public License as published by | ||
35 | * the Free Software Foundation; either version 2 of the License, or | ||
36 | * (at your option) any later version. | ||
37 | * | ||
38 | * This program is distributed in the hope that it will be useful, | ||
39 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
40 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
41 | * GNU General Public License for more details. | ||
42 | * | ||
43 | * You should have received a copy of the GNU General Public License | ||
44 | * along with this program; if not, write to the Free Software | ||
45 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
46 | */ | 33 | */ |
47 | #include <linux/compat.h> | 34 | #include <linux/compat.h> |
48 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index b1ea30a5540e..445337c107e0 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -1,21 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Kernel Probes (KProbes) | 3 | * Kernel Probes (KProbes) |
3 | * kernel/kprobes.c | 4 | * kernel/kprobes.c |
4 | * | 5 | * |
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | * | ||
19 | * Copyright (C) IBM Corporation, 2002, 2004 | 6 | * Copyright (C) IBM Corporation, 2002, 2004 |
20 | * | 7 | * |
21 | * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel | 8 | * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel |
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 46ba853656f6..35859da8bd4f 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c | |||
@@ -1,11 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* | 2 | /* |
2 | * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which | 3 | * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which |
3 | * are not related to any other subsystem | 4 | * are not related to any other subsystem |
4 | * | 5 | * |
5 | * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org> | 6 | * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org> |
6 | * | ||
7 | * This file is release under the GPLv2 | ||
8 | * | ||
9 | */ | 7 | */ |
10 | 8 | ||
11 | #include <linux/kobject.h> | 9 | #include <linux/kobject.h> |
diff --git a/kernel/locking/lock_events.h b/kernel/locking/lock_events.h index feb1acc54611..46b71af8eef2 100644 --- a/kernel/locking/lock_events.h +++ b/kernel/locking/lock_events.h | |||
@@ -31,12 +31,50 @@ enum lock_events { | |||
31 | DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); | 31 | DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * The purpose of the lock event counting subsystem is to provide a low | ||
35 | * overhead way to record the number of specific locking events by using | ||
36 | * percpu counters. It is the percpu sum that matters, not specifically | ||
37 | * how many of them happens in each cpu. | ||
38 | * | ||
39 | * It is possible that the same percpu counter may be modified in both | ||
40 | * the process and interrupt contexts. For architectures that perform | ||
41 | * percpu operation with multiple instructions, it is possible to lose | ||
42 | * count if a process context percpu update is interrupted in the middle | ||
43 | * and the same counter is updated in the interrupt context. Therefore, | ||
44 | * the generated percpu sum may not be precise. The error, if any, should | ||
45 | * be small and insignificant. | ||
46 | * | ||
47 | * For those architectures that do multi-instruction percpu operation, | ||
48 | * preemption in the middle and moving the task to another cpu may cause | ||
49 | * a larger error in the count. Again, this will be few and far between. | ||
50 | * Given the imprecise nature of the count and the possibility of resetting | ||
51 | * the count and doing the measurement again, this is not really a big | ||
52 | * problem. | ||
53 | * | ||
54 | * To get a better picture of what is happening under the hood, it is | ||
55 | * suggested that a few measurements should be taken with the counts | ||
56 | * reset in between to stamp out outliner because of these possible | ||
57 | * error conditions. | ||
58 | * | ||
59 | * To minimize overhead, we use __this_cpu_*() in all cases except when | ||
60 | * CONFIG_DEBUG_PREEMPT is defined. In this particular case, this_cpu_*() | ||
61 | * will be used to avoid the appearance of unwanted BUG messages. | ||
62 | */ | ||
63 | #ifdef CONFIG_DEBUG_PREEMPT | ||
64 | #define lockevent_percpu_inc(x) this_cpu_inc(x) | ||
65 | #define lockevent_percpu_add(x, v) this_cpu_add(x, v) | ||
66 | #else | ||
67 | #define lockevent_percpu_inc(x) __this_cpu_inc(x) | ||
68 | #define lockevent_percpu_add(x, v) __this_cpu_add(x, v) | ||
69 | #endif | ||
70 | |||
71 | /* | ||
34 | * Increment the PV qspinlock statistical counters | 72 | * Increment the PV qspinlock statistical counters |
35 | */ | 73 | */ |
36 | static inline void __lockevent_inc(enum lock_events event, bool cond) | 74 | static inline void __lockevent_inc(enum lock_events event, bool cond) |
37 | { | 75 | { |
38 | if (cond) | 76 | if (cond) |
39 | __this_cpu_inc(lockevents[event]); | 77 | lockevent_percpu_inc(lockevents[event]); |
40 | } | 78 | } |
41 | 79 | ||
42 | #define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) | 80 | #define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) |
@@ -44,7 +82,7 @@ static inline void __lockevent_inc(enum lock_events event, bool cond) | |||
44 | 82 | ||
45 | static inline void __lockevent_add(enum lock_events event, int inc) | 83 | static inline void __lockevent_add(enum lock_events event, int inc) |
46 | { | 84 | { |
47 | __this_cpu_add(lockevents[event], inc); | 85 | lockevent_percpu_add(lockevents[event], inc); |
48 | } | 86 | } |
49 | 87 | ||
50 | #define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c) | 88 | #define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c) |
diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c index c7471c3fb798..fe9ca92faa2a 100644 --- a/kernel/locking/qrwlock.c +++ b/kernel/locking/qrwlock.c | |||
@@ -1,16 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Queued read/write locks | 3 | * Queued read/write locks |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P. | 5 | * (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P. |
15 | * | 6 | * |
16 | * Authors: Waiman Long <waiman.long@hp.com> | 7 | * Authors: Waiman Long <waiman.long@hp.com> |
diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index e14b32c69639..2473f10c6956 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c | |||
@@ -1,16 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Queued spinlock | 3 | * Queued spinlock |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. | 5 | * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. |
15 | * (C) Copyright 2013-2014,2018 Red Hat, Inc. | 6 | * (C) Copyright 2013-2014,2018 Red Hat, Inc. |
16 | * (C) Copyright 2015 Intel Corp. | 7 | * (C) Copyright 2015 Intel Corp. |
diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h index 54152670ff24..e625bb410aa2 100644 --- a/kernel/locking/qspinlock_stat.h +++ b/kernel/locking/qspinlock_stat.h | |||
@@ -1,13 +1,5 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
1 | /* | 2 | /* |
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | 3 | * |
12 | * Authors: Waiman Long <longman@redhat.com> | 4 | * Authors: Waiman Long <longman@redhat.com> |
13 | */ | 5 | */ |
diff --git a/kernel/module-internal.h b/kernel/module-internal.h index d354341f8cc0..33783abc377b 100644 --- a/kernel/module-internal.h +++ b/kernel/module-internal.h | |||
@@ -1,12 +1,8 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
1 | /* Module internals | 2 | /* Module internals |
2 | * | 3 | * |
3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. | 4 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 5 | * Written by David Howells (dhowells@redhat.com) |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | */ | 6 | */ |
11 | 7 | ||
12 | #include <linux/elf.h> | 8 | #include <linux/elf.h> |
diff --git a/kernel/module.c b/kernel/module.c index 6e6712b3aaf5..80c7c09584cf 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1,20 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | Copyright (C) 2002 Richard Henderson | 3 | Copyright (C) 2002 Richard Henderson |
3 | Copyright (C) 2001 Rusty Russell, 2002, 2010 Rusty Russell IBM. | 4 | Copyright (C) 2001 Rusty Russell, 2002, 2010 Rusty Russell IBM. |
4 | 5 | ||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | 6 | */ |
19 | #include <linux/export.h> | 7 | #include <linux/export.h> |
20 | #include <linux/extable.h> | 8 | #include <linux/extable.h> |
diff --git a/kernel/module_signing.c b/kernel/module_signing.c index 6b9a926fd86b..b10fb1986ca9 100644 --- a/kernel/module_signing.c +++ b/kernel/module_signing.c | |||
@@ -1,12 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* Module signature checker | 2 | /* Module signature checker |
2 | * | 3 | * |
3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. | 4 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 5 | * Written by David Howells (dhowells@redhat.com) |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public Licence | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the Licence, or (at your option) any later version. | ||
10 | */ | 6 | */ |
11 | 7 | ||
12 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
diff --git a/kernel/params.c b/kernel/params.c index ce89f757e6da..cf448785d058 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -1,19 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* Helpers for initial module or kernel cmdline parsing | 2 | /* Helpers for initial module or kernel cmdline parsing |
2 | Copyright (C) 2001 Rusty Russell. | 3 | Copyright (C) 2001 Rusty Russell. |
3 | 4 | ||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | 5 | */ |
18 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
19 | #include <linux/string.h> | 7 | #include <linux/string.h> |
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index c8c272df7154..97522630b1b6 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -129,7 +129,7 @@ static int hibernation_test(int level) { return 0; } | |||
129 | static int platform_begin(int platform_mode) | 129 | static int platform_begin(int platform_mode) |
130 | { | 130 | { |
131 | return (platform_mode && hibernation_ops) ? | 131 | return (platform_mode && hibernation_ops) ? |
132 | hibernation_ops->begin() : 0; | 132 | hibernation_ops->begin(PMSG_FREEZE) : 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | /** | 135 | /** |
@@ -542,7 +542,7 @@ int hibernation_platform_enter(void) | |||
542 | * hibernation_ops->finish() before saving the image, so we should let | 542 | * hibernation_ops->finish() before saving the image, so we should let |
543 | * the firmware know that we're going to enter the sleep state after all | 543 | * the firmware know that we're going to enter the sleep state after all |
544 | */ | 544 | */ |
545 | error = hibernation_ops->begin(); | 545 | error = hibernation_ops->begin(PMSG_HIBERNATE); |
546 | if (error) | 546 | if (error) |
547 | goto Close; | 547 | goto Close; |
548 | 548 | ||
diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c index 3cd8a3a795d2..aa8d75804108 100644 --- a/kernel/sched/membarrier.c +++ b/kernel/sched/membarrier.c | |||
@@ -1,17 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2010-2017 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 3 | * Copyright (C) 2010-2017 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
3 | * | 4 | * |
4 | * membarrier system call | 5 | * membarrier system call |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | 6 | */ |
16 | #include "sched.h" | 7 | #include "sched.h" |
17 | 8 | ||
diff --git a/kernel/signal.c b/kernel/signal.c index d7b9d14ac80d..328a01e1a2f0 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2485,6 +2485,8 @@ relock: | |||
2485 | if (signal_group_exit(signal)) { | 2485 | if (signal_group_exit(signal)) { |
2486 | ksig->info.si_signo = signr = SIGKILL; | 2486 | ksig->info.si_signo = signr = SIGKILL; |
2487 | sigdelset(¤t->pending.signal, SIGKILL); | 2487 | sigdelset(¤t->pending.signal, SIGKILL); |
2488 | trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, | ||
2489 | &sighand->action[SIGKILL - 1]); | ||
2488 | recalc_sigpending(); | 2490 | recalc_sigpending(); |
2489 | goto fatal; | 2491 | goto fatal; |
2490 | } | 2492 | } |
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c index 5667f1da3ede..36139de0a3c4 100644 --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c | |||
@@ -207,7 +207,7 @@ int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store, | |||
207 | 207 | ||
208 | ret = arch_stack_walk_reliable(consume_entry, &c, tsk); | 208 | ret = arch_stack_walk_reliable(consume_entry, &c, tsk); |
209 | put_task_stack(tsk); | 209 | put_task_stack(tsk); |
210 | return ret; | 210 | return ret ? ret : c.len; |
211 | } | 211 | } |
212 | #endif | 212 | #endif |
213 | 213 | ||
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 7231fb5953fc..2b5a6754646f 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * kernel/stop_machine.c | 3 | * kernel/stop_machine.c |
3 | * | 4 | * |
@@ -5,8 +6,6 @@ | |||
5 | * Copyright (C) 2008, 2005 Rusty Russell rusty@rustcorp.com.au | 6 | * Copyright (C) 2008, 2005 Rusty Russell rusty@rustcorp.com.au |
6 | * Copyright (C) 2010 SUSE Linux Products GmbH | 7 | * Copyright (C) 2010 SUSE Linux Products GmbH |
7 | * Copyright (C) 2010 Tejun Heo <tj@kernel.org> | 8 | * Copyright (C) 2010 Tejun Heo <tj@kernel.org> |
8 | * | ||
9 | * This file is released under the GPLv2 and any later version. | ||
10 | */ | 9 | */ |
11 | #include <linux/completion.h> | 10 | #include <linux/completion.h> |
12 | #include <linux/cpu.h> | 11 | #include <linux/cpu.h> |
diff --git a/kernel/sys.c b/kernel/sys.c index bdbfe8d37418..2969304c29fe 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1882,13 +1882,14 @@ exit_err: | |||
1882 | } | 1882 | } |
1883 | 1883 | ||
1884 | /* | 1884 | /* |
1885 | * Check arithmetic relations of passed addresses. | ||
1886 | * | ||
1885 | * WARNING: we don't require any capability here so be very careful | 1887 | * WARNING: we don't require any capability here so be very careful |
1886 | * in what is allowed for modification from userspace. | 1888 | * in what is allowed for modification from userspace. |
1887 | */ | 1889 | */ |
1888 | static int validate_prctl_map(struct prctl_mm_map *prctl_map) | 1890 | static int validate_prctl_map_addr(struct prctl_mm_map *prctl_map) |
1889 | { | 1891 | { |
1890 | unsigned long mmap_max_addr = TASK_SIZE; | 1892 | unsigned long mmap_max_addr = TASK_SIZE; |
1891 | struct mm_struct *mm = current->mm; | ||
1892 | int error = -EINVAL, i; | 1893 | int error = -EINVAL, i; |
1893 | 1894 | ||
1894 | static const unsigned char offsets[] = { | 1895 | static const unsigned char offsets[] = { |
@@ -1949,24 +1950,6 @@ static int validate_prctl_map(struct prctl_mm_map *prctl_map) | |||
1949 | prctl_map->start_data)) | 1950 | prctl_map->start_data)) |
1950 | goto out; | 1951 | goto out; |
1951 | 1952 | ||
1952 | /* | ||
1953 | * Someone is trying to cheat the auxv vector. | ||
1954 | */ | ||
1955 | if (prctl_map->auxv_size) { | ||
1956 | if (!prctl_map->auxv || prctl_map->auxv_size > sizeof(mm->saved_auxv)) | ||
1957 | goto out; | ||
1958 | } | ||
1959 | |||
1960 | /* | ||
1961 | * Finally, make sure the caller has the rights to | ||
1962 | * change /proc/pid/exe link: only local sys admin should | ||
1963 | * be allowed to. | ||
1964 | */ | ||
1965 | if (prctl_map->exe_fd != (u32)-1) { | ||
1966 | if (!ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | ||
1967 | goto out; | ||
1968 | } | ||
1969 | |||
1970 | error = 0; | 1953 | error = 0; |
1971 | out: | 1954 | out: |
1972 | return error; | 1955 | return error; |
@@ -1993,11 +1976,18 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data | |||
1993 | if (copy_from_user(&prctl_map, addr, sizeof(prctl_map))) | 1976 | if (copy_from_user(&prctl_map, addr, sizeof(prctl_map))) |
1994 | return -EFAULT; | 1977 | return -EFAULT; |
1995 | 1978 | ||
1996 | error = validate_prctl_map(&prctl_map); | 1979 | error = validate_prctl_map_addr(&prctl_map); |
1997 | if (error) | 1980 | if (error) |
1998 | return error; | 1981 | return error; |
1999 | 1982 | ||
2000 | if (prctl_map.auxv_size) { | 1983 | if (prctl_map.auxv_size) { |
1984 | /* | ||
1985 | * Someone is trying to cheat the auxv vector. | ||
1986 | */ | ||
1987 | if (!prctl_map.auxv || | ||
1988 | prctl_map.auxv_size > sizeof(mm->saved_auxv)) | ||
1989 | return -EINVAL; | ||
1990 | |||
2001 | memset(user_auxv, 0, sizeof(user_auxv)); | 1991 | memset(user_auxv, 0, sizeof(user_auxv)); |
2002 | if (copy_from_user(user_auxv, | 1992 | if (copy_from_user(user_auxv, |
2003 | (const void __user *)prctl_map.auxv, | 1993 | (const void __user *)prctl_map.auxv, |
@@ -2010,6 +2000,14 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data | |||
2010 | } | 2000 | } |
2011 | 2001 | ||
2012 | if (prctl_map.exe_fd != (u32)-1) { | 2002 | if (prctl_map.exe_fd != (u32)-1) { |
2003 | /* | ||
2004 | * Make sure the caller has the rights to | ||
2005 | * change /proc/pid/exe link: only local sys admin should | ||
2006 | * be allowed to. | ||
2007 | */ | ||
2008 | if (!ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | ||
2009 | return -EINVAL; | ||
2010 | |||
2013 | error = prctl_set_mm_exe_file(mm, prctl_map.exe_fd); | 2011 | error = prctl_set_mm_exe_file(mm, prctl_map.exe_fd); |
2014 | if (error) | 2012 | if (error) |
2015 | return error; | 2013 | return error; |
@@ -2097,7 +2095,11 @@ static int prctl_set_mm(int opt, unsigned long addr, | |||
2097 | unsigned long arg4, unsigned long arg5) | 2095 | unsigned long arg4, unsigned long arg5) |
2098 | { | 2096 | { |
2099 | struct mm_struct *mm = current->mm; | 2097 | struct mm_struct *mm = current->mm; |
2100 | struct prctl_mm_map prctl_map; | 2098 | struct prctl_mm_map prctl_map = { |
2099 | .auxv = NULL, | ||
2100 | .auxv_size = 0, | ||
2101 | .exe_fd = -1, | ||
2102 | }; | ||
2101 | struct vm_area_struct *vma; | 2103 | struct vm_area_struct *vma; |
2102 | int error; | 2104 | int error; |
2103 | 2105 | ||
@@ -2125,9 +2127,15 @@ static int prctl_set_mm(int opt, unsigned long addr, | |||
2125 | 2127 | ||
2126 | error = -EINVAL; | 2128 | error = -EINVAL; |
2127 | 2129 | ||
2128 | down_write(&mm->mmap_sem); | 2130 | /* |
2131 | * arg_lock protects concurent updates of arg boundaries, we need | ||
2132 | * mmap_sem for a) concurrent sys_brk, b) finding VMA for addr | ||
2133 | * validation. | ||
2134 | */ | ||
2135 | down_read(&mm->mmap_sem); | ||
2129 | vma = find_vma(mm, addr); | 2136 | vma = find_vma(mm, addr); |
2130 | 2137 | ||
2138 | spin_lock(&mm->arg_lock); | ||
2131 | prctl_map.start_code = mm->start_code; | 2139 | prctl_map.start_code = mm->start_code; |
2132 | prctl_map.end_code = mm->end_code; | 2140 | prctl_map.end_code = mm->end_code; |
2133 | prctl_map.start_data = mm->start_data; | 2141 | prctl_map.start_data = mm->start_data; |
@@ -2139,9 +2147,6 @@ static int prctl_set_mm(int opt, unsigned long addr, | |||
2139 | prctl_map.arg_end = mm->arg_end; | 2147 | prctl_map.arg_end = mm->arg_end; |
2140 | prctl_map.env_start = mm->env_start; | 2148 | prctl_map.env_start = mm->env_start; |
2141 | prctl_map.env_end = mm->env_end; | 2149 | prctl_map.env_end = mm->env_end; |
2142 | prctl_map.auxv = NULL; | ||
2143 | prctl_map.auxv_size = 0; | ||
2144 | prctl_map.exe_fd = -1; | ||
2145 | 2150 | ||
2146 | switch (opt) { | 2151 | switch (opt) { |
2147 | case PR_SET_MM_START_CODE: | 2152 | case PR_SET_MM_START_CODE: |
@@ -2181,7 +2186,7 @@ static int prctl_set_mm(int opt, unsigned long addr, | |||
2181 | goto out; | 2186 | goto out; |
2182 | } | 2187 | } |
2183 | 2188 | ||
2184 | error = validate_prctl_map(&prctl_map); | 2189 | error = validate_prctl_map_addr(&prctl_map); |
2185 | if (error) | 2190 | if (error) |
2186 | goto out; | 2191 | goto out; |
2187 | 2192 | ||
@@ -2218,7 +2223,8 @@ static int prctl_set_mm(int opt, unsigned long addr, | |||
2218 | 2223 | ||
2219 | error = 0; | 2224 | error = 0; |
2220 | out: | 2225 | out: |
2221 | up_write(&mm->mmap_sem); | 2226 | spin_unlock(&mm->arg_lock); |
2227 | up_read(&mm->mmap_sem); | ||
2222 | return error; | 2228 | return error; |
2223 | } | 2229 | } |
2224 | 2230 | ||
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 5f852b8f59f7..13a0f2e6ebc2 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
@@ -1,19 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * taskstats.c - Export per-task statistics to userland | 3 | * taskstats.c - Export per-task statistics to userland |
3 | * | 4 | * |
4 | * Copyright (C) Shailabh Nagar, IBM Corp. 2006 | 5 | * Copyright (C) Shailabh Nagar, IBM Corp. 2006 |
5 | * (C) Balbir Singh, IBM Corp. 2006 | 6 | * (C) Balbir Singh, IBM Corp. 2006 |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | 7 | */ |
18 | 8 | ||
19 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2c92b3d9ea30..1c80521fd436 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -8910,12 +8910,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) | |||
8910 | 8910 | ||
8911 | cnt++; | 8911 | cnt++; |
8912 | 8912 | ||
8913 | /* reset all but tr, trace, and overruns */ | 8913 | trace_iterator_reset(&iter); |
8914 | memset(&iter.seq, 0, | ||
8915 | sizeof(struct trace_iterator) - | ||
8916 | offsetof(struct trace_iterator, seq)); | ||
8917 | iter.iter_flags |= TRACE_FILE_LAT_FMT; | 8914 | iter.iter_flags |= TRACE_FILE_LAT_FMT; |
8918 | iter.pos = -1; | ||
8919 | 8915 | ||
8920 | if (trace_find_next_entry_inc(&iter) != NULL) { | 8916 | if (trace_find_next_entry_inc(&iter) != NULL) { |
8921 | int ret; | 8917 | int ret; |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 1974ce818ddb..005f08629b8b 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/trace_seq.h> | 15 | #include <linux/trace_seq.h> |
16 | #include <linux/trace_events.h> | 16 | #include <linux/trace_events.h> |
17 | #include <linux/compiler.h> | 17 | #include <linux/compiler.h> |
18 | #include <linux/trace_seq.h> | ||
19 | #include <linux/glob.h> | 18 | #include <linux/glob.h> |
20 | 19 | ||
21 | #ifdef CONFIG_FTRACE_SYSCALLS | 20 | #ifdef CONFIG_FTRACE_SYSCALLS |
@@ -1967,4 +1966,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { } | |||
1967 | 1966 | ||
1968 | extern struct trace_iterator *tracepoint_print_iter; | 1967 | extern struct trace_iterator *tracepoint_print_iter; |
1969 | 1968 | ||
1969 | /* | ||
1970 | * Reset the state of the trace_iterator so that it can read consumed data. | ||
1971 | * Normally, the trace_iterator is used for reading the data when it is not | ||
1972 | * consumed, and must retain state. | ||
1973 | */ | ||
1974 | static __always_inline void trace_iterator_reset(struct trace_iterator *iter) | ||
1975 | { | ||
1976 | const size_t offset = offsetof(struct trace_iterator, seq); | ||
1977 | |||
1978 | /* | ||
1979 | * Keep gcc from complaining about overwriting more than just one | ||
1980 | * member in the structure. | ||
1981 | */ | ||
1982 | memset((char *)iter + offset, 0, sizeof(struct trace_iterator) - offset); | ||
1983 | |||
1984 | iter->pos = -1; | ||
1985 | } | ||
1986 | |||
1970 | #endif /* _LINUX_KERNEL_TRACE_H */ | 1987 | #endif /* _LINUX_KERNEL_TRACE_H */ |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index d3e59312ef40..5079d1db3754 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -428,7 +428,7 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, | |||
428 | op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL); | 428 | op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL); |
429 | if (!op_stack) | 429 | if (!op_stack) |
430 | return ERR_PTR(-ENOMEM); | 430 | return ERR_PTR(-ENOMEM); |
431 | prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL); | 431 | prog_stack = kcalloc(nr_preds, sizeof(*prog_stack), GFP_KERNEL); |
432 | if (!prog_stack) { | 432 | if (!prog_stack) { |
433 | parse_error(pe, -ENOMEM, 0); | 433 | parse_error(pe, -ENOMEM, 0); |
434 | goto out_free; | 434 | goto out_free; |
@@ -579,7 +579,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, | |||
579 | out_free: | 579 | out_free: |
580 | kfree(op_stack); | 580 | kfree(op_stack); |
581 | kfree(inverts); | 581 | kfree(inverts); |
582 | kfree(prog_stack); | 582 | if (prog_stack) { |
583 | for (i = 0; prog_stack[i].pred; i++) | ||
584 | kfree(prog_stack[i].pred); | ||
585 | kfree(prog_stack); | ||
586 | } | ||
583 | return ERR_PTR(ret); | 587 | return ERR_PTR(ret); |
584 | } | 588 | } |
585 | 589 | ||
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 7fca3457c705..ca6b0dff60c5 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c | |||
@@ -59,7 +59,7 @@ | |||
59 | C(NO_CLOSING_PAREN, "No closing paren found"), \ | 59 | C(NO_CLOSING_PAREN, "No closing paren found"), \ |
60 | C(SUBSYS_NOT_FOUND, "Missing subsystem"), \ | 60 | C(SUBSYS_NOT_FOUND, "Missing subsystem"), \ |
61 | C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \ | 61 | C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \ |
62 | C(INVALID_REF_KEY, "Using variable references as keys not supported"), \ | 62 | C(INVALID_REF_KEY, "Using variable references in keys not supported"), \ |
63 | C(VAR_NOT_FOUND, "Couldn't find variable"), \ | 63 | C(VAR_NOT_FOUND, "Couldn't find variable"), \ |
64 | C(FIELD_NOT_FOUND, "Couldn't find field"), | 64 | C(FIELD_NOT_FOUND, "Couldn't find field"), |
65 | 65 | ||
@@ -1854,6 +1854,9 @@ static u64 hist_field_var_ref(struct hist_field *hist_field, | |||
1854 | struct hist_elt_data *elt_data; | 1854 | struct hist_elt_data *elt_data; |
1855 | u64 var_val = 0; | 1855 | u64 var_val = 0; |
1856 | 1856 | ||
1857 | if (WARN_ON_ONCE(!elt)) | ||
1858 | return var_val; | ||
1859 | |||
1857 | elt_data = elt->private_data; | 1860 | elt_data = elt->private_data; |
1858 | var_val = elt_data->var_ref_vals[hist_field->var_ref_idx]; | 1861 | var_val = elt_data->var_ref_vals[hist_field->var_ref_idx]; |
1859 | 1862 | ||
@@ -3582,14 +3585,20 @@ static bool cond_snapshot_update(struct trace_array *tr, void *cond_data) | |||
3582 | struct track_data *track_data = tr->cond_snapshot->cond_data; | 3585 | struct track_data *track_data = tr->cond_snapshot->cond_data; |
3583 | struct hist_elt_data *elt_data, *track_elt_data; | 3586 | struct hist_elt_data *elt_data, *track_elt_data; |
3584 | struct snapshot_context *context = cond_data; | 3587 | struct snapshot_context *context = cond_data; |
3588 | struct action_data *action; | ||
3585 | u64 track_val; | 3589 | u64 track_val; |
3586 | 3590 | ||
3587 | if (!track_data) | 3591 | if (!track_data) |
3588 | return false; | 3592 | return false; |
3589 | 3593 | ||
3594 | action = track_data->action_data; | ||
3595 | |||
3590 | track_val = get_track_val(track_data->hist_data, context->elt, | 3596 | track_val = get_track_val(track_data->hist_data, context->elt, |
3591 | track_data->action_data); | 3597 | track_data->action_data); |
3592 | 3598 | ||
3599 | if (!action->track_data.check_val(track_data->track_val, track_val)) | ||
3600 | return false; | ||
3601 | |||
3593 | track_data->track_val = track_val; | 3602 | track_data->track_val = track_val; |
3594 | memcpy(track_data->key, context->key, track_data->key_len); | 3603 | memcpy(track_data->key, context->key, track_data->key_len); |
3595 | 3604 | ||
@@ -4503,7 +4512,7 @@ static int create_key_field(struct hist_trigger_data *hist_data, | |||
4503 | goto out; | 4512 | goto out; |
4504 | } | 4513 | } |
4505 | 4514 | ||
4506 | if (hist_field->flags & HIST_FIELD_FL_VAR_REF) { | 4515 | if (field_has_hist_vars(hist_field, 0)) { |
4507 | hist_err(tr, HIST_ERR_INVALID_REF_KEY, errpos(field_str)); | 4516 | hist_err(tr, HIST_ERR_INVALID_REF_KEY, errpos(field_str)); |
4508 | destroy_hist_field(hist_field, 0); | 4517 | destroy_hist_field(hist_field, 0); |
4509 | ret = -EINVAL; | 4518 | ret = -EINVAL; |
diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c index 6c1ae6b752d1..cca65044c14c 100644 --- a/kernel/trace/trace_kdb.c +++ b/kernel/trace/trace_kdb.c | |||
@@ -37,12 +37,8 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file) | |||
37 | if (skip_entries) | 37 | if (skip_entries) |
38 | kdb_printf("(skipping %d entries)\n", skip_entries); | 38 | kdb_printf("(skipping %d entries)\n", skip_entries); |
39 | 39 | ||
40 | /* reset all but tr, trace, and overruns */ | 40 | trace_iterator_reset(&iter); |
41 | memset(&iter.seq, 0, | ||
42 | sizeof(struct trace_iterator) - | ||
43 | offsetof(struct trace_iterator, seq)); | ||
44 | iter.iter_flags |= TRACE_FILE_LAT_FMT; | 41 | iter.iter_flags |= TRACE_FILE_LAT_FMT; |
45 | iter.pos = -1; | ||
46 | 42 | ||
47 | if (cpu_file == RING_BUFFER_ALL_CPUS) { | 43 | if (cpu_file == RING_BUFFER_ALL_CPUS) { |
48 | for_each_tracing_cpu(cpu) { | 44 | for_each_tracing_cpu(cpu) { |
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 46f2ab1e08a9..df3ade14ccbd 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c | |||
@@ -1,19 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2008-2014 Mathieu Desnoyers | 3 | * Copyright (C) 2008-2014 Mathieu Desnoyers |
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | 4 | */ |
18 | #include <linux/module.h> | 5 | #include <linux/module.h> |
19 | #include <linux/mutex.h> | 6 | #include <linux/mutex.h> |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 370724b45391..7be3e7530841 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -1,19 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * tsacct.c - System accounting over taskstats interface | 3 | * tsacct.c - System accounting over taskstats interface |
3 | * | 4 | * |
4 | * Copyright (C) Jay Lan, <jlan@sgi.com> | 5 | * Copyright (C) Jay Lan, <jlan@sgi.com> |
5 | * | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | 6 | */ |
18 | 7 | ||
19 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |