diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-03-06 04:33:08 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-17 11:40:57 -0400 |
commit | 7e907f48980d6668f99206ba0dded40dca2d086f (patch) | |
tree | fca2bc443e034ad4abbc06f518a03e32a0f48b47 | |
parent | a7113170214b569d24e413326a56c4cc5cc1a152 (diff) |
x86: clean up arch/x86/kernel/signal_32.c
Before:
total: 21 errors, 6 warnings, 665 lines checked
After:
total: 0 errors, 3 warnings, 685 lines checked
No code changed:
arch/x86/kernel/signal_32.o:
text data bss dec hex filename
5333 0 4 5337 14d9 signal_32.o.before
5333 0 4 5337 14d9 signal_32.o.after
md5:
c279e98012a2808e90cfa2a7787e42a4 signal_32.o.before.asm
c279e98012a2808e90cfa2a7787e42a4 signal_32.o.after.asm
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/signal_32.c | 180 |
1 files changed, 101 insertions, 79 deletions
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index f4ec6a092951..3da3ffa39e9a 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c | |||
@@ -4,26 +4,29 @@ | |||
4 | * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson | 4 | * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson |
5 | * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes | 5 | * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes |
6 | */ | 6 | */ |
7 | #include <linux/list.h> | ||
7 | 8 | ||
8 | #include <linux/sched.h> | 9 | #include <linux/personality.h> |
9 | #include <linux/mm.h> | 10 | #include <linux/binfmts.h> |
10 | #include <linux/smp.h> | 11 | #include <linux/suspend.h> |
11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/ptrace.h> | ||
12 | #include <linux/signal.h> | 14 | #include <linux/signal.h> |
15 | #include <linux/stddef.h> | ||
16 | #include <linux/unistd.h> | ||
13 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/sched.h> | ||
14 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
15 | #include <linux/unistd.h> | ||
16 | #include <linux/stddef.h> | ||
17 | #include <linux/personality.h> | ||
18 | #include <linux/suspend.h> | ||
19 | #include <linux/ptrace.h> | ||
20 | #include <linux/elf.h> | 20 | #include <linux/elf.h> |
21 | #include <linux/binfmts.h> | 21 | #include <linux/smp.h> |
22 | #include <linux/mm.h> | ||
23 | |||
22 | #include <asm/processor.h> | 24 | #include <asm/processor.h> |
23 | #include <asm/ucontext.h> | 25 | #include <asm/ucontext.h> |
24 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
25 | #include <asm/i387.h> | 27 | #include <asm/i387.h> |
26 | #include <asm/vdso.h> | 28 | #include <asm/vdso.h> |
29 | |||
27 | #include "sigframe.h" | 30 | #include "sigframe.h" |
28 | 31 | ||
29 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 32 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
@@ -55,10 +58,11 @@ sys_sigsuspend(int history0, int history1, old_sigset_t mask) | |||
55 | current->state = TASK_INTERRUPTIBLE; | 58 | current->state = TASK_INTERRUPTIBLE; |
56 | schedule(); | 59 | schedule(); |
57 | set_thread_flag(TIF_RESTORE_SIGMASK); | 60 | set_thread_flag(TIF_RESTORE_SIGMASK); |
61 | |||
58 | return -ERESTARTNOHAND; | 62 | return -ERESTARTNOHAND; |
59 | } | 63 | } |
60 | 64 | ||
61 | asmlinkage int | 65 | asmlinkage int |
62 | sys_sigaction(int sig, const struct old_sigaction __user *act, | 66 | sys_sigaction(int sig, const struct old_sigaction __user *act, |
63 | struct old_sigaction __user *oact) | 67 | struct old_sigaction __user *oact) |
64 | { | 68 | { |
@@ -67,10 +71,12 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, | |||
67 | 71 | ||
68 | if (act) { | 72 | if (act) { |
69 | old_sigset_t mask; | 73 | old_sigset_t mask; |
74 | |||
70 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || | 75 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || |
71 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || | 76 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || |
72 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) | 77 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) |
73 | return -EFAULT; | 78 | return -EFAULT; |
79 | |||
74 | __get_user(new_ka.sa.sa_flags, &act->sa_flags); | 80 | __get_user(new_ka.sa.sa_flags, &act->sa_flags); |
75 | __get_user(mask, &act->sa_mask); | 81 | __get_user(mask, &act->sa_mask); |
76 | siginitset(&new_ka.sa.sa_mask, mask); | 82 | siginitset(&new_ka.sa.sa_mask, mask); |
@@ -83,6 +89,7 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, | |||
83 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || | 89 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || |
84 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) | 90 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) |
85 | return -EFAULT; | 91 | return -EFAULT; |
92 | |||
86 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags); | 93 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags); |
87 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); | 94 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); |
88 | } | 95 | } |
@@ -90,10 +97,12 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, | |||
90 | return ret; | 97 | return ret; |
91 | } | 98 | } |
92 | 99 | ||
93 | asmlinkage int | 100 | asmlinkage int sys_sigaltstack(unsigned long bx) |
94 | sys_sigaltstack(unsigned long bx) | ||
95 | { | 101 | { |
96 | /* This is needed to make gcc realize it doesn't own the "struct pt_regs" */ | 102 | /* |
103 | * This is needed to make gcc realize it doesn't own the | ||
104 | * "struct pt_regs" | ||
105 | */ | ||
97 | struct pt_regs *regs = (struct pt_regs *)&bx; | 106 | struct pt_regs *regs = (struct pt_regs *)&bx; |
98 | const stack_t __user *uss = (const stack_t __user *)bx; | 107 | const stack_t __user *uss = (const stack_t __user *)bx; |
99 | stack_t __user *uoss = (stack_t __user *)regs->cx; | 108 | stack_t __user *uoss = (stack_t __user *)regs->cx; |
@@ -129,7 +138,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
129 | #define GET_SEG(seg) \ | 138 | #define GET_SEG(seg) \ |
130 | { unsigned short tmp; \ | 139 | { unsigned short tmp; \ |
131 | err |= __get_user(tmp, &sc->seg); \ | 140 | err |= __get_user(tmp, &sc->seg); \ |
132 | loadsegment(seg,tmp); } | 141 | loadsegment(seg, tmp); } |
133 | 142 | ||
134 | GET_SEG(gs); | 143 | GET_SEG(gs); |
135 | COPY_SEG(fs); | 144 | COPY_SEG(fs); |
@@ -139,16 +148,19 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
139 | COPY(dx); COPY(cx); COPY(ip); | 148 | COPY(dx); COPY(cx); COPY(ip); |
140 | COPY_SEG_STRICT(cs); | 149 | COPY_SEG_STRICT(cs); |
141 | COPY_SEG_STRICT(ss); | 150 | COPY_SEG_STRICT(ss); |
142 | 151 | ||
143 | { | 152 | { |
144 | unsigned int tmpflags; | 153 | unsigned int tmpflags; |
154 | |||
145 | err |= __get_user(tmpflags, &sc->flags); | 155 | err |= __get_user(tmpflags, &sc->flags); |
146 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); | 156 | regs->flags = (regs->flags & ~FIX_EFLAGS) | |
157 | (tmpflags & FIX_EFLAGS); | ||
147 | regs->orig_ax = -1; /* disable syscall checks */ | 158 | regs->orig_ax = -1; /* disable syscall checks */ |
148 | } | 159 | } |
149 | 160 | ||
150 | { | 161 | { |
151 | struct _fpstate __user * buf; | 162 | struct _fpstate __user *buf; |
163 | |||
152 | err |= __get_user(buf, &sc->fpstate); | 164 | err |= __get_user(buf, &sc->fpstate); |
153 | if (buf) { | 165 | if (buf) { |
154 | if (!access_ok(VERIFY_READ, buf, sizeof(*buf))) | 166 | if (!access_ok(VERIFY_READ, buf, sizeof(*buf))) |
@@ -156,6 +168,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
156 | err |= restore_i387(buf); | 168 | err |= restore_i387(buf); |
157 | } else { | 169 | } else { |
158 | struct task_struct *me = current; | 170 | struct task_struct *me = current; |
171 | |||
159 | if (used_math()) { | 172 | if (used_math()) { |
160 | clear_fpu(me); | 173 | clear_fpu(me); |
161 | clear_used_math(); | 174 | clear_used_math(); |
@@ -172,15 +185,17 @@ badframe: | |||
172 | 185 | ||
173 | asmlinkage unsigned long sys_sigreturn(unsigned long __unused) | 186 | asmlinkage unsigned long sys_sigreturn(unsigned long __unused) |
174 | { | 187 | { |
175 | struct pt_regs *regs = (struct pt_regs *) &__unused; | 188 | struct sigframe __user *frame; |
176 | struct sigframe __user *frame = (struct sigframe __user *)(regs->sp - 8); | 189 | struct pt_regs *regs; |
177 | sigset_t set; | ||
178 | unsigned long ax; | 190 | unsigned long ax; |
191 | sigset_t set; | ||
192 | |||
193 | regs = (struct pt_regs *) &__unused; | ||
194 | frame = (struct sigframe __user *)(regs->sp - 8); | ||
179 | 195 | ||
180 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) | 196 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
181 | goto badframe; | 197 | goto badframe; |
182 | if (__get_user(set.sig[0], &frame->sc.oldmask) | 198 | if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1 |
183 | || (_NSIG_WORDS > 1 | ||
184 | && __copy_from_user(&set.sig[1], &frame->extramask, | 199 | && __copy_from_user(&set.sig[1], &frame->extramask, |
185 | sizeof(frame->extramask)))) | 200 | sizeof(frame->extramask)))) |
186 | goto badframe; | 201 | goto badframe; |
@@ -190,7 +205,7 @@ asmlinkage unsigned long sys_sigreturn(unsigned long __unused) | |||
190 | current->blocked = set; | 205 | current->blocked = set; |
191 | recalc_sigpending(); | 206 | recalc_sigpending(); |
192 | spin_unlock_irq(¤t->sighand->siglock); | 207 | spin_unlock_irq(¤t->sighand->siglock); |
193 | 208 | ||
194 | if (restore_sigcontext(regs, &frame->sc, &ax)) | 209 | if (restore_sigcontext(regs, &frame->sc, &ax)) |
195 | goto badframe; | 210 | goto badframe; |
196 | return ax; | 211 | return ax; |
@@ -207,8 +222,9 @@ badframe: | |||
207 | } | 222 | } |
208 | 223 | ||
209 | force_sig(SIGSEGV, current); | 224 | force_sig(SIGSEGV, current); |
225 | |||
210 | return 0; | 226 | return 0; |
211 | } | 227 | } |
212 | 228 | ||
213 | asmlinkage int sys_rt_sigreturn(unsigned long __unused) | 229 | asmlinkage int sys_rt_sigreturn(unsigned long __unused) |
214 | { | 230 | { |
@@ -228,7 +244,7 @@ asmlinkage int sys_rt_sigreturn(unsigned long __unused) | |||
228 | current->blocked = set; | 244 | current->blocked = set; |
229 | recalc_sigpending(); | 245 | recalc_sigpending(); |
230 | spin_unlock_irq(¤t->sighand->siglock); | 246 | spin_unlock_irq(¤t->sighand->siglock); |
231 | 247 | ||
232 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) | 248 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) |
233 | goto badframe; | 249 | goto badframe; |
234 | 250 | ||
@@ -240,12 +256,11 @@ asmlinkage int sys_rt_sigreturn(unsigned long __unused) | |||
240 | badframe: | 256 | badframe: |
241 | force_sig(SIGSEGV, current); | 257 | force_sig(SIGSEGV, current); |
242 | return 0; | 258 | return 0; |
243 | } | 259 | } |
244 | 260 | ||
245 | /* | 261 | /* |
246 | * Set up a signal frame. | 262 | * Set up a signal frame. |
247 | */ | 263 | */ |
248 | |||
249 | static int | 264 | static int |
250 | setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | 265 | setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, |
251 | struct pt_regs *regs, unsigned long mask) | 266 | struct pt_regs *regs, unsigned long mask) |
@@ -276,9 +291,9 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | |||
276 | 291 | ||
277 | tmp = save_i387(fpstate); | 292 | tmp = save_i387(fpstate); |
278 | if (tmp < 0) | 293 | if (tmp < 0) |
279 | err = 1; | 294 | err = 1; |
280 | else | 295 | else |
281 | err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate); | 296 | err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate); |
282 | 297 | ||
283 | /* non-iBCS2 extensions.. */ | 298 | /* non-iBCS2 extensions.. */ |
284 | err |= __put_user(mask, &sc->oldmask); | 299 | err |= __put_user(mask, &sc->oldmask); |
@@ -291,7 +306,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | |||
291 | * Determine which stack to use.. | 306 | * Determine which stack to use.. |
292 | */ | 307 | */ |
293 | static inline void __user * | 308 | static inline void __user * |
294 | get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) | 309 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) |
295 | { | 310 | { |
296 | unsigned long sp; | 311 | unsigned long sp; |
297 | 312 | ||
@@ -309,32 +324,37 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) | |||
309 | if (ka->sa.sa_flags & SA_ONSTACK) { | 324 | if (ka->sa.sa_flags & SA_ONSTACK) { |
310 | if (sas_ss_flags(sp) == 0) | 325 | if (sas_ss_flags(sp) == 0) |
311 | sp = current->sas_ss_sp + current->sas_ss_size; | 326 | sp = current->sas_ss_sp + current->sas_ss_size; |
312 | } | 327 | } else { |
313 | 328 | /* This is the legacy signal stack switching. */ | |
314 | /* This is the legacy signal stack switching. */ | 329 | if ((regs->ss & 0xffff) != __USER_DS && |
315 | else if ((regs->ss & 0xffff) != __USER_DS && | 330 | !(ka->sa.sa_flags & SA_RESTORER) && |
316 | !(ka->sa.sa_flags & SA_RESTORER) && | 331 | ka->sa.sa_restorer) |
317 | ka->sa.sa_restorer) { | 332 | sp = (unsigned long) ka->sa.sa_restorer; |
318 | sp = (unsigned long) ka->sa.sa_restorer; | ||
319 | } | 333 | } |
320 | 334 | ||
321 | sp -= frame_size; | 335 | sp -= frame_size; |
322 | /* Align the stack pointer according to the i386 ABI, | 336 | /* |
323 | * i.e. so that on function entry ((sp + 4) & 15) == 0. */ | 337 | * Align the stack pointer according to the i386 ABI, |
338 | * i.e. so that on function entry ((sp + 4) & 15) == 0. | ||
339 | */ | ||
324 | sp = ((sp + 4) & -16ul) - 4; | 340 | sp = ((sp + 4) & -16ul) - 4; |
341 | |||
325 | return (void __user *) sp; | 342 | return (void __user *) sp; |
326 | } | 343 | } |
327 | 344 | ||
328 | /* These symbols are defined with the addresses in the vsyscall page. | 345 | /* |
329 | See vsyscall-sigreturn.S. */ | 346 | * These symbols are defined with the addresses in the vsyscall page. |
347 | * See vsyscall-sigreturn.S. | ||
348 | */ | ||
330 | extern void __user __kernel_sigreturn; | 349 | extern void __user __kernel_sigreturn; |
331 | extern void __user __kernel_rt_sigreturn; | 350 | extern void __user __kernel_rt_sigreturn; |
332 | 351 | ||
333 | static int setup_frame(int sig, struct k_sigaction *ka, | 352 | static int |
334 | sigset_t *set, struct pt_regs * regs) | 353 | setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, |
354 | struct pt_regs *regs) | ||
335 | { | 355 | { |
336 | void __user *restorer; | ||
337 | struct sigframe __user *frame; | 356 | struct sigframe __user *frame; |
357 | void __user *restorer; | ||
338 | int err = 0; | 358 | int err = 0; |
339 | int usig; | 359 | int usig; |
340 | 360 | ||
@@ -373,9 +393,9 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
373 | 393 | ||
374 | /* Set up to return from userspace. */ | 394 | /* Set up to return from userspace. */ |
375 | err |= __put_user(restorer, &frame->pretcode); | 395 | err |= __put_user(restorer, &frame->pretcode); |
376 | 396 | ||
377 | /* | 397 | /* |
378 | * This is popl %eax ; movl $,%eax ; int $0x80 | 398 | * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80 |
379 | * | 399 | * |
380 | * WE DO NOT USE IT ANY MORE! It's only left here for historical | 400 | * WE DO NOT USE IT ANY MORE! It's only left here for historical |
381 | * reasons and because gdb uses it as a signature to notice | 401 | * reasons and because gdb uses it as a signature to notice |
@@ -389,9 +409,9 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
389 | goto give_sigsegv; | 409 | goto give_sigsegv; |
390 | 410 | ||
391 | /* Set up registers for signal handler */ | 411 | /* Set up registers for signal handler */ |
392 | regs->sp = (unsigned long) frame; | 412 | regs->sp = (unsigned long)frame; |
393 | regs->ip = (unsigned long) ka->sa.sa_handler; | 413 | regs->ip = (unsigned long)ka->sa.sa_handler; |
394 | regs->ax = (unsigned long) sig; | 414 | regs->ax = (unsigned long)sig; |
395 | regs->dx = 0; | 415 | regs->dx = 0; |
396 | regs->cx = 0; | 416 | regs->cx = 0; |
397 | 417 | ||
@@ -418,10 +438,10 @@ give_sigsegv: | |||
418 | } | 438 | } |
419 | 439 | ||
420 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 440 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
421 | sigset_t *set, struct pt_regs * regs) | 441 | sigset_t *set, struct pt_regs *regs) |
422 | { | 442 | { |
423 | void __user *restorer; | ||
424 | struct rt_sigframe __user *frame; | 443 | struct rt_sigframe __user *frame; |
444 | void __user *restorer; | ||
425 | int err = 0; | 445 | int err = 0; |
426 | int usig; | 446 | int usig; |
427 | 447 | ||
@@ -451,7 +471,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
451 | &frame->uc.uc_stack.ss_flags); | 471 | &frame->uc.uc_stack.ss_flags); |
452 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | 472 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); |
453 | err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate, | 473 | err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate, |
454 | regs, set->sig[0]); | 474 | regs, set->sig[0]); |
455 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 475 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
456 | if (err) | 476 | if (err) |
457 | goto give_sigsegv; | 477 | goto give_sigsegv; |
@@ -461,9 +481,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
461 | if (ka->sa.sa_flags & SA_RESTORER) | 481 | if (ka->sa.sa_flags & SA_RESTORER) |
462 | restorer = ka->sa.sa_restorer; | 482 | restorer = ka->sa.sa_restorer; |
463 | err |= __put_user(restorer, &frame->pretcode); | 483 | err |= __put_user(restorer, &frame->pretcode); |
464 | 484 | ||
465 | /* | 485 | /* |
466 | * This is movl $,%ax ; int $0x80 | 486 | * This is movl $__NR_rt_sigreturn, %ax ; int $0x80 |
467 | * | 487 | * |
468 | * WE DO NOT USE IT ANY MORE! It's only left here for historical | 488 | * WE DO NOT USE IT ANY MORE! It's only left here for historical |
469 | * reasons and because gdb uses it as a signature to notice | 489 | * reasons and because gdb uses it as a signature to notice |
@@ -477,11 +497,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
477 | goto give_sigsegv; | 497 | goto give_sigsegv; |
478 | 498 | ||
479 | /* Set up registers for signal handler */ | 499 | /* Set up registers for signal handler */ |
480 | regs->sp = (unsigned long) frame; | 500 | regs->sp = (unsigned long)frame; |
481 | regs->ip = (unsigned long) ka->sa.sa_handler; | 501 | regs->ip = (unsigned long)ka->sa.sa_handler; |
482 | regs->ax = (unsigned long) usig; | 502 | regs->ax = (unsigned long)usig; |
483 | regs->dx = (unsigned long) &frame->info; | 503 | regs->dx = (unsigned long)&frame->info; |
484 | regs->cx = (unsigned long) &frame->uc; | 504 | regs->cx = (unsigned long)&frame->uc; |
485 | 505 | ||
486 | regs->ds = __USER_DS; | 506 | regs->ds = __USER_DS; |
487 | regs->es = __USER_DS; | 507 | regs->es = __USER_DS; |
@@ -506,9 +526,8 @@ give_sigsegv: | |||
506 | } | 526 | } |
507 | 527 | ||
508 | /* | 528 | /* |
509 | * OK, we're invoking a handler | 529 | * OK, we're invoking a handler: |
510 | */ | 530 | */ |
511 | |||
512 | static int | 531 | static int |
513 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 532 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
514 | sigset_t *oldset, struct pt_regs *regs) | 533 | sigset_t *oldset, struct pt_regs *regs) |
@@ -551,16 +570,17 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
551 | else | 570 | else |
552 | ret = setup_frame(sig, ka, oldset, regs); | 571 | ret = setup_frame(sig, ka, oldset, regs); |
553 | 572 | ||
554 | if (ret == 0) { | 573 | if (ret) |
555 | spin_lock_irq(¤t->sighand->siglock); | 574 | return ret; |
556 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
557 | if (!(ka->sa.sa_flags & SA_NODEFER)) | ||
558 | sigaddset(¤t->blocked,sig); | ||
559 | recalc_sigpending(); | ||
560 | spin_unlock_irq(¤t->sighand->siglock); | ||
561 | } | ||
562 | 575 | ||
563 | return ret; | 576 | spin_lock_irq(¤t->sighand->siglock); |
577 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); | ||
578 | if (!(ka->sa.sa_flags & SA_NODEFER)) | ||
579 | sigaddset(¤t->blocked, sig); | ||
580 | recalc_sigpending(); | ||
581 | spin_unlock_irq(¤t->sighand->siglock); | ||
582 | |||
583 | return 0; | ||
564 | } | 584 | } |
565 | 585 | ||
566 | /* | 586 | /* |
@@ -592,7 +612,8 @@ static void do_signal(struct pt_regs *regs) | |||
592 | 612 | ||
593 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 613 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
594 | if (signr > 0) { | 614 | if (signr > 0) { |
595 | /* Re-enable any watchpoints before delivering the | 615 | /* |
616 | * Re-enable any watchpoints before delivering the | ||
596 | * signal to user space. The processor register will | 617 | * signal to user space. The processor register will |
597 | * have been cleared if the watchpoint triggered | 618 | * have been cleared if the watchpoint triggered |
598 | * inside the kernel. | 619 | * inside the kernel. |
@@ -600,16 +621,17 @@ static void do_signal(struct pt_regs *regs) | |||
600 | if (current->thread.debugreg7) | 621 | if (current->thread.debugreg7) |
601 | set_debugreg(current->thread.debugreg7, 7); | 622 | set_debugreg(current->thread.debugreg7, 7); |
602 | 623 | ||
603 | /* Whee! Actually deliver the signal. */ | 624 | /* Whee! Actually deliver the signal. */ |
604 | if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { | 625 | if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { |
605 | /* a signal was successfully delivered; the saved | 626 | /* |
627 | * a signal was successfully delivered; the saved | ||
606 | * sigmask will have been stored in the signal frame, | 628 | * sigmask will have been stored in the signal frame, |
607 | * and will be restored by sigreturn, so we can simply | 629 | * and will be restored by sigreturn, so we can simply |
608 | * clear the TIF_RESTORE_SIGMASK flag */ | 630 | * clear the TIF_RESTORE_SIGMASK flag |
631 | */ | ||
609 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | 632 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
610 | clear_thread_flag(TIF_RESTORE_SIGMASK); | 633 | clear_thread_flag(TIF_RESTORE_SIGMASK); |
611 | } | 634 | } |
612 | |||
613 | return; | 635 | return; |
614 | } | 636 | } |
615 | 637 | ||
@@ -645,8 +667,8 @@ static void do_signal(struct pt_regs *regs) | |||
645 | * notification of userspace execution resumption | 667 | * notification of userspace execution resumption |
646 | * - triggered by the TIF_WORK_MASK flags | 668 | * - triggered by the TIF_WORK_MASK flags |
647 | */ | 669 | */ |
648 | void do_notify_resume(struct pt_regs *regs, void *unused, | 670 | void |
649 | __u32 thread_info_flags) | 671 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) |
650 | { | 672 | { |
651 | /* Pending single-step? */ | 673 | /* Pending single-step? */ |
652 | if (thread_info_flags & _TIF_SINGLESTEP) { | 674 | if (thread_info_flags & _TIF_SINGLESTEP) { |
@@ -660,6 +682,6 @@ void do_notify_resume(struct pt_regs *regs, void *unused, | |||
660 | 682 | ||
661 | if (thread_info_flags & _TIF_HRTICK_RESCHED) | 683 | if (thread_info_flags & _TIF_HRTICK_RESCHED) |
662 | hrtick_resched(); | 684 | hrtick_resched(); |
663 | 685 | ||
664 | clear_thread_flag(TIF_IRET); | 686 | clear_thread_flag(TIF_IRET); |
665 | } | 687 | } |