aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-10 19:58:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-10 19:58:42 -0400
commit9967468c0a109644e4a1f5b39b39bf86fe7507a7 (patch)
tree72b7764c6dd6d74ede25688545a2e0c29dde3a2b /kernel
parent548aa0e3c516d906dae5edb1fc9a1ad2e490120a (diff)
parentdd83c161fbcc5d8be637ab159c0de015cbff5ba4 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: - most of the rest of MM - KASAN updates - lib/ updates - checkpatch updates - some binfmt_elf changes - various misc bits * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (115 commits) kernel/exit.c: avoid undefined behaviour when calling wait4() kernel/signal.c: avoid undefined behaviour in kill_something_info binfmt_elf: safely increment argv pointers s390: reduce ELF_ET_DYN_BASE powerpc: move ELF_ET_DYN_BASE to 4GB / 4MB arm64: move ELF_ET_DYN_BASE to 4GB / 4MB arm: move ELF_ET_DYN_BASE to 4MB binfmt_elf: use ELF_ET_DYN_BASE only for PIE fs, epoll: short circuit fetching events if thread has been killed checkpatch: improve multi-line alignment test checkpatch: improve macro reuse test checkpatch: change format of --color argument to --color[=WHEN] checkpatch: silence perl 5.26.0 unescaped left brace warnings checkpatch: improve tests for multiple line function definitions checkpatch: remove false warning for commit reference checkpatch: fix stepping through statements with $stat and ctx_statement_block checkpatch: [HLP]LIST_HEAD is also declaration checkpatch: warn when a MAINTAINERS entry isn't [A-Z]:\t checkpatch: improve the unnecessary OOM message test lib/bsearch.c: micro-optimize pivot position calculation ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/extable.c3
-rw-r--r--kernel/groups.c35
-rw-r--r--kernel/kallsyms.c10
-rw-r--r--kernel/ksysfs.c2
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/signal.c4
-rw-r--r--kernel/sys.c6
8 files changed, 28 insertions, 38 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 608c9775a37b..c5548faa9f37 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1639,6 +1639,10 @@ long kernel_wait4(pid_t upid, int __user *stat_addr, int options,
1639 __WNOTHREAD|__WCLONE|__WALL)) 1639 __WNOTHREAD|__WCLONE|__WALL))
1640 return -EINVAL; 1640 return -EINVAL;
1641 1641
1642 /* -INT_MIN is not defined */
1643 if (upid == INT_MIN)
1644 return -ESRCH;
1645
1642 if (upid == -1) 1646 if (upid == -1)
1643 type = PIDTYPE_MAX; 1647 type = PIDTYPE_MAX;
1644 else if (upid < 0) { 1648 else if (upid < 0) {
diff --git a/kernel/extable.c b/kernel/extable.c
index 223df4a328a4..38c2412401a1 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -55,7 +55,8 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
55{ 55{
56 const struct exception_table_entry *e; 56 const struct exception_table_entry *e;
57 57
58 e = search_extable(__start___ex_table, __stop___ex_table-1, addr); 58 e = search_extable(__start___ex_table,
59 __stop___ex_table - __start___ex_table, addr);
59 if (!e) 60 if (!e)
60 e = search_module_extables(addr); 61 e = search_module_extables(addr);
61 return e; 62 return e;
diff --git a/kernel/groups.c b/kernel/groups.c
index d09727692a2a..434f6665f187 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -5,6 +5,7 @@
5#include <linux/export.h> 5#include <linux/export.h>
6#include <linux/slab.h> 6#include <linux/slab.h>
7#include <linux/security.h> 7#include <linux/security.h>
8#include <linux/sort.h>
8#include <linux/syscalls.h> 9#include <linux/syscalls.h>
9#include <linux/user_namespace.h> 10#include <linux/user_namespace.h>
10#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
@@ -76,32 +77,18 @@ static int groups_from_user(struct group_info *group_info,
76 return 0; 77 return 0;
77} 78}
78 79
79/* a simple Shell sort */ 80static int gid_cmp(const void *_a, const void *_b)
81{
82 kgid_t a = *(kgid_t *)_a;
83 kgid_t b = *(kgid_t *)_b;
84
85 return gid_gt(a, b) - gid_lt(a, b);
86}
87
80static void groups_sort(struct group_info *group_info) 88static void groups_sort(struct group_info *group_info)
81{ 89{
82 int base, max, stride; 90 sort(group_info->gid, group_info->ngroups, sizeof(*group_info->gid),
83 int gidsetsize = group_info->ngroups; 91 gid_cmp, NULL);
84
85 for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
86 ; /* nothing */
87 stride /= 3;
88
89 while (stride) {
90 max = gidsetsize - stride;
91 for (base = 0; base < max; base++) {
92 int left = base;
93 int right = left + stride;
94 kgid_t tmp = group_info->gid[right];
95
96 while (left >= 0 && gid_gt(group_info->gid[left], tmp)) {
97 group_info->gid[right] = group_info->gid[left];
98 right = left;
99 left -= stride;
100 }
101 group_info->gid[right] = tmp;
102 }
103 stride /= 3;
104 }
105} 92}
106 93
107/* a simple bsearch */ 94/* a simple bsearch */
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 6a3b249a2ae1..127e7cfafa55 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -28,12 +28,6 @@
28 28
29#include <asm/sections.h> 29#include <asm/sections.h>
30 30
31#ifdef CONFIG_KALLSYMS_ALL
32#define all_var 1
33#else
34#define all_var 0
35#endif
36
37/* 31/*
38 * These will be re-linked against their real values 32 * These will be re-linked against their real values
39 * during the second link stage. 33 * during the second link stage.
@@ -82,7 +76,7 @@ static inline int is_kernel(unsigned long addr)
82 76
83static int is_ksym_addr(unsigned long addr) 77static int is_ksym_addr(unsigned long addr)
84{ 78{
85 if (all_var) 79 if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
86 return is_kernel(addr); 80 return is_kernel(addr);
87 81
88 return is_kernel_text(addr) || is_kernel_inittext(addr); 82 return is_kernel_text(addr) || is_kernel_inittext(addr);
@@ -280,7 +274,7 @@ static unsigned long get_symbol_pos(unsigned long addr,
280 if (!symbol_end) { 274 if (!symbol_end) {
281 if (is_kernel_inittext(addr)) 275 if (is_kernel_inittext(addr))
282 symbol_end = (unsigned long)_einittext; 276 symbol_end = (unsigned long)_einittext;
283 else if (all_var) 277 else if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
284 symbol_end = (unsigned long)_end; 278 symbol_end = (unsigned long)_end;
285 else 279 else
286 symbol_end = (unsigned long)_etext; 280 symbol_end = (unsigned long)_etext;
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 23cd70651238..df1a9aa602a0 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -234,7 +234,7 @@ static struct attribute * kernel_attrs[] = {
234 NULL 234 NULL
235}; 235};
236 236
237static struct attribute_group kernel_attr_group = { 237static const struct attribute_group kernel_attr_group = {
238 .attrs = kernel_attrs, 238 .attrs = kernel_attrs,
239}; 239};
240 240
diff --git a/kernel/module.c b/kernel/module.c
index b3dbdde82e80..b0f92a365140 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -4196,7 +4196,7 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
4196 goto out; 4196 goto out;
4197 4197
4198 e = search_extable(mod->extable, 4198 e = search_extable(mod->extable,
4199 mod->extable + mod->num_exentries - 1, 4199 mod->num_exentries,
4200 addr); 4200 addr);
4201out: 4201out:
4202 preempt_enable(); 4202 preempt_enable();
diff --git a/kernel/signal.c b/kernel/signal.c
index 48a59eefd8ad..caed9133ae52 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1402,6 +1402,10 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid)
1402 return ret; 1402 return ret;
1403 } 1403 }
1404 1404
1405 /* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */
1406 if (pid == INT_MIN)
1407 return -ESRCH;
1408
1405 read_lock(&tasklist_lock); 1409 read_lock(&tasklist_lock);
1406 if (pid != -1) { 1410 if (pid != -1) {
1407 ret = __kill_pgrp_info(sig, info, 1411 ret = __kill_pgrp_info(sig, info,
diff --git a/kernel/sys.c b/kernel/sys.c
index 47d901586b4e..73fc0af147d0 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2360,7 +2360,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
2360 case PR_GET_THP_DISABLE: 2360 case PR_GET_THP_DISABLE:
2361 if (arg2 || arg3 || arg4 || arg5) 2361 if (arg2 || arg3 || arg4 || arg5)
2362 return -EINVAL; 2362 return -EINVAL;
2363 error = !!(me->mm->def_flags & VM_NOHUGEPAGE); 2363 error = !!test_bit(MMF_DISABLE_THP, &me->mm->flags);
2364 break; 2364 break;
2365 case PR_SET_THP_DISABLE: 2365 case PR_SET_THP_DISABLE:
2366 if (arg3 || arg4 || arg5) 2366 if (arg3 || arg4 || arg5)
@@ -2368,9 +2368,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
2368 if (down_write_killable(&me->mm->mmap_sem)) 2368 if (down_write_killable(&me->mm->mmap_sem))
2369 return -EINTR; 2369 return -EINTR;
2370 if (arg2) 2370 if (arg2)
2371 me->mm->def_flags |= VM_NOHUGEPAGE; 2371 set_bit(MMF_DISABLE_THP, &me->mm->flags);
2372 else 2372 else
2373 me->mm->def_flags &= ~VM_NOHUGEPAGE; 2373 clear_bit(MMF_DISABLE_THP, &me->mm->flags);
2374 up_write(&me->mm->mmap_sem); 2374 up_write(&me->mm->mmap_sem);
2375 break; 2375 break;
2376 case PR_MPX_ENABLE_MANAGEMENT: 2376 case PR_MPX_ENABLE_MANAGEMENT: