aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@shinybook.infradead.org>2005-05-03 03:14:09 -0400
committerDavid Woodhouse <dwmw2@shinybook.infradead.org>2005-05-03 03:14:09 -0400
commit27b030d58c8e72fc7a95187a791bd9406e350f02 (patch)
treeab3bab7f39a5ce5bab65578a7e08fa4dfdeb198c /kernel
parent79d20b14a0d651f15b0ef9a22b6cf12d284a6d38 (diff)
parent6628465e33ca694bd8fd5c3cf4eb7ff9177bc694 (diff)
Merge with master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c13
-rw-r--r--kernel/futex.c3
-rw-r--r--kernel/kthread.c2
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/power/swsusp.c2
-rw-r--r--kernel/printk.c27
-rw-r--r--kernel/profile.c4
-rw-r--r--kernel/ptrace.c5
-rw-r--r--kernel/rcupdate.c22
-rw-r--r--kernel/sched.c28
-rw-r--r--kernel/signal.c9
-rw-r--r--kernel/stop_machine.c10
-rw-r--r--kernel/sys.c25
-rw-r--r--kernel/sys_ni.c1
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/timer.c2
16 files changed, 103 insertions, 54 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 39d35935b371..7be283d98983 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -27,6 +27,7 @@
27#include <linux/mempolicy.h> 27#include <linux/mempolicy.h>
28#include <linux/cpuset.h> 28#include <linux/cpuset.h>
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/signal.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/unistd.h> 33#include <asm/unistd.h>
@@ -38,6 +39,8 @@ extern struct task_struct *child_reaper;
38 39
39int getrusage(struct task_struct *, int, struct rusage __user *); 40int getrusage(struct task_struct *, int, struct rusage __user *);
40 41
42static void exit_mm(struct task_struct * tsk);
43
41static void __unhash_process(struct task_struct *p) 44static void __unhash_process(struct task_struct *p)
42{ 45{
43 nr_threads--; 46 nr_threads--;
@@ -209,7 +212,7 @@ static inline int has_stopped_jobs(int pgrp)
209} 212}
210 213
211/** 214/**
212 * reparent_to_init() - Reparent the calling kernel thread to the init task. 215 * reparent_to_init - Reparent the calling kernel thread to the init task.
213 * 216 *
214 * If a kernel thread is launched as a result of a system call, or if 217 * If a kernel thread is launched as a result of a system call, or if
215 * it ever exits, it should generally reparent itself to init so that 218 * it ever exits, it should generally reparent itself to init so that
@@ -277,7 +280,7 @@ void set_special_pids(pid_t session, pid_t pgrp)
277 */ 280 */
278int allow_signal(int sig) 281int allow_signal(int sig)
279{ 282{
280 if (sig < 1 || sig > _NSIG) 283 if (!valid_signal(sig) || sig < 1)
281 return -EINVAL; 284 return -EINVAL;
282 285
283 spin_lock_irq(&current->sighand->siglock); 286 spin_lock_irq(&current->sighand->siglock);
@@ -298,7 +301,7 @@ EXPORT_SYMBOL(allow_signal);
298 301
299int disallow_signal(int sig) 302int disallow_signal(int sig)
300{ 303{
301 if (sig < 1 || sig > _NSIG) 304 if (!valid_signal(sig) || sig < 1)
302 return -EINVAL; 305 return -EINVAL;
303 306
304 spin_lock_irq(&current->sighand->siglock); 307 spin_lock_irq(&current->sighand->siglock);
@@ -473,7 +476,7 @@ EXPORT_SYMBOL_GPL(exit_fs);
473 * Turn us into a lazy TLB process if we 476 * Turn us into a lazy TLB process if we
474 * aren't already.. 477 * aren't already..
475 */ 478 */
476void exit_mm(struct task_struct * tsk) 479static void exit_mm(struct task_struct * tsk)
477{ 480{
478 struct mm_struct *mm = tsk->mm; 481 struct mm_struct *mm = tsk->mm;
479 482
@@ -517,8 +520,6 @@ static inline void choose_new_parent(task_t *p, task_t *reaper, task_t *child_re
517 */ 520 */
518 BUG_ON(p == reaper || reaper->exit_state >= EXIT_ZOMBIE); 521 BUG_ON(p == reaper || reaper->exit_state >= EXIT_ZOMBIE);
519 p->real_parent = reaper; 522 p->real_parent = reaper;
520 if (p->parent == p->real_parent)
521 BUG();
522} 523}
523 524
524static inline void reparent_thread(task_t *p, task_t *father, int traced) 525static inline void reparent_thread(task_t *p, task_t *father, int traced)
diff --git a/kernel/futex.c b/kernel/futex.c
index 7b54a672d0ad..c7130f86106c 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -39,6 +39,7 @@
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/pagemap.h> 40#include <linux/pagemap.h>
41#include <linux/syscalls.h> 41#include <linux/syscalls.h>
42#include <linux/signal.h>
42 43
43#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) 44#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
44 45
@@ -654,7 +655,7 @@ static int futex_fd(unsigned long uaddr, int signal)
654 int ret, err; 655 int ret, err;
655 656
656 ret = -EINVAL; 657 ret = -EINVAL;
657 if (signal < 0 || signal > _NSIG) 658 if (!valid_signal(signal))
658 goto out; 659 goto out;
659 660
660 ret = get_unused_fd(); 661 ret = get_unused_fd();
diff --git a/kernel/kthread.c b/kernel/kthread.c
index e377e2244103..f50f174e92da 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -174,7 +174,7 @@ int kthread_stop(struct task_struct *k)
174 174
175 /* Must init completion *before* thread sees kthread_stop_info.k */ 175 /* Must init completion *before* thread sees kthread_stop_info.k */
176 init_completion(&kthread_stop_info.done); 176 init_completion(&kthread_stop_info.done);
177 wmb(); 177 smp_wmb();
178 178
179 /* Now set kthread_should_stop() to true, and wake it up. */ 179 /* Now set kthread_should_stop() to true, and wake it up. */
180 kthread_stop_info.k = k; 180 kthread_stop_info.k = k;
diff --git a/kernel/module.c b/kernel/module.c
index 2dbfa0773faf..5734ab09d3f9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1801,7 +1801,7 @@ sys_init_module(void __user *umod,
1801 /* Init routine failed: abort. Try to protect us from 1801 /* Init routine failed: abort. Try to protect us from
1802 buggy refcounters. */ 1802 buggy refcounters. */
1803 mod->state = MODULE_STATE_GOING; 1803 mod->state = MODULE_STATE_GOING;
1804 synchronize_kernel(); 1804 synchronize_sched();
1805 if (mod->unsafe) 1805 if (mod->unsafe)
1806 printk(KERN_ERR "%s: module is now stuck!\n", 1806 printk(KERN_ERR "%s: module is now stuck!\n",
1807 mod->name); 1807 mod->name);
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index ae5bebc3b18f..90b3b68dee3f 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -1099,7 +1099,7 @@ static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist)
1099 return pblist; 1099 return pblist;
1100} 1100}
1101 1101
1102/** 1102/*
1103 * Using bio to read from swap. 1103 * Using bio to read from swap.
1104 * This code requires a bit more work than just using buffer heads 1104 * This code requires a bit more work than just using buffer heads
1105 * but, it is the recommended way for 2.5/2.6. 1105 * but, it is the recommended way for 2.5/2.6.
diff --git a/kernel/printk.c b/kernel/printk.c
index 1498689548d1..290a07ce2c8a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -85,10 +85,6 @@ static int console_locked;
85 */ 85 */
86static DEFINE_SPINLOCK(logbuf_lock); 86static DEFINE_SPINLOCK(logbuf_lock);
87 87
88static char __log_buf[__LOG_BUF_LEN];
89static char *log_buf = __log_buf;
90static int log_buf_len = __LOG_BUF_LEN;
91
92#define LOG_BUF_MASK (log_buf_len-1) 88#define LOG_BUF_MASK (log_buf_len-1)
93#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) 89#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
94 90
@@ -99,7 +95,6 @@ static int log_buf_len = __LOG_BUF_LEN;
99static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */ 95static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */
100static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */ 96static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */
101static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */ 97static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */
102static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
103 98
104/* 99/*
105 * Array of consoles built from command line options (console=) 100 * Array of consoles built from command line options (console=)
@@ -120,6 +115,13 @@ static int preferred_console = -1;
120/* Flag: console code may call schedule() */ 115/* Flag: console code may call schedule() */
121static int console_may_schedule; 116static int console_may_schedule;
122 117
118#ifdef CONFIG_PRINTK
119
120static char __log_buf[__LOG_BUF_LEN];
121static char *log_buf = __log_buf;
122static int log_buf_len = __LOG_BUF_LEN;
123static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
124
123/* 125/*
124 * Setup a list of consoles. Called from init/main.c 126 * Setup a list of consoles. Called from init/main.c
125 */ 127 */
@@ -535,6 +537,7 @@ __setup("time", printk_time_setup);
535 * then changes console_loglevel may break. This is because console_loglevel 537 * then changes console_loglevel may break. This is because console_loglevel
536 * is inspected when the actual printing occurs. 538 * is inspected when the actual printing occurs.
537 */ 539 */
540
538asmlinkage int printk(const char *fmt, ...) 541asmlinkage int printk(const char *fmt, ...)
539{ 542{
540 va_list args; 543 va_list args;
@@ -655,6 +658,18 @@ out:
655EXPORT_SYMBOL(printk); 658EXPORT_SYMBOL(printk);
656EXPORT_SYMBOL(vprintk); 659EXPORT_SYMBOL(vprintk);
657 660
661#else
662
663asmlinkage long sys_syslog(int type, char __user * buf, int len)
664{
665 return 0;
666}
667
668int do_syslog(int type, char __user * buf, int len) { return 0; }
669static void call_console_drivers(unsigned long start, unsigned long end) {}
670
671#endif
672
658/** 673/**
659 * acquire_console_sem - lock the console system for exclusive use. 674 * acquire_console_sem - lock the console system for exclusive use.
660 * 675 *
@@ -931,7 +946,7 @@ int unregister_console(struct console * console)
931 return res; 946 return res;
932} 947}
933EXPORT_SYMBOL(unregister_console); 948EXPORT_SYMBOL(unregister_console);
934 949
935/** 950/**
936 * tty_write_message - write a message to a certain tty, not just the console. 951 * tty_write_message - write a message to a certain tty, not just the console.
937 * 952 *
diff --git a/kernel/profile.c b/kernel/profile.c
index a38fa70075fe..0221a50ca867 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -184,7 +184,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
184 WARN_ON(hook != timer_hook); 184 WARN_ON(hook != timer_hook);
185 timer_hook = NULL; 185 timer_hook = NULL;
186 /* make sure all CPUs see the NULL hook */ 186 /* make sure all CPUs see the NULL hook */
187 synchronize_kernel(); 187 synchronize_sched(); /* Allow ongoing interrupts to complete. */
188} 188}
189 189
190EXPORT_SYMBOL_GPL(register_timer_hook); 190EXPORT_SYMBOL_GPL(register_timer_hook);
@@ -522,7 +522,7 @@ static int __init create_hash_tables(void)
522 return 0; 522 return 0;
523out_cleanup: 523out_cleanup:
524 prof_on = 0; 524 prof_on = 0;
525 mb(); 525 smp_mb();
526 on_each_cpu(profile_nop, NULL, 0, 1); 526 on_each_cpu(profile_nop, NULL, 0, 1);
527 for_each_online_cpu(cpu) { 527 for_each_online_cpu(cpu) {
528 struct page *page; 528 struct page *page;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 88b306c4e841..8dcb8f6288bc 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -16,6 +16,7 @@
16#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/signal.h>
19 20
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
@@ -135,7 +136,7 @@ int ptrace_attach(struct task_struct *task)
135 (current->gid != task->sgid) || 136 (current->gid != task->sgid) ||
136 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) 137 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE))
137 goto bad; 138 goto bad;
138 rmb(); 139 smp_rmb();
139 if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) 140 if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE))
140 goto bad; 141 goto bad;
141 /* the same process cannot be attached many times */ 142 /* the same process cannot be attached many times */
@@ -166,7 +167,7 @@ bad:
166 167
167int ptrace_detach(struct task_struct *child, unsigned int data) 168int ptrace_detach(struct task_struct *child, unsigned int data)
168{ 169{
169 if ((unsigned long) data > _NSIG) 170 if (!valid_signal(data))
170 return -EIO; 171 return -EIO;
171 172
172 /* Architecture-specific hardware disable .. */ 173 /* Architecture-specific hardware disable .. */
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index d00eded75d71..f436993bd590 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -444,15 +444,18 @@ static void wakeme_after_rcu(struct rcu_head *head)
444} 444}
445 445
446/** 446/**
447 * synchronize_kernel - wait until a grace period has elapsed. 447 * synchronize_rcu - wait until a grace period has elapsed.
448 * 448 *
449 * Control will return to the caller some time after a full grace 449 * Control will return to the caller some time after a full grace
450 * period has elapsed, in other words after all currently executing RCU 450 * period has elapsed, in other words after all currently executing RCU
451 * read-side critical sections have completed. RCU read-side critical 451 * read-side critical sections have completed. RCU read-side critical
452 * sections are delimited by rcu_read_lock() and rcu_read_unlock(), 452 * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
453 * and may be nested. 453 * and may be nested.
454 *
455 * If your read-side code is not protected by rcu_read_lock(), do -not-
456 * use synchronize_rcu().
454 */ 457 */
455void synchronize_kernel(void) 458void synchronize_rcu(void)
456{ 459{
457 struct rcu_synchronize rcu; 460 struct rcu_synchronize rcu;
458 461
@@ -464,7 +467,16 @@ void synchronize_kernel(void)
464 wait_for_completion(&rcu.completion); 467 wait_for_completion(&rcu.completion);
465} 468}
466 469
470/*
471 * Deprecated, use synchronize_rcu() or synchronize_sched() instead.
472 */
473void synchronize_kernel(void)
474{
475 synchronize_rcu();
476}
477
467module_param(maxbatch, int, 0); 478module_param(maxbatch, int, 0);
468EXPORT_SYMBOL_GPL(call_rcu); 479EXPORT_SYMBOL(call_rcu); /* WARNING: GPL-only in April 2006. */
469EXPORT_SYMBOL_GPL(call_rcu_bh); 480EXPORT_SYMBOL(call_rcu_bh); /* WARNING: GPL-only in April 2006. */
470EXPORT_SYMBOL_GPL(synchronize_kernel); 481EXPORT_SYMBOL_GPL(synchronize_rcu);
482EXPORT_SYMBOL(synchronize_kernel); /* WARNING: GPL-only in April 2006. */
diff --git a/kernel/sched.c b/kernel/sched.c
index 9bb7489ee645..0dc3158667a2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2906,6 +2906,7 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
2906 * @q: the waitqueue 2906 * @q: the waitqueue
2907 * @mode: which threads 2907 * @mode: which threads
2908 * @nr_exclusive: how many wake-one or wake-many threads to wake up 2908 * @nr_exclusive: how many wake-one or wake-many threads to wake up
2909 * @key: is directly passed to the wakeup function
2909 */ 2910 */
2910void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode, 2911void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode,
2911 int nr_exclusive, void *key) 2912 int nr_exclusive, void *key)
@@ -2928,7 +2929,7 @@ void fastcall __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
2928} 2929}
2929 2930
2930/** 2931/**
2931 * __wake_up - sync- wake up threads blocked on a waitqueue. 2932 * __wake_up_sync - wake up threads blocked on a waitqueue.
2932 * @q: the waitqueue 2933 * @q: the waitqueue
2933 * @mode: which threads 2934 * @mode: which threads
2934 * @nr_exclusive: how many wake-one or wake-many threads to wake up 2935 * @nr_exclusive: how many wake-one or wake-many threads to wake up
@@ -3223,6 +3224,19 @@ out_unlock:
3223 3224
3224EXPORT_SYMBOL(set_user_nice); 3225EXPORT_SYMBOL(set_user_nice);
3225 3226
3227/*
3228 * can_nice - check if a task can reduce its nice value
3229 * @p: task
3230 * @nice: nice value
3231 */
3232int can_nice(const task_t *p, const int nice)
3233{
3234 /* convert nice value [19,-20] to rlimit style value [0,39] */
3235 int nice_rlim = 19 - nice;
3236 return (nice_rlim <= p->signal->rlim[RLIMIT_NICE].rlim_cur ||
3237 capable(CAP_SYS_NICE));
3238}
3239
3226#ifdef __ARCH_WANT_SYS_NICE 3240#ifdef __ARCH_WANT_SYS_NICE
3227 3241
3228/* 3242/*
@@ -3242,12 +3256,8 @@ asmlinkage long sys_nice(int increment)
3242 * We don't have to worry. Conceptually one call occurs first 3256 * We don't have to worry. Conceptually one call occurs first
3243 * and we have a single winner. 3257 * and we have a single winner.
3244 */ 3258 */
3245 if (increment < 0) { 3259 if (increment < -40)
3246 if (!capable(CAP_SYS_NICE)) 3260 increment = -40;
3247 return -EPERM;
3248 if (increment < -40)
3249 increment = -40;
3250 }
3251 if (increment > 40) 3261 if (increment > 40)
3252 increment = 40; 3262 increment = 40;
3253 3263
@@ -3257,6 +3267,9 @@ asmlinkage long sys_nice(int increment)
3257 if (nice > 19) 3267 if (nice > 19)
3258 nice = 19; 3268 nice = 19;
3259 3269
3270 if (increment < 0 && !can_nice(current, nice))
3271 return -EPERM;
3272
3260 retval = security_task_setnice(current, nice); 3273 retval = security_task_setnice(current, nice);
3261 if (retval) 3274 if (retval)
3262 return retval; 3275 return retval;
@@ -3372,6 +3385,7 @@ recheck:
3372 return -EINVAL; 3385 return -EINVAL;
3373 3386
3374 if ((policy == SCHED_FIFO || policy == SCHED_RR) && 3387 if ((policy == SCHED_FIFO || policy == SCHED_RR) &&
3388 param->sched_priority > p->signal->rlim[RLIMIT_RTPRIO].rlim_cur &&
3375 !capable(CAP_SYS_NICE)) 3389 !capable(CAP_SYS_NICE))
3376 return -EPERM; 3390 return -EPERM;
3377 if ((current->euid != p->euid) && (current->euid != p->uid) && 3391 if ((current->euid != p->euid) && (current->euid != p->uid) &&
diff --git a/kernel/signal.c b/kernel/signal.c
index e6567d7f2b62..8f3debc77c5b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/syscalls.h> 23#include <linux/syscalls.h>
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/posix-timers.h> 25#include <linux/posix-timers.h>
26#include <linux/signal.h>
26#include <asm/param.h> 27#include <asm/param.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/unistd.h> 29#include <asm/unistd.h>
@@ -646,7 +647,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
646 struct task_struct *t) 647 struct task_struct *t)
647{ 648{
648 int error = -EINVAL; 649 int error = -EINVAL;
649 if (sig < 0 || sig > _NSIG) 650 if (!valid_signal(sig))
650 return error; 651 return error;
651 error = -EPERM; 652 error = -EPERM;
652 if ((!info || ((unsigned long)info != 1 && 653 if ((!info || ((unsigned long)info != 1 &&
@@ -1245,7 +1246,7 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1245 * Make sure legacy kernel users don't send in bad values 1246 * Make sure legacy kernel users don't send in bad values
1246 * (normal paths check this in check_kill_permission). 1247 * (normal paths check this in check_kill_permission).
1247 */ 1248 */
1248 if (sig < 0 || sig > _NSIG) 1249 if (!valid_signal(sig))
1249 return -EINVAL; 1250 return -EINVAL;
1250 1251
1251 /* 1252 /*
@@ -1520,7 +1521,7 @@ void do_notify_parent(struct task_struct *tsk, int sig)
1520 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) 1521 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
1521 sig = 0; 1522 sig = 0;
1522 } 1523 }
1523 if (sig > 0 && sig <= _NSIG) 1524 if (valid_signal(sig) && sig > 0)
1524 __group_send_sig_info(sig, &info, tsk->parent); 1525 __group_send_sig_info(sig, &info, tsk->parent);
1525 __wake_up_parent(tsk, tsk->parent); 1526 __wake_up_parent(tsk, tsk->parent);
1526 spin_unlock_irqrestore(&psig->siglock, flags); 1527 spin_unlock_irqrestore(&psig->siglock, flags);
@@ -2364,7 +2365,7 @@ do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact)
2364{ 2365{
2365 struct k_sigaction *k; 2366 struct k_sigaction *k;
2366 2367
2367 if (sig < 1 || sig > _NSIG || (act && sig_kernel_only(sig))) 2368 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
2368 return -EINVAL; 2369 return -EINVAL;
2369 2370
2370 k = &current->sighand->action[sig-1]; 2371 k = &current->sighand->action[sig-1];
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index c39ed70af174..6116b25aa7cf 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -33,7 +33,7 @@ static int stopmachine(void *cpu)
33 set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); 33 set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu));
34 34
35 /* Ack: we are alive */ 35 /* Ack: we are alive */
36 mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ 36 smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */
37 atomic_inc(&stopmachine_thread_ack); 37 atomic_inc(&stopmachine_thread_ack);
38 38
39 /* Simple state machine */ 39 /* Simple state machine */
@@ -43,14 +43,14 @@ static int stopmachine(void *cpu)
43 local_irq_disable(); 43 local_irq_disable();
44 irqs_disabled = 1; 44 irqs_disabled = 1;
45 /* Ack: irqs disabled. */ 45 /* Ack: irqs disabled. */
46 mb(); /* Must read state first. */ 46 smp_mb(); /* Must read state first. */
47 atomic_inc(&stopmachine_thread_ack); 47 atomic_inc(&stopmachine_thread_ack);
48 } else if (stopmachine_state == STOPMACHINE_PREPARE 48 } else if (stopmachine_state == STOPMACHINE_PREPARE
49 && !prepared) { 49 && !prepared) {
50 /* Everyone is in place, hold CPU. */ 50 /* Everyone is in place, hold CPU. */
51 preempt_disable(); 51 preempt_disable();
52 prepared = 1; 52 prepared = 1;
53 mb(); /* Must read state first. */ 53 smp_mb(); /* Must read state first. */
54 atomic_inc(&stopmachine_thread_ack); 54 atomic_inc(&stopmachine_thread_ack);
55 } 55 }
56 /* Yield in first stage: migration threads need to 56 /* Yield in first stage: migration threads need to
@@ -62,7 +62,7 @@ static int stopmachine(void *cpu)
62 } 62 }
63 63
64 /* Ack: we are exiting. */ 64 /* Ack: we are exiting. */
65 mb(); /* Must read state first. */ 65 smp_mb(); /* Must read state first. */
66 atomic_inc(&stopmachine_thread_ack); 66 atomic_inc(&stopmachine_thread_ack);
67 67
68 if (irqs_disabled) 68 if (irqs_disabled)
@@ -77,7 +77,7 @@ static int stopmachine(void *cpu)
77static void stopmachine_set_state(enum stopmachine_state state) 77static void stopmachine_set_state(enum stopmachine_state state)
78{ 78{
79 atomic_set(&stopmachine_thread_ack, 0); 79 atomic_set(&stopmachine_thread_ack, 0);
80 wmb(); 80 smp_wmb();
81 stopmachine_state = state; 81 stopmachine_state = state;
82 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) 82 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads)
83 cpu_relax(); 83 cpu_relax();
diff --git a/kernel/sys.c b/kernel/sys.c
index 462d78d55895..f64e97cabe25 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -25,6 +25,7 @@
25#include <linux/dcookies.h> 25#include <linux/dcookies.h>
26#include <linux/suspend.h> 26#include <linux/suspend.h>
27#include <linux/tty.h> 27#include <linux/tty.h>
28#include <linux/signal.h>
28 29
29#include <linux/compat.h> 30#include <linux/compat.h>
30#include <linux/syscalls.h> 31#include <linux/syscalls.h>
@@ -227,7 +228,7 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
227 error = -EPERM; 228 error = -EPERM;
228 goto out; 229 goto out;
229 } 230 }
230 if (niceval < task_nice(p) && !capable(CAP_SYS_NICE)) { 231 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
231 error = -EACCES; 232 error = -EACCES;
232 goto out; 233 goto out;
233 } 234 }
@@ -525,7 +526,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
525 if (new_egid != old_egid) 526 if (new_egid != old_egid)
526 { 527 {
527 current->mm->dumpable = 0; 528 current->mm->dumpable = 0;
528 wmb(); 529 smp_wmb();
529 } 530 }
530 if (rgid != (gid_t) -1 || 531 if (rgid != (gid_t) -1 ||
531 (egid != (gid_t) -1 && egid != old_rgid)) 532 (egid != (gid_t) -1 && egid != old_rgid))
@@ -556,7 +557,7 @@ asmlinkage long sys_setgid(gid_t gid)
556 if(old_egid != gid) 557 if(old_egid != gid)
557 { 558 {
558 current->mm->dumpable=0; 559 current->mm->dumpable=0;
559 wmb(); 560 smp_wmb();
560 } 561 }
561 current->gid = current->egid = current->sgid = current->fsgid = gid; 562 current->gid = current->egid = current->sgid = current->fsgid = gid;
562 } 563 }
@@ -565,7 +566,7 @@ asmlinkage long sys_setgid(gid_t gid)
565 if(old_egid != gid) 566 if(old_egid != gid)
566 { 567 {
567 current->mm->dumpable=0; 568 current->mm->dumpable=0;
568 wmb(); 569 smp_wmb();
569 } 570 }
570 current->egid = current->fsgid = gid; 571 current->egid = current->fsgid = gid;
571 } 572 }
@@ -596,7 +597,7 @@ static int set_user(uid_t new_ruid, int dumpclear)
596 if(dumpclear) 597 if(dumpclear)
597 { 598 {
598 current->mm->dumpable = 0; 599 current->mm->dumpable = 0;
599 wmb(); 600 smp_wmb();
600 } 601 }
601 current->uid = new_ruid; 602 current->uid = new_ruid;
602 return 0; 603 return 0;
@@ -653,7 +654,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
653 if (new_euid != old_euid) 654 if (new_euid != old_euid)
654 { 655 {
655 current->mm->dumpable=0; 656 current->mm->dumpable=0;
656 wmb(); 657 smp_wmb();
657 } 658 }
658 current->fsuid = current->euid = new_euid; 659 current->fsuid = current->euid = new_euid;
659 if (ruid != (uid_t) -1 || 660 if (ruid != (uid_t) -1 ||
@@ -703,7 +704,7 @@ asmlinkage long sys_setuid(uid_t uid)
703 if (old_euid != uid) 704 if (old_euid != uid)
704 { 705 {
705 current->mm->dumpable = 0; 706 current->mm->dumpable = 0;
706 wmb(); 707 smp_wmb();
707 } 708 }
708 current->fsuid = current->euid = uid; 709 current->fsuid = current->euid = uid;
709 current->suid = new_suid; 710 current->suid = new_suid;
@@ -748,7 +749,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
748 if (euid != current->euid) 749 if (euid != current->euid)
749 { 750 {
750 current->mm->dumpable = 0; 751 current->mm->dumpable = 0;
751 wmb(); 752 smp_wmb();
752 } 753 }
753 current->euid = euid; 754 current->euid = euid;
754 } 755 }
@@ -798,7 +799,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
798 if (egid != current->egid) 799 if (egid != current->egid)
799 { 800 {
800 current->mm->dumpable = 0; 801 current->mm->dumpable = 0;
801 wmb(); 802 smp_wmb();
802 } 803 }
803 current->egid = egid; 804 current->egid = egid;
804 } 805 }
@@ -845,7 +846,7 @@ asmlinkage long sys_setfsuid(uid_t uid)
845 if (uid != old_fsuid) 846 if (uid != old_fsuid)
846 { 847 {
847 current->mm->dumpable = 0; 848 current->mm->dumpable = 0;
848 wmb(); 849 smp_wmb();
849 } 850 }
850 current->fsuid = uid; 851 current->fsuid = uid;
851 } 852 }
@@ -875,7 +876,7 @@ asmlinkage long sys_setfsgid(gid_t gid)
875 if (gid != old_fsgid) 876 if (gid != old_fsgid)
876 { 877 {
877 current->mm->dumpable = 0; 878 current->mm->dumpable = 0;
878 wmb(); 879 smp_wmb();
879 } 880 }
880 current->fsgid = gid; 881 current->fsgid = gid;
881 key_fsgid_changed(current); 882 key_fsgid_changed(current);
@@ -1637,7 +1638,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
1637 switch (option) { 1638 switch (option) {
1638 case PR_SET_PDEATHSIG: 1639 case PR_SET_PDEATHSIG:
1639 sig = arg2; 1640 sig = arg2;
1640 if (sig < 0 || sig > _NSIG) { 1641 if (!valid_signal(sig)) {
1641 error = -EINVAL; 1642 error = -EINVAL;
1642 break; 1643 break;
1643 } 1644 }
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 1802a311dd3f..0dda70ed1f98 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -52,6 +52,7 @@ cond_syscall(sys_msgsnd);
52cond_syscall(sys_msgrcv); 52cond_syscall(sys_msgrcv);
53cond_syscall(sys_msgctl); 53cond_syscall(sys_msgctl);
54cond_syscall(sys_shmget); 54cond_syscall(sys_shmget);
55cond_syscall(sys_shmat);
55cond_syscall(sys_shmdt); 56cond_syscall(sys_shmdt);
56cond_syscall(sys_shmctl); 57cond_syscall(sys_shmctl);
57cond_syscall(sys_mq_open); 58cond_syscall(sys_mq_open);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 79dbd93bd697..701d12c63068 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1991,6 +1991,8 @@ int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1991 * @filp: the file structure 1991 * @filp: the file structure
1992 * @buffer: the user buffer 1992 * @buffer: the user buffer
1993 * @lenp: the size of the user buffer 1993 * @lenp: the size of the user buffer
1994 * @ppos: file position
1995 * @ppos: the current position in the file
1994 * 1996 *
1995 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1997 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1996 * values from/to the user buffer, treated as an ASCII string. 1998 * values from/to the user buffer, treated as an ASCII string.
diff --git a/kernel/timer.c b/kernel/timer.c
index ecb3d67c0e14..207aa4f0aa10 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1007,7 +1007,7 @@ asmlinkage long sys_getppid(void)
1007 * Make sure we read the pid before re-reading the 1007 * Make sure we read the pid before re-reading the
1008 * parent pointer: 1008 * parent pointer:
1009 */ 1009 */
1010 rmb(); 1010 smp_rmb();
1011 parent = me->group_leader->real_parent; 1011 parent = me->group_leader->real_parent;
1012 if (old != parent) 1012 if (old != parent)
1013 continue; 1013 continue;