aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:35:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 19:35:10 -0400
commit57d326169e878a1a37b2bccd1cf81f6809ee67b9 (patch)
tree86ed74ae4dc2beaebce1c67b8459f1873b777d3a /kernel
parent7b215de3d0abbc4f6daf2efd19e8809af0564490 (diff)
parent0244756edc4b98c129e92c7061d9f383708cf786 (diff)
Merge branch 'akpm' (patches from Andrew Morton) into next
Merge more updates from Andrew Morton: - Most of the rest of MM. This includes "mark remap_file_pages syscall as deprecated" but the actual "replace remap_file_pages syscall with emulation" is held back. I guess we'll need to work out when to pull the trigger on that one. - various minor cleanups to obscure filesystems - the drivers/rtc queue - hfsplus updates - ufs, hpfs, fatfs, affs, reiserfs - Documentation/ - signals - procfs - cpu hotplug - lib/idr.c - rapidio - sysctl - ipc updates * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (171 commits) ufs: sb mutex merge + mutex_destroy powerpc: update comments for generic idle conversion cris: update comments for generic idle conversion idle: remove cpu_idle() forward declarations nbd: zero from and len fields in NBD_CMD_DISCONNECT. mm: convert some level-less printks to pr_* MAINTAINERS: adi-buildroot-devel is moderated MAINTAINERS: add linux-api for review of API/ABI changes mm/kmemleak-test.c: use pr_fmt for logging fs/dlm/debug_fs.c: replace seq_printf by seq_puts fs/dlm/lockspace.c: convert simple_str to kstr fs/dlm/config.c: convert simple_str to kstr mm: mark remap_file_pages() syscall as deprecated mm: memcontrol: remove unnecessary memcg argument from soft limit functions mm: memcontrol: clean up memcg zoneinfo lookup mm/memblock.c: call kmemleak directly from memblock_(alloc|free) mm/mempool.c: update the kmemleak stack trace for mempool allocations lib/radix-tree.c: update the kmemleak stack trace for radix tree allocations mm: introduce kmemleak_update_trace() mm/kmemleak.c: use %u to print ->checksum ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/acct.c6
-rw-r--r--kernel/audit.c2
-rw-r--r--kernel/exit.c39
-rw-r--r--kernel/fork.c10
-rw-r--r--kernel/kexec.c69
-rw-r--r--kernel/kmod.c5
-rw-r--r--kernel/panic.c23
-rw-r--r--kernel/profile.c20
-rw-r--r--kernel/seccomp.c4
-rw-r--r--kernel/signal.c91
-rw-r--r--kernel/smp.c18
-rw-r--r--kernel/sysctl.c94
-rw-r--r--kernel/user_namespace.c33
-rw-r--r--kernel/utsname_sysctl.c6
14 files changed, 234 insertions, 186 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 8d6e145138bb..808a86ff229d 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -55,7 +55,7 @@
55#include <linux/times.h> 55#include <linux/times.h>
56#include <linux/syscalls.h> 56#include <linux/syscalls.h>
57#include <linux/mount.h> 57#include <linux/mount.h>
58#include <asm/uaccess.h> 58#include <linux/uaccess.h>
59#include <asm/div64.h> 59#include <asm/div64.h>
60#include <linux/blkdev.h> /* sector_div */ 60#include <linux/blkdev.h> /* sector_div */
61#include <linux/pid_namespace.h> 61#include <linux/pid_namespace.h>
@@ -134,7 +134,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
134 spin_lock(&acct_lock); 134 spin_lock(&acct_lock);
135 if (file != acct->file) { 135 if (file != acct->file) {
136 if (act) 136 if (act)
137 res = act>0; 137 res = act > 0;
138 goto out; 138 goto out;
139 } 139 }
140 140
@@ -262,7 +262,7 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
262 if (name) { 262 if (name) {
263 struct filename *tmp = getname(name); 263 struct filename *tmp = getname(name);
264 if (IS_ERR(tmp)) 264 if (IS_ERR(tmp))
265 return (PTR_ERR(tmp)); 265 return PTR_ERR(tmp);
266 error = acct_on(tmp); 266 error = acct_on(tmp);
267 putname(tmp); 267 putname(tmp);
268 } else { 268 } else {
diff --git a/kernel/audit.c b/kernel/audit.c
index 47845c57eb19..f30106459a32 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -44,7 +44,7 @@
44#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 44#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 45
46#include <linux/init.h> 46#include <linux/init.h>
47#include <asm/types.h> 47#include <linux/types.h>
48#include <linux/atomic.h> 48#include <linux/atomic.h>
49#include <linux/mm.h> 49#include <linux/mm.h>
50#include <linux/export.h> 50#include <linux/export.h>
diff --git a/kernel/exit.c b/kernel/exit.c
index 750c2e594617..e5c4668f1799 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -313,45 +313,6 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
313 } 313 }
314} 314}
315 315
316/*
317 * Let kernel threads use this to say that they allow a certain signal.
318 * Must not be used if kthread was cloned with CLONE_SIGHAND.
319 */
320int allow_signal(int sig)
321{
322 if (!valid_signal(sig) || sig < 1)
323 return -EINVAL;
324
325 spin_lock_irq(&current->sighand->siglock);
326 /* This is only needed for daemonize()'ed kthreads */
327 sigdelset(&current->blocked, sig);
328 /*
329 * Kernel threads handle their own signals. Let the signal code
330 * know it'll be handled, so that they don't get converted to
331 * SIGKILL or just silently dropped.
332 */
333 current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
334 recalc_sigpending();
335 spin_unlock_irq(&current->sighand->siglock);
336 return 0;
337}
338
339EXPORT_SYMBOL(allow_signal);
340
341int disallow_signal(int sig)
342{
343 if (!valid_signal(sig) || sig < 1)
344 return -EINVAL;
345
346 spin_lock_irq(&current->sighand->siglock);
347 current->sighand->action[(sig)-1].sa.sa_handler = SIG_IGN;
348 recalc_sigpending();
349 spin_unlock_irq(&current->sighand->siglock);
350 return 0;
351}
352
353EXPORT_SYMBOL(disallow_signal);
354
355#ifdef CONFIG_MEMCG 316#ifdef CONFIG_MEMCG
356/* 317/*
357 * A task is exiting. If it owned this mm, find a new owner for the mm. 318 * A task is exiting. If it owned this mm, find a new owner for the mm.
diff --git a/kernel/fork.c b/kernel/fork.c
index 0d53eb0dfb6f..d2799d1fc952 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1606,10 +1606,12 @@ long do_fork(unsigned long clone_flags,
1606 */ 1606 */
1607 if (!IS_ERR(p)) { 1607 if (!IS_ERR(p)) {
1608 struct completion vfork; 1608 struct completion vfork;
1609 struct pid *pid;
1609 1610
1610 trace_sched_process_fork(current, p); 1611 trace_sched_process_fork(current, p);
1611 1612
1612 nr = task_pid_vnr(p); 1613 pid = get_task_pid(p, PIDTYPE_PID);
1614 nr = pid_vnr(pid);
1613 1615
1614 if (clone_flags & CLONE_PARENT_SETTID) 1616 if (clone_flags & CLONE_PARENT_SETTID)
1615 put_user(nr, parent_tidptr); 1617 put_user(nr, parent_tidptr);
@@ -1624,12 +1626,14 @@ long do_fork(unsigned long clone_flags,
1624 1626
1625 /* forking complete and child started to run, tell ptracer */ 1627 /* forking complete and child started to run, tell ptracer */
1626 if (unlikely(trace)) 1628 if (unlikely(trace))
1627 ptrace_event(trace, nr); 1629 ptrace_event_pid(trace, pid);
1628 1630
1629 if (clone_flags & CLONE_VFORK) { 1631 if (clone_flags & CLONE_VFORK) {
1630 if (!wait_for_vfork_done(p, &vfork)) 1632 if (!wait_for_vfork_done(p, &vfork))
1631 ptrace_event(PTRACE_EVENT_VFORK_DONE, nr); 1633 ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid);
1632 } 1634 }
1635
1636 put_pid(pid);
1633 } else { 1637 } else {
1634 nr = PTR_ERR(p); 1638 nr = PTR_ERR(p);
1635 } 1639 }
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 28c57069ef68..6748688813d0 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -125,8 +125,8 @@ static struct page *kimage_alloc_page(struct kimage *image,
125 unsigned long dest); 125 unsigned long dest);
126 126
127static int do_kimage_alloc(struct kimage **rimage, unsigned long entry, 127static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
128 unsigned long nr_segments, 128 unsigned long nr_segments,
129 struct kexec_segment __user *segments) 129 struct kexec_segment __user *segments)
130{ 130{
131 size_t segment_bytes; 131 size_t segment_bytes;
132 struct kimage *image; 132 struct kimage *image;
@@ -257,13 +257,13 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
257 image->control_code_page = kimage_alloc_control_pages(image, 257 image->control_code_page = kimage_alloc_control_pages(image,
258 get_order(KEXEC_CONTROL_PAGE_SIZE)); 258 get_order(KEXEC_CONTROL_PAGE_SIZE));
259 if (!image->control_code_page) { 259 if (!image->control_code_page) {
260 printk(KERN_ERR "Could not allocate control_code_buffer\n"); 260 pr_err("Could not allocate control_code_buffer\n");
261 goto out_free; 261 goto out_free;
262 } 262 }
263 263
264 image->swap_page = kimage_alloc_control_pages(image, 0); 264 image->swap_page = kimage_alloc_control_pages(image, 0);
265 if (!image->swap_page) { 265 if (!image->swap_page) {
266 printk(KERN_ERR "Could not allocate swap buffer\n"); 266 pr_err("Could not allocate swap buffer\n");
267 goto out_free; 267 goto out_free;
268 } 268 }
269 269
@@ -332,7 +332,7 @@ static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry,
332 image->control_code_page = kimage_alloc_control_pages(image, 332 image->control_code_page = kimage_alloc_control_pages(image,
333 get_order(KEXEC_CONTROL_PAGE_SIZE)); 333 get_order(KEXEC_CONTROL_PAGE_SIZE));
334 if (!image->control_code_page) { 334 if (!image->control_code_page) {
335 printk(KERN_ERR "Could not allocate control_code_buffer\n"); 335 pr_err("Could not allocate control_code_buffer\n");
336 goto out_free; 336 goto out_free;
337 } 337 }
338 338
@@ -621,8 +621,8 @@ static void kimage_terminate(struct kimage *image)
621 621
622#define for_each_kimage_entry(image, ptr, entry) \ 622#define for_each_kimage_entry(image, ptr, entry) \
623 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \ 623 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
624 ptr = (entry & IND_INDIRECTION)? \ 624 ptr = (entry & IND_INDIRECTION) ? \
625 phys_to_virt((entry & PAGE_MASK)): ptr +1) 625 phys_to_virt((entry & PAGE_MASK)) : ptr + 1)
626 626
627static void kimage_free_entry(kimage_entry_t entry) 627static void kimage_free_entry(kimage_entry_t entry)
628{ 628{
@@ -650,8 +650,7 @@ static void kimage_free(struct kimage *image)
650 * done with it. 650 * done with it.
651 */ 651 */
652 ind = entry; 652 ind = entry;
653 } 653 } else if (entry & IND_SOURCE)
654 else if (entry & IND_SOURCE)
655 kimage_free_entry(entry); 654 kimage_free_entry(entry);
656 } 655 }
657 /* Free the final indirection page */ 656 /* Free the final indirection page */
@@ -774,8 +773,7 @@ static struct page *kimage_alloc_page(struct kimage *image,
774 addr = old_addr; 773 addr = old_addr;
775 page = old_page; 774 page = old_page;
776 break; 775 break;
777 } 776 } else {
778 else {
779 /* Place the page on the destination list I 777 /* Place the page on the destination list I
780 * will use it later. 778 * will use it later.
781 */ 779 */
@@ -1059,7 +1057,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
1059 return -EINVAL; 1057 return -EINVAL;
1060 1058
1061 ksegments = compat_alloc_user_space(nr_segments * sizeof(out)); 1059 ksegments = compat_alloc_user_space(nr_segments * sizeof(out));
1062 for (i=0; i < nr_segments; i++) { 1060 for (i = 0; i < nr_segments; i++) {
1063 result = copy_from_user(&in, &segments[i], sizeof(in)); 1061 result = copy_from_user(&in, &segments[i], sizeof(in));
1064 if (result) 1062 if (result)
1065 return -EFAULT; 1063 return -EFAULT;
@@ -1214,14 +1212,14 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
1214 * squirrelled away. ELF notes happen to provide 1212 * squirrelled away. ELF notes happen to provide
1215 * all of that, so there is no need to invent something new. 1213 * all of that, so there is no need to invent something new.
1216 */ 1214 */
1217 buf = (u32*)per_cpu_ptr(crash_notes, cpu); 1215 buf = (u32 *)per_cpu_ptr(crash_notes, cpu);
1218 if (!buf) 1216 if (!buf)
1219 return; 1217 return;
1220 memset(&prstatus, 0, sizeof(prstatus)); 1218 memset(&prstatus, 0, sizeof(prstatus));
1221 prstatus.pr_pid = current->pid; 1219 prstatus.pr_pid = current->pid;
1222 elf_core_copy_kernel_regs(&prstatus.pr_reg, regs); 1220 elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);
1223 buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, 1221 buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS,
1224 &prstatus, sizeof(prstatus)); 1222 &prstatus, sizeof(prstatus));
1225 final_note(buf); 1223 final_note(buf);
1226} 1224}
1227 1225
@@ -1230,8 +1228,7 @@ static int __init crash_notes_memory_init(void)
1230 /* Allocate memory for saving cpu registers. */ 1228 /* Allocate memory for saving cpu registers. */
1231 crash_notes = alloc_percpu(note_buf_t); 1229 crash_notes = alloc_percpu(note_buf_t);
1232 if (!crash_notes) { 1230 if (!crash_notes) {
1233 printk("Kexec: Memory allocation for saving cpu register" 1231 pr_warn("Kexec: Memory allocation for saving cpu register states failed\n");
1234 " states failed\n");
1235 return -ENOMEM; 1232 return -ENOMEM;
1236 } 1233 }
1237 return 0; 1234 return 0;
@@ -1253,10 +1250,10 @@ subsys_initcall(crash_notes_memory_init);
1253 * 1250 *
1254 * The function returns 0 on success and -EINVAL on failure. 1251 * The function returns 0 on success and -EINVAL on failure.
1255 */ 1252 */
1256static int __init parse_crashkernel_mem(char *cmdline, 1253static int __init parse_crashkernel_mem(char *cmdline,
1257 unsigned long long system_ram, 1254 unsigned long long system_ram,
1258 unsigned long long *crash_size, 1255 unsigned long long *crash_size,
1259 unsigned long long *crash_base) 1256 unsigned long long *crash_base)
1260{ 1257{
1261 char *cur = cmdline, *tmp; 1258 char *cur = cmdline, *tmp;
1262 1259
@@ -1267,12 +1264,12 @@ static int __init parse_crashkernel_mem(char *cmdline,
1267 /* get the start of the range */ 1264 /* get the start of the range */
1268 start = memparse(cur, &tmp); 1265 start = memparse(cur, &tmp);
1269 if (cur == tmp) { 1266 if (cur == tmp) {
1270 pr_warning("crashkernel: Memory value expected\n"); 1267 pr_warn("crashkernel: Memory value expected\n");
1271 return -EINVAL; 1268 return -EINVAL;
1272 } 1269 }
1273 cur = tmp; 1270 cur = tmp;
1274 if (*cur != '-') { 1271 if (*cur != '-') {
1275 pr_warning("crashkernel: '-' expected\n"); 1272 pr_warn("crashkernel: '-' expected\n");
1276 return -EINVAL; 1273 return -EINVAL;
1277 } 1274 }
1278 cur++; 1275 cur++;
@@ -1281,31 +1278,30 @@ static int __init parse_crashkernel_mem(char *cmdline,
1281 if (*cur != ':') { 1278 if (*cur != ':') {
1282 end = memparse(cur, &tmp); 1279 end = memparse(cur, &tmp);
1283 if (cur == tmp) { 1280 if (cur == tmp) {
1284 pr_warning("crashkernel: Memory " 1281 pr_warn("crashkernel: Memory value expected\n");
1285 "value expected\n");
1286 return -EINVAL; 1282 return -EINVAL;
1287 } 1283 }
1288 cur = tmp; 1284 cur = tmp;
1289 if (end <= start) { 1285 if (end <= start) {
1290 pr_warning("crashkernel: end <= start\n"); 1286 pr_warn("crashkernel: end <= start\n");
1291 return -EINVAL; 1287 return -EINVAL;
1292 } 1288 }
1293 } 1289 }
1294 1290
1295 if (*cur != ':') { 1291 if (*cur != ':') {
1296 pr_warning("crashkernel: ':' expected\n"); 1292 pr_warn("crashkernel: ':' expected\n");
1297 return -EINVAL; 1293 return -EINVAL;
1298 } 1294 }
1299 cur++; 1295 cur++;
1300 1296
1301 size = memparse(cur, &tmp); 1297 size = memparse(cur, &tmp);
1302 if (cur == tmp) { 1298 if (cur == tmp) {
1303 pr_warning("Memory value expected\n"); 1299 pr_warn("Memory value expected\n");
1304 return -EINVAL; 1300 return -EINVAL;
1305 } 1301 }
1306 cur = tmp; 1302 cur = tmp;
1307 if (size >= system_ram) { 1303 if (size >= system_ram) {
1308 pr_warning("crashkernel: invalid size\n"); 1304 pr_warn("crashkernel: invalid size\n");
1309 return -EINVAL; 1305 return -EINVAL;
1310 } 1306 }
1311 1307
@@ -1323,8 +1319,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
1323 cur++; 1319 cur++;
1324 *crash_base = memparse(cur, &tmp); 1320 *crash_base = memparse(cur, &tmp);
1325 if (cur == tmp) { 1321 if (cur == tmp) {
1326 pr_warning("Memory value expected " 1322 pr_warn("Memory value expected after '@'\n");
1327 "after '@'\n");
1328 return -EINVAL; 1323 return -EINVAL;
1329 } 1324 }
1330 } 1325 }
@@ -1336,26 +1331,26 @@ static int __init parse_crashkernel_mem(char *cmdline,
1336/* 1331/*
1337 * That function parses "simple" (old) crashkernel command lines like 1332 * That function parses "simple" (old) crashkernel command lines like
1338 * 1333 *
1339 * crashkernel=size[@offset] 1334 * crashkernel=size[@offset]
1340 * 1335 *
1341 * It returns 0 on success and -EINVAL on failure. 1336 * It returns 0 on success and -EINVAL on failure.
1342 */ 1337 */
1343static int __init parse_crashkernel_simple(char *cmdline, 1338static int __init parse_crashkernel_simple(char *cmdline,
1344 unsigned long long *crash_size, 1339 unsigned long long *crash_size,
1345 unsigned long long *crash_base) 1340 unsigned long long *crash_base)
1346{ 1341{
1347 char *cur = cmdline; 1342 char *cur = cmdline;
1348 1343
1349 *crash_size = memparse(cmdline, &cur); 1344 *crash_size = memparse(cmdline, &cur);
1350 if (cmdline == cur) { 1345 if (cmdline == cur) {
1351 pr_warning("crashkernel: memory value expected\n"); 1346 pr_warn("crashkernel: memory value expected\n");
1352 return -EINVAL; 1347 return -EINVAL;
1353 } 1348 }
1354 1349
1355 if (*cur == '@') 1350 if (*cur == '@')
1356 *crash_base = memparse(cur+1, &cur); 1351 *crash_base = memparse(cur+1, &cur);
1357 else if (*cur != ' ' && *cur != '\0') { 1352 else if (*cur != ' ' && *cur != '\0') {
1358 pr_warning("crashkernel: unrecognized char\n"); 1353 pr_warn("crashkernel: unrecognized char\n");
1359 return -EINVAL; 1354 return -EINVAL;
1360 } 1355 }
1361 1356
@@ -1691,7 +1686,7 @@ int kernel_kexec(void)
1691 * CPU hotplug again; so re-enable it here. 1686 * CPU hotplug again; so re-enable it here.
1692 */ 1687 */
1693 cpu_hotplug_enable(); 1688 cpu_hotplug_enable();
1694 printk(KERN_EMERG "Starting new kernel\n"); 1689 pr_emerg("Starting new kernel\n");
1695 machine_shutdown(); 1690 machine_shutdown();
1696 } 1691 }
1697 1692
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 0ac67a5861c5..8637e041a247 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -285,10 +285,7 @@ static int wait_for_helper(void *data)
285 pid_t pid; 285 pid_t pid;
286 286
287 /* If SIGCLD is ignored sys_wait4 won't populate the status. */ 287 /* If SIGCLD is ignored sys_wait4 won't populate the status. */
288 spin_lock_irq(&current->sighand->siglock); 288 kernel_sigaction(SIGCHLD, SIG_DFL);
289 current->sighand->action[SIGCHLD-1].sa.sa_handler = SIG_DFL;
290 spin_unlock_irq(&current->sighand->siglock);
291
292 pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD); 289 pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD);
293 if (pid < 0) { 290 if (pid < 0) {
294 sub_info->retval = pid; 291 sub_info->retval = pid;
diff --git a/kernel/panic.c b/kernel/panic.c
index d02fa9fef46a..62e16cef9cc2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -32,6 +32,7 @@ static unsigned long tainted_mask;
32static int pause_on_oops; 32static int pause_on_oops;
33static int pause_on_oops_flag; 33static int pause_on_oops_flag;
34static DEFINE_SPINLOCK(pause_on_oops_lock); 34static DEFINE_SPINLOCK(pause_on_oops_lock);
35static bool crash_kexec_post_notifiers;
35 36
36int panic_timeout = CONFIG_PANIC_TIMEOUT; 37int panic_timeout = CONFIG_PANIC_TIMEOUT;
37EXPORT_SYMBOL_GPL(panic_timeout); 38EXPORT_SYMBOL_GPL(panic_timeout);
@@ -112,9 +113,11 @@ void panic(const char *fmt, ...)
112 /* 113 /*
113 * If we have crashed and we have a crash kernel loaded let it handle 114 * If we have crashed and we have a crash kernel loaded let it handle
114 * everything else. 115 * everything else.
115 * Do we want to call this before we try to display a message? 116 * If we want to run this after calling panic_notifiers, pass
117 * the "crash_kexec_post_notifiers" option to the kernel.
116 */ 118 */
117 crash_kexec(NULL); 119 if (!crash_kexec_post_notifiers)
120 crash_kexec(NULL);
118 121
119 /* 122 /*
120 * Note smp_send_stop is the usual smp shutdown function, which 123 * Note smp_send_stop is the usual smp shutdown function, which
@@ -131,6 +134,15 @@ void panic(const char *fmt, ...)
131 134
132 kmsg_dump(KMSG_DUMP_PANIC); 135 kmsg_dump(KMSG_DUMP_PANIC);
133 136
137 /*
138 * If you doubt kdump always works fine in any situation,
139 * "crash_kexec_post_notifiers" offers you a chance to run
140 * panic_notifiers and dumping kmsg before kdump.
141 * Note: since some panic_notifiers can make crashed kernel
142 * more unstable, it can increase risks of the kdump failure too.
143 */
144 crash_kexec(NULL);
145
134 bust_spinlocks(0); 146 bust_spinlocks(0);
135 147
136 if (!panic_blink) 148 if (!panic_blink)
@@ -472,6 +484,13 @@ EXPORT_SYMBOL(__stack_chk_fail);
472core_param(panic, panic_timeout, int, 0644); 484core_param(panic, panic_timeout, int, 0644);
473core_param(pause_on_oops, pause_on_oops, int, 0644); 485core_param(pause_on_oops, pause_on_oops, int, 0644);
474 486
487static int __init setup_crash_kexec_post_notifiers(char *s)
488{
489 crash_kexec_post_notifiers = true;
490 return 0;
491}
492early_param("crash_kexec_post_notifiers", setup_crash_kexec_post_notifiers);
493
475static int __init oops_setup(char *s) 494static int __init oops_setup(char *s)
476{ 495{
477 if (!s) 496 if (!s)
diff --git a/kernel/profile.c b/kernel/profile.c
index cb980f0c731b..54bf5ba26420 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -52,9 +52,9 @@ static DEFINE_MUTEX(profile_flip_mutex);
52 52
53int profile_setup(char *str) 53int profile_setup(char *str)
54{ 54{
55 static char schedstr[] = "schedule"; 55 static const char schedstr[] = "schedule";
56 static char sleepstr[] = "sleep"; 56 static const char sleepstr[] = "sleep";
57 static char kvmstr[] = "kvm"; 57 static const char kvmstr[] = "kvm";
58 int par; 58 int par;
59 59
60 if (!strncmp(str, sleepstr, strlen(sleepstr))) { 60 if (!strncmp(str, sleepstr, strlen(sleepstr))) {
@@ -64,12 +64,10 @@ int profile_setup(char *str)
64 str += strlen(sleepstr) + 1; 64 str += strlen(sleepstr) + 1;
65 if (get_option(&str, &par)) 65 if (get_option(&str, &par))
66 prof_shift = par; 66 prof_shift = par;
67 printk(KERN_INFO 67 pr_info("kernel sleep profiling enabled (shift: %ld)\n",
68 "kernel sleep profiling enabled (shift: %ld)\n",
69 prof_shift); 68 prof_shift);
70#else 69#else
71 printk(KERN_WARNING 70 pr_warn("kernel sleep profiling requires CONFIG_SCHEDSTATS\n");
72 "kernel sleep profiling requires CONFIG_SCHEDSTATS\n");
73#endif /* CONFIG_SCHEDSTATS */ 71#endif /* CONFIG_SCHEDSTATS */
74 } else if (!strncmp(str, schedstr, strlen(schedstr))) { 72 } else if (!strncmp(str, schedstr, strlen(schedstr))) {
75 prof_on = SCHED_PROFILING; 73 prof_on = SCHED_PROFILING;
@@ -77,8 +75,7 @@ int profile_setup(char *str)
77 str += strlen(schedstr) + 1; 75 str += strlen(schedstr) + 1;
78 if (get_option(&str, &par)) 76 if (get_option(&str, &par))
79 prof_shift = par; 77 prof_shift = par;
80 printk(KERN_INFO 78 pr_info("kernel schedule profiling enabled (shift: %ld)\n",
81 "kernel schedule profiling enabled (shift: %ld)\n",
82 prof_shift); 79 prof_shift);
83 } else if (!strncmp(str, kvmstr, strlen(kvmstr))) { 80 } else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
84 prof_on = KVM_PROFILING; 81 prof_on = KVM_PROFILING;
@@ -86,13 +83,12 @@ int profile_setup(char *str)
86 str += strlen(kvmstr) + 1; 83 str += strlen(kvmstr) + 1;
87 if (get_option(&str, &par)) 84 if (get_option(&str, &par))
88 prof_shift = par; 85 prof_shift = par;
89 printk(KERN_INFO 86 pr_info("kernel KVM profiling enabled (shift: %ld)\n",
90 "kernel KVM profiling enabled (shift: %ld)\n",
91 prof_shift); 87 prof_shift);
92 } else if (get_option(&str, &par)) { 88 } else if (get_option(&str, &par)) {
93 prof_shift = par; 89 prof_shift = par;
94 prof_on = CPU_PROFILING; 90 prof_on = CPU_PROFILING;
95 printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n", 91 pr_info("kernel profiling enabled (shift: %ld)\n",
96 prof_shift); 92 prof_shift);
97 } 93 }
98 return 1; 94 return 1;
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index b35c21503a36..f6d76bebe69f 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -39,7 +39,7 @@
39 * is only needed for handling filters shared across tasks. 39 * is only needed for handling filters shared across tasks.
40 * @prev: points to a previously installed, or inherited, filter 40 * @prev: points to a previously installed, or inherited, filter
41 * @len: the number of instructions in the program 41 * @len: the number of instructions in the program
42 * @insns: the BPF program instructions to evaluate 42 * @insnsi: the BPF program instructions to evaluate
43 * 43 *
44 * seccomp_filter objects are organized in a tree linked via the @prev 44 * seccomp_filter objects are organized in a tree linked via the @prev
45 * pointer. For any task, it appears to be a singly-linked list starting 45 * pointer. For any task, it appears to be a singly-linked list starting
@@ -220,7 +220,7 @@ static long seccomp_attach_filter(struct sock_fprog *fprog)
220 return -ENOMEM; 220 return -ENOMEM;
221 221
222 /* 222 /*
223 * Installing a seccomp filter requires that the task have 223 * Installing a seccomp filter requires that the task has
224 * CAP_SYS_ADMIN in its namespace or be running with no_new_privs. 224 * CAP_SYS_ADMIN in its namespace or be running with no_new_privs.
225 * This avoids scenarios where unprivileged tasks can affect the 225 * This avoids scenarios where unprivileged tasks can affect the
226 * behavior of privileged children. 226 * behavior of privileged children.
diff --git a/kernel/signal.c b/kernel/signal.c
index 6e600aaa2af4..a4077e90f19f 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -277,6 +277,7 @@ void task_clear_jobctl_trapping(struct task_struct *task)
277{ 277{
278 if (unlikely(task->jobctl & JOBCTL_TRAPPING)) { 278 if (unlikely(task->jobctl & JOBCTL_TRAPPING)) {
279 task->jobctl &= ~JOBCTL_TRAPPING; 279 task->jobctl &= ~JOBCTL_TRAPPING;
280 smp_mb(); /* advised by wake_up_bit() */
280 wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT); 281 wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT);
281 } 282 }
282} 283}
@@ -705,11 +706,8 @@ void signal_wake_up_state(struct task_struct *t, unsigned int state)
705 * Returns 1 if any signals were found. 706 * Returns 1 if any signals were found.
706 * 707 *
707 * All callers must be holding the siglock. 708 * All callers must be holding the siglock.
708 *
709 * This version takes a sigset mask and looks at all signals,
710 * not just those in the first mask word.
711 */ 709 */
712static int rm_from_queue_full(sigset_t *mask, struct sigpending *s) 710static int flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
713{ 711{
714 struct sigqueue *q, *n; 712 struct sigqueue *q, *n;
715 sigset_t m; 713 sigset_t m;
@@ -727,29 +725,6 @@ static int rm_from_queue_full(sigset_t *mask, struct sigpending *s)
727 } 725 }
728 return 1; 726 return 1;
729} 727}
730/*
731 * Remove signals in mask from the pending set and queue.
732 * Returns 1 if any signals were found.
733 *
734 * All callers must be holding the siglock.
735 */
736static int rm_from_queue(unsigned long mask, struct sigpending *s)
737{
738 struct sigqueue *q, *n;
739
740 if (!sigtestsetmask(&s->signal, mask))
741 return 0;
742
743 sigdelsetmask(&s->signal, mask);
744 list_for_each_entry_safe(q, n, &s->list, list) {
745 if (q->info.si_signo < SIGRTMIN &&
746 (mask & sigmask(q->info.si_signo))) {
747 list_del_init(&q->list);
748 __sigqueue_free(q);
749 }
750 }
751 return 1;
752}
753 728
754static inline int is_si_special(const struct siginfo *info) 729static inline int is_si_special(const struct siginfo *info)
755{ 730{
@@ -861,6 +836,7 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force)
861{ 836{
862 struct signal_struct *signal = p->signal; 837 struct signal_struct *signal = p->signal;
863 struct task_struct *t; 838 struct task_struct *t;
839 sigset_t flush;
864 840
865 if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) { 841 if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) {
866 if (signal->flags & SIGNAL_GROUP_COREDUMP) 842 if (signal->flags & SIGNAL_GROUP_COREDUMP)
@@ -872,26 +848,25 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force)
872 /* 848 /*
873 * This is a stop signal. Remove SIGCONT from all queues. 849 * This is a stop signal. Remove SIGCONT from all queues.
874 */ 850 */
875 rm_from_queue(sigmask(SIGCONT), &signal->shared_pending); 851 siginitset(&flush, sigmask(SIGCONT));
876 t = p; 852 flush_sigqueue_mask(&flush, &signal->shared_pending);
877 do { 853 for_each_thread(p, t)
878 rm_from_queue(sigmask(SIGCONT), &t->pending); 854 flush_sigqueue_mask(&flush, &t->pending);
879 } while_each_thread(p, t);
880 } else if (sig == SIGCONT) { 855 } else if (sig == SIGCONT) {
881 unsigned int why; 856 unsigned int why;
882 /* 857 /*
883 * Remove all stop signals from all queues, wake all threads. 858 * Remove all stop signals from all queues, wake all threads.
884 */ 859 */
885 rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending); 860 siginitset(&flush, SIG_KERNEL_STOP_MASK);
886 t = p; 861 flush_sigqueue_mask(&flush, &signal->shared_pending);
887 do { 862 for_each_thread(p, t) {
863 flush_sigqueue_mask(&flush, &t->pending);
888 task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING); 864 task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
889 rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
890 if (likely(!(t->ptrace & PT_SEIZED))) 865 if (likely(!(t->ptrace & PT_SEIZED)))
891 wake_up_state(t, __TASK_STOPPED); 866 wake_up_state(t, __TASK_STOPPED);
892 else 867 else
893 ptrace_trap_notify(t); 868 ptrace_trap_notify(t);
894 } while_each_thread(p, t); 869 }
895 870
896 /* 871 /*
897 * Notify the parent with CLD_CONTINUED if we were stopped. 872 * Notify the parent with CLD_CONTINUED if we were stopped.
@@ -2854,7 +2829,7 @@ int do_sigtimedwait(const sigset_t *which, siginfo_t *info,
2854 2829
2855 spin_lock_irq(&tsk->sighand->siglock); 2830 spin_lock_irq(&tsk->sighand->siglock);
2856 __set_task_blocked(tsk, &tsk->real_blocked); 2831 __set_task_blocked(tsk, &tsk->real_blocked);
2857 siginitset(&tsk->real_blocked, 0); 2832 sigemptyset(&tsk->real_blocked);
2858 sig = dequeue_signal(tsk, &mask, info); 2833 sig = dequeue_signal(tsk, &mask, info);
2859 } 2834 }
2860 spin_unlock_irq(&tsk->sighand->siglock); 2835 spin_unlock_irq(&tsk->sighand->siglock);
@@ -3091,18 +3066,39 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
3091} 3066}
3092#endif 3067#endif
3093 3068
3069/*
3070 * For kthreads only, must not be used if cloned with CLONE_SIGHAND
3071 */
3072void kernel_sigaction(int sig, __sighandler_t action)
3073{
3074 spin_lock_irq(&current->sighand->siglock);
3075 current->sighand->action[sig - 1].sa.sa_handler = action;
3076 if (action == SIG_IGN) {
3077 sigset_t mask;
3078
3079 sigemptyset(&mask);
3080 sigaddset(&mask, sig);
3081
3082 flush_sigqueue_mask(&mask, &current->signal->shared_pending);
3083 flush_sigqueue_mask(&mask, &current->pending);
3084 recalc_sigpending();
3085 }
3086 spin_unlock_irq(&current->sighand->siglock);
3087}
3088EXPORT_SYMBOL(kernel_sigaction);
3089
3094int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) 3090int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
3095{ 3091{
3096 struct task_struct *t = current; 3092 struct task_struct *p = current, *t;
3097 struct k_sigaction *k; 3093 struct k_sigaction *k;
3098 sigset_t mask; 3094 sigset_t mask;
3099 3095
3100 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig))) 3096 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
3101 return -EINVAL; 3097 return -EINVAL;
3102 3098
3103 k = &t->sighand->action[sig-1]; 3099 k = &p->sighand->action[sig-1];
3104 3100
3105 spin_lock_irq(&current->sighand->siglock); 3101 spin_lock_irq(&p->sighand->siglock);
3106 if (oact) 3102 if (oact)
3107 *oact = *k; 3103 *oact = *k;
3108 3104
@@ -3121,21 +3117,20 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
3121 * (for example, SIGCHLD), shall cause the pending signal to 3117 * (for example, SIGCHLD), shall cause the pending signal to
3122 * be discarded, whether or not it is blocked" 3118 * be discarded, whether or not it is blocked"
3123 */ 3119 */
3124 if (sig_handler_ignored(sig_handler(t, sig), sig)) { 3120 if (sig_handler_ignored(sig_handler(p, sig), sig)) {
3125 sigemptyset(&mask); 3121 sigemptyset(&mask);
3126 sigaddset(&mask, sig); 3122 sigaddset(&mask, sig);
3127 rm_from_queue_full(&mask, &t->signal->shared_pending); 3123 flush_sigqueue_mask(&mask, &p->signal->shared_pending);
3128 do { 3124 for_each_thread(p, t)
3129 rm_from_queue_full(&mask, &t->pending); 3125 flush_sigqueue_mask(&mask, &t->pending);
3130 } while_each_thread(current, t);
3131 } 3126 }
3132 } 3127 }
3133 3128
3134 spin_unlock_irq(&current->sighand->siglock); 3129 spin_unlock_irq(&p->sighand->siglock);
3135 return 0; 3130 return 0;
3136} 3131}
3137 3132
3138static int 3133static int
3139do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long sp) 3134do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long sp)
3140{ 3135{
3141 stack_t oss; 3136 stack_t oss;
diff --git a/kernel/smp.c b/kernel/smp.c
index 06d574e42c72..306f8180b0d5 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -185,14 +185,26 @@ void generic_smp_call_function_single_interrupt(void)
185{ 185{
186 struct llist_node *entry; 186 struct llist_node *entry;
187 struct call_single_data *csd, *csd_next; 187 struct call_single_data *csd, *csd_next;
188 static bool warned;
189
190 entry = llist_del_all(&__get_cpu_var(call_single_queue));
191 entry = llist_reverse_order(entry);
188 192
189 /* 193 /*
190 * Shouldn't receive this interrupt on a cpu that is not yet online. 194 * Shouldn't receive this interrupt on a cpu that is not yet online.
191 */ 195 */
192 WARN_ON_ONCE(!cpu_online(smp_processor_id())); 196 if (unlikely(!cpu_online(smp_processor_id()) && !warned)) {
197 warned = true;
198 WARN(1, "IPI on offline CPU %d\n", smp_processor_id());
193 199
194 entry = llist_del_all(&__get_cpu_var(call_single_queue)); 200 /*
195 entry = llist_reverse_order(entry); 201 * We don't have to use the _safe() variant here
202 * because we are not invoking the IPI handlers yet.
203 */
204 llist_for_each_entry(csd, entry, llist)
205 pr_warn("IPI callback %pS sent to offline CPU\n",
206 csd->func);
207 }
196 208
197 llist_for_each_entry_safe(csd, csd_next, entry, llist) { 209 llist_for_each_entry_safe(csd, csd_next, entry, llist) {
198 csd->func(csd->info); 210 csd->func(csd->info);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 40ce2d983b12..db19e3e2aa4b 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -173,6 +173,13 @@ extern int no_unaligned_warning;
173#endif 173#endif
174 174
175#ifdef CONFIG_PROC_SYSCTL 175#ifdef CONFIG_PROC_SYSCTL
176
177#define SYSCTL_WRITES_LEGACY -1
178#define SYSCTL_WRITES_WARN 0
179#define SYSCTL_WRITES_STRICT 1
180
181static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
182
176static int proc_do_cad_pid(struct ctl_table *table, int write, 183static int proc_do_cad_pid(struct ctl_table *table, int write,
177 void __user *buffer, size_t *lenp, loff_t *ppos); 184 void __user *buffer, size_t *lenp, loff_t *ppos);
178static int proc_taint(struct ctl_table *table, int write, 185static int proc_taint(struct ctl_table *table, int write,
@@ -195,7 +202,7 @@ static int proc_dostring_coredump(struct ctl_table *table, int write,
195/* Note: sysrq code uses it's own private copy */ 202/* Note: sysrq code uses it's own private copy */
196static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; 203static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
197 204
198static int sysrq_sysctl_handler(ctl_table *table, int write, 205static int sysrq_sysctl_handler(struct ctl_table *table, int write,
199 void __user *buffer, size_t *lenp, 206 void __user *buffer, size_t *lenp,
200 loff_t *ppos) 207 loff_t *ppos)
201{ 208{
@@ -495,6 +502,15 @@ static struct ctl_table kern_table[] = {
495 .mode = 0644, 502 .mode = 0644,
496 .proc_handler = proc_taint, 503 .proc_handler = proc_taint,
497 }, 504 },
505 {
506 .procname = "sysctl_writes_strict",
507 .data = &sysctl_writes_strict,
508 .maxlen = sizeof(int),
509 .mode = 0644,
510 .proc_handler = proc_dointvec_minmax,
511 .extra1 = &neg_one,
512 .extra2 = &one,
513 },
498#endif 514#endif
499#ifdef CONFIG_LATENCYTOP 515#ifdef CONFIG_LATENCYTOP
500 { 516 {
@@ -1703,8 +1719,8 @@ int __init sysctl_init(void)
1703 1719
1704#ifdef CONFIG_PROC_SYSCTL 1720#ifdef CONFIG_PROC_SYSCTL
1705 1721
1706static int _proc_do_string(void* data, int maxlen, int write, 1722static int _proc_do_string(char *data, int maxlen, int write,
1707 void __user *buffer, 1723 char __user *buffer,
1708 size_t *lenp, loff_t *ppos) 1724 size_t *lenp, loff_t *ppos)
1709{ 1725{
1710 size_t len; 1726 size_t len;
@@ -1717,21 +1733,30 @@ static int _proc_do_string(void* data, int maxlen, int write,
1717 } 1733 }
1718 1734
1719 if (write) { 1735 if (write) {
1720 len = 0; 1736 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1737 /* Only continue writes not past the end of buffer. */
1738 len = strlen(data);
1739 if (len > maxlen - 1)
1740 len = maxlen - 1;
1741
1742 if (*ppos > len)
1743 return 0;
1744 len = *ppos;
1745 } else {
1746 /* Start writing from beginning of buffer. */
1747 len = 0;
1748 }
1749
1750 *ppos += *lenp;
1721 p = buffer; 1751 p = buffer;
1722 while (len < *lenp) { 1752 while ((p - buffer) < *lenp && len < maxlen - 1) {
1723 if (get_user(c, p++)) 1753 if (get_user(c, p++))
1724 return -EFAULT; 1754 return -EFAULT;
1725 if (c == 0 || c == '\n') 1755 if (c == 0 || c == '\n')
1726 break; 1756 break;
1727 len++; 1757 data[len++] = c;
1728 } 1758 }
1729 if (len >= maxlen) 1759 data[len] = 0;
1730 len = maxlen-1;
1731 if(copy_from_user(data, buffer, len))
1732 return -EFAULT;
1733 ((char *) data)[len] = 0;
1734 *ppos += *lenp;
1735 } else { 1760 } else {
1736 len = strlen(data); 1761 len = strlen(data);
1737 if (len > maxlen) 1762 if (len > maxlen)
@@ -1748,10 +1773,10 @@ static int _proc_do_string(void* data, int maxlen, int write,
1748 if (len > *lenp) 1773 if (len > *lenp)
1749 len = *lenp; 1774 len = *lenp;
1750 if (len) 1775 if (len)
1751 if(copy_to_user(buffer, data, len)) 1776 if (copy_to_user(buffer, data, len))
1752 return -EFAULT; 1777 return -EFAULT;
1753 if (len < *lenp) { 1778 if (len < *lenp) {
1754 if(put_user('\n', ((char __user *) buffer) + len)) 1779 if (put_user('\n', buffer + len))
1755 return -EFAULT; 1780 return -EFAULT;
1756 len++; 1781 len++;
1757 } 1782 }
@@ -1761,6 +1786,14 @@ static int _proc_do_string(void* data, int maxlen, int write,
1761 return 0; 1786 return 0;
1762} 1787}
1763 1788
1789static void warn_sysctl_write(struct ctl_table *table)
1790{
1791 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1792 "This will not be supported in the future. To silence this\n"
1793 "warning, set kernel.sysctl_writes_strict = -1\n",
1794 current->comm, table->procname);
1795}
1796
1764/** 1797/**
1765 * proc_dostring - read a string sysctl 1798 * proc_dostring - read a string sysctl
1766 * @table: the sysctl table 1799 * @table: the sysctl table
@@ -1781,8 +1814,11 @@ static int _proc_do_string(void* data, int maxlen, int write,
1781int proc_dostring(struct ctl_table *table, int write, 1814int proc_dostring(struct ctl_table *table, int write,
1782 void __user *buffer, size_t *lenp, loff_t *ppos) 1815 void __user *buffer, size_t *lenp, loff_t *ppos)
1783{ 1816{
1784 return _proc_do_string(table->data, table->maxlen, write, 1817 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1785 buffer, lenp, ppos); 1818 warn_sysctl_write(table);
1819
1820 return _proc_do_string((char *)(table->data), table->maxlen, write,
1821 (char __user *)buffer, lenp, ppos);
1786} 1822}
1787 1823
1788static size_t proc_skip_spaces(char **buf) 1824static size_t proc_skip_spaces(char **buf)
@@ -1956,6 +1992,18 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
1956 conv = do_proc_dointvec_conv; 1992 conv = do_proc_dointvec_conv;
1957 1993
1958 if (write) { 1994 if (write) {
1995 if (*ppos) {
1996 switch (sysctl_writes_strict) {
1997 case SYSCTL_WRITES_STRICT:
1998 goto out;
1999 case SYSCTL_WRITES_WARN:
2000 warn_sysctl_write(table);
2001 break;
2002 default:
2003 break;
2004 }
2005 }
2006
1959 if (left > PAGE_SIZE - 1) 2007 if (left > PAGE_SIZE - 1)
1960 left = PAGE_SIZE - 1; 2008 left = PAGE_SIZE - 1;
1961 page = __get_free_page(GFP_TEMPORARY); 2009 page = __get_free_page(GFP_TEMPORARY);
@@ -2013,6 +2061,7 @@ free:
2013 return err ? : -EINVAL; 2061 return err ? : -EINVAL;
2014 } 2062 }
2015 *lenp -= left; 2063 *lenp -= left;
2064out:
2016 *ppos += *lenp; 2065 *ppos += *lenp;
2017 return err; 2066 return err;
2018} 2067}
@@ -2205,6 +2254,18 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
2205 left = *lenp; 2254 left = *lenp;
2206 2255
2207 if (write) { 2256 if (write) {
2257 if (*ppos) {
2258 switch (sysctl_writes_strict) {
2259 case SYSCTL_WRITES_STRICT:
2260 goto out;
2261 case SYSCTL_WRITES_WARN:
2262 warn_sysctl_write(table);
2263 break;
2264 default:
2265 break;
2266 }
2267 }
2268
2208 if (left > PAGE_SIZE - 1) 2269 if (left > PAGE_SIZE - 1)
2209 left = PAGE_SIZE - 1; 2270 left = PAGE_SIZE - 1;
2210 page = __get_free_page(GFP_TEMPORARY); 2271 page = __get_free_page(GFP_TEMPORARY);
@@ -2260,6 +2321,7 @@ free:
2260 return err ? : -EINVAL; 2321 return err ? : -EINVAL;
2261 } 2322 }
2262 *lenp -= left; 2323 *lenp -= left;
2324out:
2263 *ppos += *lenp; 2325 *ppos += *lenp;
2264 return err; 2326 return err;
2265} 2327}
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index bf71b4b2d632..fcc02560fd6b 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -286,7 +286,7 @@ EXPORT_SYMBOL(from_kuid_munged);
286/** 286/**
287 * make_kgid - Map a user-namespace gid pair into a kgid. 287 * make_kgid - Map a user-namespace gid pair into a kgid.
288 * @ns: User namespace that the gid is in 288 * @ns: User namespace that the gid is in
289 * @uid: group identifier 289 * @gid: group identifier
290 * 290 *
291 * Maps a user-namespace gid pair into a kernel internal kgid, 291 * Maps a user-namespace gid pair into a kernel internal kgid,
292 * and returns that kgid. 292 * and returns that kgid.
@@ -482,7 +482,8 @@ static int projid_m_show(struct seq_file *seq, void *v)
482 return 0; 482 return 0;
483} 483}
484 484
485static void *m_start(struct seq_file *seq, loff_t *ppos, struct uid_gid_map *map) 485static void *m_start(struct seq_file *seq, loff_t *ppos,
486 struct uid_gid_map *map)
486{ 487{
487 struct uid_gid_extent *extent = NULL; 488 struct uid_gid_extent *extent = NULL;
488 loff_t pos = *ppos; 489 loff_t pos = *ppos;
@@ -546,7 +547,8 @@ struct seq_operations proc_projid_seq_operations = {
546 .show = projid_m_show, 547 .show = projid_m_show,
547}; 548};
548 549
549static bool mappings_overlap(struct uid_gid_map *new_map, struct uid_gid_extent *extent) 550static bool mappings_overlap(struct uid_gid_map *new_map,
551 struct uid_gid_extent *extent)
550{ 552{
551 u32 upper_first, lower_first, upper_last, lower_last; 553 u32 upper_first, lower_first, upper_last, lower_last;
552 unsigned idx; 554 unsigned idx;
@@ -653,7 +655,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
653 ret = -EINVAL; 655 ret = -EINVAL;
654 pos = kbuf; 656 pos = kbuf;
655 new_map.nr_extents = 0; 657 new_map.nr_extents = 0;
656 for (;pos; pos = next_line) { 658 for (; pos; pos = next_line) {
657 extent = &new_map.extent[new_map.nr_extents]; 659 extent = &new_map.extent[new_map.nr_extents];
658 660
659 /* Find the end of line and ensure I don't look past it */ 661 /* Find the end of line and ensure I don't look past it */
@@ -687,13 +689,16 @@ static ssize_t map_write(struct file *file, const char __user *buf,
687 689
688 /* Verify we have been given valid starting values */ 690 /* Verify we have been given valid starting values */
689 if ((extent->first == (u32) -1) || 691 if ((extent->first == (u32) -1) ||
690 (extent->lower_first == (u32) -1 )) 692 (extent->lower_first == (u32) -1))
691 goto out; 693 goto out;
692 694
693 /* Verify count is not zero and does not cause the extent to wrap */ 695 /* Verify count is not zero and does not cause the
696 * extent to wrap
697 */
694 if ((extent->first + extent->count) <= extent->first) 698 if ((extent->first + extent->count) <= extent->first)
695 goto out; 699 goto out;
696 if ((extent->lower_first + extent->count) <= extent->lower_first) 700 if ((extent->lower_first + extent->count) <=
701 extent->lower_first)
697 goto out; 702 goto out;
698 703
699 /* Do the ranges in extent overlap any previous extents? */ 704 /* Do the ranges in extent overlap any previous extents? */
@@ -751,7 +756,8 @@ out:
751 return ret; 756 return ret;
752} 757}
753 758
754ssize_t proc_uid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) 759ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
760 size_t size, loff_t *ppos)
755{ 761{
756 struct seq_file *seq = file->private_data; 762 struct seq_file *seq = file->private_data;
757 struct user_namespace *ns = seq->private; 763 struct user_namespace *ns = seq->private;
@@ -767,7 +773,8 @@ ssize_t proc_uid_map_write(struct file *file, const char __user *buf, size_t siz
767 &ns->uid_map, &ns->parent->uid_map); 773 &ns->uid_map, &ns->parent->uid_map);
768} 774}
769 775
770ssize_t proc_gid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) 776ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
777 size_t size, loff_t *ppos)
771{ 778{
772 struct seq_file *seq = file->private_data; 779 struct seq_file *seq = file->private_data;
773 struct user_namespace *ns = seq->private; 780 struct user_namespace *ns = seq->private;
@@ -783,7 +790,8 @@ ssize_t proc_gid_map_write(struct file *file, const char __user *buf, size_t siz
783 &ns->gid_map, &ns->parent->gid_map); 790 &ns->gid_map, &ns->parent->gid_map);
784} 791}
785 792
786ssize_t proc_projid_map_write(struct file *file, const char __user *buf, size_t size, loff_t *ppos) 793ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
794 size_t size, loff_t *ppos)
787{ 795{
788 struct seq_file *seq = file->private_data; 796 struct seq_file *seq = file->private_data;
789 struct user_namespace *ns = seq->private; 797 struct user_namespace *ns = seq->private;
@@ -800,7 +808,7 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf, size_t
800 &ns->projid_map, &ns->parent->projid_map); 808 &ns->projid_map, &ns->parent->projid_map);
801} 809}
802 810
803static bool new_idmap_permitted(const struct file *file, 811static bool new_idmap_permitted(const struct file *file,
804 struct user_namespace *ns, int cap_setid, 812 struct user_namespace *ns, int cap_setid,
805 struct uid_gid_map *new_map) 813 struct uid_gid_map *new_map)
806{ 814{
@@ -811,8 +819,7 @@ static bool new_idmap_permitted(const struct file *file,
811 kuid_t uid = make_kuid(ns->parent, id); 819 kuid_t uid = make_kuid(ns->parent, id);
812 if (uid_eq(uid, file->f_cred->fsuid)) 820 if (uid_eq(uid, file->f_cred->fsuid))
813 return true; 821 return true;
814 } 822 } else if (cap_setid == CAP_SETGID) {
815 else if (cap_setid == CAP_SETGID) {
816 kgid_t gid = make_kgid(ns->parent, id); 823 kgid_t gid = make_kgid(ns->parent, id);
817 if (gid_eq(gid, file->f_cred->fsgid)) 824 if (gid_eq(gid, file->f_cred->fsgid))
818 return true; 825 return true;
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 6fbe811c7ad1..c8eac43267e9 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -17,7 +17,7 @@
17 17
18#ifdef CONFIG_PROC_SYSCTL 18#ifdef CONFIG_PROC_SYSCTL
19 19
20static void *get_uts(ctl_table *table, int write) 20static void *get_uts(struct ctl_table *table, int write)
21{ 21{
22 char *which = table->data; 22 char *which = table->data;
23 struct uts_namespace *uts_ns; 23 struct uts_namespace *uts_ns;
@@ -32,7 +32,7 @@ static void *get_uts(ctl_table *table, int write)
32 return which; 32 return which;
33} 33}
34 34
35static void put_uts(ctl_table *table, int write, void *which) 35static void put_uts(struct ctl_table *table, int write, void *which)
36{ 36{
37 if (!write) 37 if (!write)
38 up_read(&uts_sem); 38 up_read(&uts_sem);
@@ -44,7 +44,7 @@ static void put_uts(ctl_table *table, int write, void *which)
44 * Special case of dostring for the UTS structure. This has locks 44 * Special case of dostring for the UTS structure. This has locks
45 * to observe. Should this be in kernel/sys.c ???? 45 * to observe. Should this be in kernel/sys.c ????
46 */ 46 */
47static int proc_do_uts_string(ctl_table *table, int write, 47static int proc_do_uts_string(struct ctl_table *table, int write,
48 void __user *buffer, size_t *lenp, loff_t *ppos) 48 void __user *buffer, size_t *lenp, loff_t *ppos)
49{ 49{
50 struct ctl_table uts_table; 50 struct ctl_table uts_table;