diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-09 12:58:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-09 12:58:12 -0400 |
commit | 63b12bdb0d21aca527996fb2c547387bfd3e14b8 (patch) | |
tree | 6ab83b2a1c289f30fea18b88f04138ee69c37c6f | |
parent | ad1f5caf34390bb20fdbb4eaf71b0494e89936f0 (diff) | |
parent | 059ade650ae57cfd371af690fdba887af04aded8 (diff) |
Merge branch 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc
Pull arch signal handling cleanup from Richard Weinberger:
"This patch series moves all remaining archs to the get_signal(),
signal_setup_done() and sigsp() functions.
Currently these archs use open coded variants of the said functions.
Further, unused parameters get removed from get_signal_to_deliver(),
tracehook_signal_handler() and signal_delivered().
At the end of the day we save around 500 lines of code."
* 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc: (43 commits)
powerpc: Use sigsp()
openrisc: Use sigsp()
mn10300: Use sigsp()
mips: Use sigsp()
microblaze: Use sigsp()
metag: Use sigsp()
m68k: Use sigsp()
m32r: Use sigsp()
hexagon: Use sigsp()
frv: Use sigsp()
cris: Use sigsp()
c6x: Use sigsp()
blackfin: Use sigsp()
avr32: Use sigsp()
arm64: Use sigsp()
arc: Use sigsp()
sas_ss_flags: Remove nested ternary if
Rip out get_signal_to_deliver()
Clean up signal_delivered()
tracehook_signal_handler: Remove sig, info, ka and regs
...
46 files changed, 789 insertions, 1238 deletions
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c index 7e95e1a86510..cb3142a2d40b 100644 --- a/arch/arc/kernel/signal.c +++ b/arch/arc/kernel/signal.c | |||
@@ -141,17 +141,13 @@ badframe: | |||
141 | /* | 141 | /* |
142 | * Determine which stack to use.. | 142 | * Determine which stack to use.. |
143 | */ | 143 | */ |
144 | static inline void __user *get_sigframe(struct k_sigaction *ka, | 144 | static inline void __user *get_sigframe(struct ksignal *ksig, |
145 | struct pt_regs *regs, | 145 | struct pt_regs *regs, |
146 | unsigned long framesize) | 146 | unsigned long framesize) |
147 | { | 147 | { |
148 | unsigned long sp = regs->sp; | 148 | unsigned long sp = sigsp(regs->sp, ksig); |
149 | void __user *frame; | 149 | void __user *frame; |
150 | 150 | ||
151 | /* This is the X/Open sanctioned signal stack switching */ | ||
152 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) | ||
153 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
154 | |||
155 | /* No matter what happens, 'sp' must be word | 151 | /* No matter what happens, 'sp' must be word |
156 | * aligned otherwise nasty things could happen | 152 | * aligned otherwise nasty things could happen |
157 | */ | 153 | */ |
@@ -179,14 +175,13 @@ static inline int map_sig(int sig) | |||
179 | } | 175 | } |
180 | 176 | ||
181 | static int | 177 | static int |
182 | setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info, | 178 | setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
183 | sigset_t *set, struct pt_regs *regs) | ||
184 | { | 179 | { |
185 | struct rt_sigframe __user *sf; | 180 | struct rt_sigframe __user *sf; |
186 | unsigned int magic = 0; | 181 | unsigned int magic = 0; |
187 | int err = 0; | 182 | int err = 0; |
188 | 183 | ||
189 | sf = get_sigframe(ka, regs, sizeof(struct rt_sigframe)); | 184 | sf = get_sigframe(ksig, regs, sizeof(struct rt_sigframe)); |
190 | if (!sf) | 185 | if (!sf) |
191 | return 1; | 186 | return 1; |
192 | 187 | ||
@@ -205,8 +200,8 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info, | |||
205 | * #2: struct siginfo | 200 | * #2: struct siginfo |
206 | * #3: struct ucontext (completely populated) | 201 | * #3: struct ucontext (completely populated) |
207 | */ | 202 | */ |
208 | if (unlikely(ka->sa.sa_flags & SA_SIGINFO)) { | 203 | if (unlikely(ksig->ka.sa.sa_flags & SA_SIGINFO)) { |
209 | err |= copy_siginfo_to_user(&sf->info, info); | 204 | err |= copy_siginfo_to_user(&sf->info, &ksig->info); |
210 | err |= __put_user(0, &sf->uc.uc_flags); | 205 | err |= __put_user(0, &sf->uc.uc_flags); |
211 | err |= __put_user(NULL, &sf->uc.uc_link); | 206 | err |= __put_user(NULL, &sf->uc.uc_link); |
212 | err |= __save_altstack(&sf->uc.uc_stack, regs->sp); | 207 | err |= __save_altstack(&sf->uc.uc_stack, regs->sp); |
@@ -227,16 +222,16 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info, | |||
227 | return err; | 222 | return err; |
228 | 223 | ||
229 | /* #1 arg to the user Signal handler */ | 224 | /* #1 arg to the user Signal handler */ |
230 | regs->r0 = map_sig(signo); | 225 | regs->r0 = map_sig(ksig->sig); |
231 | 226 | ||
232 | /* setup PC of user space signal handler */ | 227 | /* setup PC of user space signal handler */ |
233 | regs->ret = (unsigned long)ka->sa.sa_handler; | 228 | regs->ret = (unsigned long)ksig->ka.sa.sa_handler; |
234 | 229 | ||
235 | /* | 230 | /* |
236 | * handler returns using sigreturn stub provided already by userpsace | 231 | * handler returns using sigreturn stub provided already by userpsace |
237 | */ | 232 | */ |
238 | BUG_ON(!(ka->sa.sa_flags & SA_RESTORER)); | 233 | BUG_ON(!(ksig->ka.sa.sa_flags & SA_RESTORER)); |
239 | regs->blink = (unsigned long)ka->sa.sa_restorer; | 234 | regs->blink = (unsigned long)ksig->ka.sa.sa_restorer; |
240 | 235 | ||
241 | /* User Stack for signal handler will be above the frame just carved */ | 236 | /* User Stack for signal handler will be above the frame just carved */ |
242 | regs->sp = (unsigned long)sf; | 237 | regs->sp = (unsigned long)sf; |
@@ -298,38 +293,30 @@ static void arc_restart_syscall(struct k_sigaction *ka, struct pt_regs *regs) | |||
298 | * OK, we're invoking a handler | 293 | * OK, we're invoking a handler |
299 | */ | 294 | */ |
300 | static void | 295 | static void |
301 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 296 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
302 | struct pt_regs *regs) | ||
303 | { | 297 | { |
304 | sigset_t *oldset = sigmask_to_save(); | 298 | sigset_t *oldset = sigmask_to_save(); |
305 | int ret; | 299 | int ret; |
306 | 300 | ||
307 | /* Set up the stack frame */ | 301 | /* Set up the stack frame */ |
308 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 302 | ret = setup_rt_frame(ksig, oldset, regs); |
309 | 303 | ||
310 | if (ret) | 304 | signal_setup_done(ret, ksig, 0); |
311 | force_sigsegv(sig, current); | ||
312 | else | ||
313 | signal_delivered(sig, info, ka, regs, 0); | ||
314 | } | 305 | } |
315 | 306 | ||
316 | void do_signal(struct pt_regs *regs) | 307 | void do_signal(struct pt_regs *regs) |
317 | { | 308 | { |
318 | struct k_sigaction ka; | 309 | struct ksignal ksig; |
319 | siginfo_t info; | ||
320 | int signr; | ||
321 | int restart_scall; | 310 | int restart_scall; |
322 | 311 | ||
323 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | ||
324 | |||
325 | restart_scall = in_syscall(regs) && syscall_restartable(regs); | 312 | restart_scall = in_syscall(regs) && syscall_restartable(regs); |
326 | 313 | ||
327 | if (signr > 0) { | 314 | if (get_signal(&ksig)) { |
328 | if (restart_scall) { | 315 | if (restart_scall) { |
329 | arc_restart_syscall(&ka, regs); | 316 | arc_restart_syscall(&ksig.ka, regs); |
330 | syscall_wont_restart(regs); /* No more restarts */ | 317 | syscall_wont_restart(regs); /* No more restarts */ |
331 | } | 318 | } |
332 | handle_signal(signr, &ka, &info, regs); | 319 | handle_signal(&ksig, regs); |
333 | return; | 320 | return; |
334 | } | 321 | } |
335 | 322 | ||
diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h index 7c275e3b640f..eeaa97559bab 100644 --- a/arch/arm64/include/asm/signal32.h +++ b/arch/arm64/include/asm/signal32.h | |||
@@ -24,22 +24,21 @@ | |||
24 | 24 | ||
25 | extern const compat_ulong_t aarch32_sigret_code[6]; | 25 | extern const compat_ulong_t aarch32_sigret_code[6]; |
26 | 26 | ||
27 | int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, | 27 | int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set, |
28 | struct pt_regs *regs); | 28 | struct pt_regs *regs); |
29 | int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | 29 | int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, |
30 | sigset_t *set, struct pt_regs *regs); | 30 | struct pt_regs *regs); |
31 | 31 | ||
32 | void compat_setup_restart_syscall(struct pt_regs *regs); | 32 | void compat_setup_restart_syscall(struct pt_regs *regs); |
33 | #else | 33 | #else |
34 | 34 | ||
35 | static inline int compat_setup_frame(int usid, struct k_sigaction *ka, | 35 | static inline int compat_setup_frame(int usid, struct ksignal *ksig, |
36 | sigset_t *set, struct pt_regs *regs) | 36 | sigset_t *set, struct pt_regs *regs) |
37 | { | 37 | { |
38 | return -ENOSYS; | 38 | return -ENOSYS; |
39 | } | 39 | } |
40 | 40 | ||
41 | static inline int compat_setup_rt_frame(int usig, struct k_sigaction *ka, | 41 | static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, |
42 | siginfo_t *info, sigset_t *set, | ||
43 | struct pt_regs *regs) | 42 | struct pt_regs *regs) |
44 | { | 43 | { |
45 | return -ENOSYS; | 44 | return -ENOSYS; |
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 6357b9c6c90e..6fa792137eda 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c | |||
@@ -209,19 +209,13 @@ static int setup_sigframe(struct rt_sigframe __user *sf, | |||
209 | return err; | 209 | return err; |
210 | } | 210 | } |
211 | 211 | ||
212 | static struct rt_sigframe __user *get_sigframe(struct k_sigaction *ka, | 212 | static struct rt_sigframe __user *get_sigframe(struct ksignal *ksig, |
213 | struct pt_regs *regs) | 213 | struct pt_regs *regs) |
214 | { | 214 | { |
215 | unsigned long sp, sp_top; | 215 | unsigned long sp, sp_top; |
216 | struct rt_sigframe __user *frame; | 216 | struct rt_sigframe __user *frame; |
217 | 217 | ||
218 | sp = sp_top = regs->sp; | 218 | sp = sp_top = sigsp(regs->sp, ksig); |
219 | |||
220 | /* | ||
221 | * This is the X/Open sanctioned signal stack switching. | ||
222 | */ | ||
223 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) | ||
224 | sp = sp_top = current->sas_ss_sp + current->sas_ss_size; | ||
225 | 219 | ||
226 | sp = (sp - sizeof(struct rt_sigframe)) & ~15; | 220 | sp = (sp - sizeof(struct rt_sigframe)) & ~15; |
227 | frame = (struct rt_sigframe __user *)sp; | 221 | frame = (struct rt_sigframe __user *)sp; |
@@ -253,13 +247,13 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, | |||
253 | regs->regs[30] = (unsigned long)sigtramp; | 247 | regs->regs[30] = (unsigned long)sigtramp; |
254 | } | 248 | } |
255 | 249 | ||
256 | static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | 250 | static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, |
257 | sigset_t *set, struct pt_regs *regs) | 251 | struct pt_regs *regs) |
258 | { | 252 | { |
259 | struct rt_sigframe __user *frame; | 253 | struct rt_sigframe __user *frame; |
260 | int err = 0; | 254 | int err = 0; |
261 | 255 | ||
262 | frame = get_sigframe(ka, regs); | 256 | frame = get_sigframe(ksig, regs); |
263 | if (!frame) | 257 | if (!frame) |
264 | return 1; | 258 | return 1; |
265 | 259 | ||
@@ -269,9 +263,9 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
269 | err |= __save_altstack(&frame->uc.uc_stack, regs->sp); | 263 | err |= __save_altstack(&frame->uc.uc_stack, regs->sp); |
270 | err |= setup_sigframe(frame, regs, set); | 264 | err |= setup_sigframe(frame, regs, set); |
271 | if (err == 0) { | 265 | if (err == 0) { |
272 | setup_return(regs, ka, frame, usig); | 266 | setup_return(regs, &ksig->ka, frame, usig); |
273 | if (ka->sa.sa_flags & SA_SIGINFO) { | 267 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
274 | err |= copy_siginfo_to_user(&frame->info, info); | 268 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
275 | regs->regs[1] = (unsigned long)&frame->info; | 269 | regs->regs[1] = (unsigned long)&frame->info; |
276 | regs->regs[2] = (unsigned long)&frame->uc; | 270 | regs->regs[2] = (unsigned long)&frame->uc; |
277 | } | 271 | } |
@@ -291,13 +285,12 @@ static void setup_restart_syscall(struct pt_regs *regs) | |||
291 | /* | 285 | /* |
292 | * OK, we're invoking a handler | 286 | * OK, we're invoking a handler |
293 | */ | 287 | */ |
294 | static void handle_signal(unsigned long sig, struct k_sigaction *ka, | 288 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
295 | siginfo_t *info, struct pt_regs *regs) | ||
296 | { | 289 | { |
297 | struct thread_info *thread = current_thread_info(); | 290 | struct thread_info *thread = current_thread_info(); |
298 | struct task_struct *tsk = current; | 291 | struct task_struct *tsk = current; |
299 | sigset_t *oldset = sigmask_to_save(); | 292 | sigset_t *oldset = sigmask_to_save(); |
300 | int usig = sig; | 293 | int usig = ksig->sig; |
301 | int ret; | 294 | int ret; |
302 | 295 | ||
303 | /* | 296 | /* |
@@ -310,13 +303,12 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
310 | * Set up the stack frame | 303 | * Set up the stack frame |
311 | */ | 304 | */ |
312 | if (is_compat_task()) { | 305 | if (is_compat_task()) { |
313 | if (ka->sa.sa_flags & SA_SIGINFO) | 306 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
314 | ret = compat_setup_rt_frame(usig, ka, info, oldset, | 307 | ret = compat_setup_rt_frame(usig, ksig, oldset, regs); |
315 | regs); | ||
316 | else | 308 | else |
317 | ret = compat_setup_frame(usig, ka, oldset, regs); | 309 | ret = compat_setup_frame(usig, ksig, oldset, regs); |
318 | } else { | 310 | } else { |
319 | ret = setup_rt_frame(usig, ka, info, oldset, regs); | 311 | ret = setup_rt_frame(usig, ksig, oldset, regs); |
320 | } | 312 | } |
321 | 313 | ||
322 | /* | 314 | /* |
@@ -324,18 +316,14 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
324 | */ | 316 | */ |
325 | ret |= !valid_user_regs(®s->user_regs); | 317 | ret |= !valid_user_regs(®s->user_regs); |
326 | 318 | ||
327 | if (ret != 0) { | ||
328 | force_sigsegv(sig, tsk); | ||
329 | return; | ||
330 | } | ||
331 | |||
332 | /* | 319 | /* |
333 | * Fast forward the stepping logic so we step into the signal | 320 | * Fast forward the stepping logic so we step into the signal |
334 | * handler. | 321 | * handler. |
335 | */ | 322 | */ |
336 | user_fastforward_single_step(tsk); | 323 | if (!ret) |
324 | user_fastforward_single_step(tsk); | ||
337 | 325 | ||
338 | signal_delivered(sig, info, ka, regs, 0); | 326 | signal_setup_done(ret, ksig, 0); |
339 | } | 327 | } |
340 | 328 | ||
341 | /* | 329 | /* |
@@ -350,10 +338,9 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
350 | static void do_signal(struct pt_regs *regs) | 338 | static void do_signal(struct pt_regs *regs) |
351 | { | 339 | { |
352 | unsigned long continue_addr = 0, restart_addr = 0; | 340 | unsigned long continue_addr = 0, restart_addr = 0; |
353 | struct k_sigaction ka; | 341 | int retval = 0; |
354 | siginfo_t info; | ||
355 | int signr, retval = 0; | ||
356 | int syscall = (int)regs->syscallno; | 342 | int syscall = (int)regs->syscallno; |
343 | struct ksignal ksig; | ||
357 | 344 | ||
358 | /* | 345 | /* |
359 | * If we were from a system call, check for system call restarting... | 346 | * If we were from a system call, check for system call restarting... |
@@ -387,8 +374,7 @@ static void do_signal(struct pt_regs *regs) | |||
387 | * Get the signal to deliver. When running under ptrace, at this point | 374 | * Get the signal to deliver. When running under ptrace, at this point |
388 | * the debugger may change all of our registers. | 375 | * the debugger may change all of our registers. |
389 | */ | 376 | */ |
390 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 377 | if (get_signal(&ksig)) { |
391 | if (signr > 0) { | ||
392 | /* | 378 | /* |
393 | * Depending on the signal settings, we may need to revert the | 379 | * Depending on the signal settings, we may need to revert the |
394 | * decision to restart the system call, but skip this if a | 380 | * decision to restart the system call, but skip this if a |
@@ -398,12 +384,12 @@ static void do_signal(struct pt_regs *regs) | |||
398 | (retval == -ERESTARTNOHAND || | 384 | (retval == -ERESTARTNOHAND || |
399 | retval == -ERESTART_RESTARTBLOCK || | 385 | retval == -ERESTART_RESTARTBLOCK || |
400 | (retval == -ERESTARTSYS && | 386 | (retval == -ERESTARTSYS && |
401 | !(ka.sa.sa_flags & SA_RESTART)))) { | 387 | !(ksig.ka.sa.sa_flags & SA_RESTART)))) { |
402 | regs->regs[0] = -EINTR; | 388 | regs->regs[0] = -EINTR; |
403 | regs->pc = continue_addr; | 389 | regs->pc = continue_addr; |
404 | } | 390 | } |
405 | 391 | ||
406 | handle_signal(signr, &ka, &info, regs); | 392 | handle_signal(&ksig, regs); |
407 | return; | 393 | return; |
408 | } | 394 | } |
409 | 395 | ||
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index c5ee208321c3..1b9ad02837cf 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c | |||
@@ -407,20 +407,14 @@ badframe: | |||
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | static void __user *compat_get_sigframe(struct k_sigaction *ka, | 410 | static void __user *compat_get_sigframe(struct ksignal *ksig, |
411 | struct pt_regs *regs, | 411 | struct pt_regs *regs, |
412 | int framesize) | 412 | int framesize) |
413 | { | 413 | { |
414 | compat_ulong_t sp = regs->compat_sp; | 414 | compat_ulong_t sp = sigsp(regs->compat_sp, ksig); |
415 | void __user *frame; | 415 | void __user *frame; |
416 | 416 | ||
417 | /* | 417 | /* |
418 | * This is the X/Open sanctioned signal stack switching. | ||
419 | */ | ||
420 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) | ||
421 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
422 | |||
423 | /* | ||
424 | * ATPCS B01 mandates 8-byte alignment | 418 | * ATPCS B01 mandates 8-byte alignment |
425 | */ | 419 | */ |
426 | frame = compat_ptr((compat_uptr_t)((sp - framesize) & ~7)); | 420 | frame = compat_ptr((compat_uptr_t)((sp - framesize) & ~7)); |
@@ -520,18 +514,18 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf, | |||
520 | /* | 514 | /* |
521 | * 32-bit signal handling routines called from signal.c | 515 | * 32-bit signal handling routines called from signal.c |
522 | */ | 516 | */ |
523 | int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | 517 | int compat_setup_rt_frame(int usig, struct ksignal *ksig, |
524 | sigset_t *set, struct pt_regs *regs) | 518 | sigset_t *set, struct pt_regs *regs) |
525 | { | 519 | { |
526 | struct compat_rt_sigframe __user *frame; | 520 | struct compat_rt_sigframe __user *frame; |
527 | int err = 0; | 521 | int err = 0; |
528 | 522 | ||
529 | frame = compat_get_sigframe(ka, regs, sizeof(*frame)); | 523 | frame = compat_get_sigframe(ksig, regs, sizeof(*frame)); |
530 | 524 | ||
531 | if (!frame) | 525 | if (!frame) |
532 | return 1; | 526 | return 1; |
533 | 527 | ||
534 | err |= copy_siginfo_to_user32(&frame->info, info); | 528 | err |= copy_siginfo_to_user32(&frame->info, &ksig->info); |
535 | 529 | ||
536 | __put_user_error(0, &frame->sig.uc.uc_flags, err); | 530 | __put_user_error(0, &frame->sig.uc.uc_flags, err); |
537 | __put_user_error(0, &frame->sig.uc.uc_link, err); | 531 | __put_user_error(0, &frame->sig.uc.uc_link, err); |
@@ -541,7 +535,7 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
541 | err |= compat_setup_sigframe(&frame->sig, regs, set); | 535 | err |= compat_setup_sigframe(&frame->sig, regs, set); |
542 | 536 | ||
543 | if (err == 0) { | 537 | if (err == 0) { |
544 | compat_setup_return(regs, ka, frame->sig.retcode, frame, usig); | 538 | compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig); |
545 | regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info; | 539 | regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info; |
546 | regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc; | 540 | regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc; |
547 | } | 541 | } |
@@ -549,13 +543,13 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | |||
549 | return err; | 543 | return err; |
550 | } | 544 | } |
551 | 545 | ||
552 | int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, | 546 | int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set, |
553 | struct pt_regs *regs) | 547 | struct pt_regs *regs) |
554 | { | 548 | { |
555 | struct compat_sigframe __user *frame; | 549 | struct compat_sigframe __user *frame; |
556 | int err = 0; | 550 | int err = 0; |
557 | 551 | ||
558 | frame = compat_get_sigframe(ka, regs, sizeof(*frame)); | 552 | frame = compat_get_sigframe(ksig, regs, sizeof(*frame)); |
559 | 553 | ||
560 | if (!frame) | 554 | if (!frame) |
561 | return 1; | 555 | return 1; |
@@ -564,7 +558,7 @@ int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, | |||
564 | 558 | ||
565 | err |= compat_setup_sigframe(frame, regs, set); | 559 | err |= compat_setup_sigframe(frame, regs, set); |
566 | if (err == 0) | 560 | if (err == 0) |
567 | compat_setup_return(regs, ka, frame->retcode, frame, usig); | 561 | compat_setup_return(regs, &ksig->ka, frame->retcode, frame, usig); |
568 | 562 | ||
569 | return err; | 563 | return err; |
570 | } | 564 | } |
diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c index b80c0b3d2bab..d309fbcc3bd6 100644 --- a/arch/avr32/kernel/signal.c +++ b/arch/avr32/kernel/signal.c | |||
@@ -127,24 +127,20 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | static inline void __user * | 129 | static inline void __user * |
130 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize) | 130 | get_sigframe(struct ksignal *ksig, struct pt_regs *regs, int framesize) |
131 | { | 131 | { |
132 | unsigned long sp = regs->sp; | 132 | unsigned long sp = sigsp(regs->sp, ksig); |
133 | |||
134 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) | ||
135 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
136 | 133 | ||
137 | return (void __user *)((sp - framesize) & ~3); | 134 | return (void __user *)((sp - framesize) & ~3); |
138 | } | 135 | } |
139 | 136 | ||
140 | static int | 137 | static int |
141 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 138 | setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
142 | sigset_t *set, struct pt_regs *regs) | ||
143 | { | 139 | { |
144 | struct rt_sigframe __user *frame; | 140 | struct rt_sigframe __user *frame; |
145 | int err = 0; | 141 | int err = 0; |
146 | 142 | ||
147 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 143 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
148 | err = -EFAULT; | 144 | err = -EFAULT; |
149 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 145 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
150 | goto out; | 146 | goto out; |
@@ -164,7 +160,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
164 | err = __put_user(0x3008d733 | (__NR_rt_sigreturn << 20), | 160 | err = __put_user(0x3008d733 | (__NR_rt_sigreturn << 20), |
165 | &frame->retcode); | 161 | &frame->retcode); |
166 | 162 | ||
167 | err |= copy_siginfo_to_user(&frame->info, info); | 163 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
168 | 164 | ||
169 | /* Set up the ucontext */ | 165 | /* Set up the ucontext */ |
170 | err |= __put_user(0, &frame->uc.uc_flags); | 166 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -176,12 +172,12 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
176 | if (err) | 172 | if (err) |
177 | goto out; | 173 | goto out; |
178 | 174 | ||
179 | regs->r12 = sig; | 175 | regs->r12 = ksig->sig; |
180 | regs->r11 = (unsigned long) &frame->info; | 176 | regs->r11 = (unsigned long) &frame->info; |
181 | regs->r10 = (unsigned long) &frame->uc; | 177 | regs->r10 = (unsigned long) &frame->uc; |
182 | regs->sp = (unsigned long) frame; | 178 | regs->sp = (unsigned long) frame; |
183 | if (ka->sa.sa_flags & SA_RESTORER) | 179 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
184 | regs->lr = (unsigned long)ka->sa.sa_restorer; | 180 | regs->lr = (unsigned long)ksig->ka.sa.sa_restorer; |
185 | else { | 181 | else { |
186 | printk(KERN_NOTICE "[%s:%d] did not set SA_RESTORER\n", | 182 | printk(KERN_NOTICE "[%s:%d] did not set SA_RESTORER\n", |
187 | current->comm, current->pid); | 183 | current->comm, current->pid); |
@@ -189,10 +185,10 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
189 | } | 185 | } |
190 | 186 | ||
191 | pr_debug("SIG deliver [%s:%d]: sig=%d sp=0x%lx pc=0x%lx->0x%p lr=0x%lx\n", | 187 | pr_debug("SIG deliver [%s:%d]: sig=%d sp=0x%lx pc=0x%lx->0x%p lr=0x%lx\n", |
192 | current->comm, current->pid, sig, regs->sp, | 188 | current->comm, current->pid, ksig->sig, regs->sp, |
193 | regs->pc, ka->sa.sa_handler, regs->lr); | 189 | regs->pc, ksig->ka.sa.sa_handler, regs->lr); |
194 | 190 | ||
195 | regs->pc = (unsigned long) ka->sa.sa_handler; | 191 | regs->pc = (unsigned long)ksig->ka.sa.sa_handler; |
196 | 192 | ||
197 | out: | 193 | out: |
198 | return err; | 194 | return err; |
@@ -208,15 +204,14 @@ static inline void setup_syscall_restart(struct pt_regs *regs) | |||
208 | } | 204 | } |
209 | 205 | ||
210 | static inline void | 206 | static inline void |
211 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 207 | handle_signal(struct ksignal *ksig, struct pt_regs *regs, int syscall) |
212 | struct pt_regs *regs, int syscall) | ||
213 | { | 208 | { |
214 | int ret; | 209 | int ret; |
215 | 210 | ||
216 | /* | 211 | /* |
217 | * Set up the stack frame | 212 | * Set up the stack frame |
218 | */ | 213 | */ |
219 | ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs); | 214 | ret = setup_rt_frame(ksig, sigmask_to_save(), regs); |
220 | 215 | ||
221 | /* | 216 | /* |
222 | * Check that the resulting registers are sane | 217 | * Check that the resulting registers are sane |
@@ -226,10 +221,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
226 | /* | 221 | /* |
227 | * Block the signal if we were successful. | 222 | * Block the signal if we were successful. |
228 | */ | 223 | */ |
229 | if (ret != 0) | 224 | signal_setup_done(ret, ksig, 0); |
230 | force_sigsegv(sig, current); | ||
231 | else | ||
232 | signal_delivered(sig, info, ka, regs, 0); | ||
233 | } | 225 | } |
234 | 226 | ||
235 | /* | 227 | /* |
@@ -239,9 +231,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
239 | */ | 231 | */ |
240 | static void do_signal(struct pt_regs *regs, int syscall) | 232 | static void do_signal(struct pt_regs *regs, int syscall) |
241 | { | 233 | { |
242 | siginfo_t info; | 234 | struct ksignal ksig; |
243 | int signr; | ||
244 | struct k_sigaction ka; | ||
245 | 235 | ||
246 | /* | 236 | /* |
247 | * We want the common case to go fast, which is why we may in | 237 | * We want the common case to go fast, which is why we may in |
@@ -251,18 +241,18 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
251 | if (!user_mode(regs)) | 241 | if (!user_mode(regs)) |
252 | return; | 242 | return; |
253 | 243 | ||
254 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 244 | get_signal(&ksig); |
255 | if (syscall) { | 245 | if (syscall) { |
256 | switch (regs->r12) { | 246 | switch (regs->r12) { |
257 | case -ERESTART_RESTARTBLOCK: | 247 | case -ERESTART_RESTARTBLOCK: |
258 | case -ERESTARTNOHAND: | 248 | case -ERESTARTNOHAND: |
259 | if (signr > 0) { | 249 | if (ksig.sig > 0) { |
260 | regs->r12 = -EINTR; | 250 | regs->r12 = -EINTR; |
261 | break; | 251 | break; |
262 | } | 252 | } |
263 | /* fall through */ | 253 | /* fall through */ |
264 | case -ERESTARTSYS: | 254 | case -ERESTARTSYS: |
265 | if (signr > 0 && !(ka.sa.sa_flags & SA_RESTART)) { | 255 | if (ksig.sig > 0 && !(ksig.ka.sa.sa_flags & SA_RESTART)) { |
266 | regs->r12 = -EINTR; | 256 | regs->r12 = -EINTR; |
267 | break; | 257 | break; |
268 | } | 258 | } |
@@ -272,13 +262,13 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
272 | } | 262 | } |
273 | } | 263 | } |
274 | 264 | ||
275 | if (signr == 0) { | 265 | if (!ksig.sig) { |
276 | /* No signal to deliver -- put the saved sigmask back */ | 266 | /* No signal to deliver -- put the saved sigmask back */ |
277 | restore_saved_sigmask(); | 267 | restore_saved_sigmask(); |
278 | return; | 268 | return; |
279 | } | 269 | } |
280 | 270 | ||
281 | handle_signal(signr, &ka, &info, regs, syscall); | 271 | handle_signal(&ksig, regs, syscall); |
282 | } | 272 | } |
283 | 273 | ||
284 | asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) | 274 | asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) |
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c index b022af6c48f8..ef275571d885 100644 --- a/arch/blackfin/kernel/signal.c +++ b/arch/blackfin/kernel/signal.c | |||
@@ -135,40 +135,31 @@ static inline int rt_setup_sigcontext(struct sigcontext *sc, struct pt_regs *reg | |||
135 | return err; | 135 | return err; |
136 | } | 136 | } |
137 | 137 | ||
138 | static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, | 138 | static inline void *get_sigframe(struct ksignal *ksig, |
139 | size_t frame_size) | 139 | size_t frame_size) |
140 | { | 140 | { |
141 | unsigned long usp; | 141 | unsigned long usp = sigsp(rdusp(), ksig); |
142 | 142 | ||
143 | /* Default to using normal stack. */ | ||
144 | usp = rdusp(); | ||
145 | |||
146 | /* This is the X/Open sanctioned signal stack switching. */ | ||
147 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
148 | if (!on_sig_stack(usp)) | ||
149 | usp = current->sas_ss_sp + current->sas_ss_size; | ||
150 | } | ||
151 | return (void *)((usp - frame_size) & -8UL); | 143 | return (void *)((usp - frame_size) & -8UL); |
152 | } | 144 | } |
153 | 145 | ||
154 | static int | 146 | static int |
155 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info, | 147 | setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
156 | sigset_t * set, struct pt_regs *regs) | ||
157 | { | 148 | { |
158 | struct rt_sigframe *frame; | 149 | struct rt_sigframe *frame; |
159 | int err = 0; | 150 | int err = 0; |
160 | 151 | ||
161 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 152 | frame = get_sigframe(ksig, sizeof(*frame)); |
162 | 153 | ||
163 | err |= __put_user((current_thread_info()->exec_domain | 154 | err |= __put_user((current_thread_info()->exec_domain |
164 | && current_thread_info()->exec_domain->signal_invmap | 155 | && current_thread_info()->exec_domain->signal_invmap |
165 | && sig < 32 | 156 | && ksig->sig < 32 |
166 | ? current_thread_info()->exec_domain-> | 157 | ? current_thread_info()->exec_domain-> |
167 | signal_invmap[sig] : sig), &frame->sig); | 158 | signal_invmap[ksig->sig] : ksig->sig), &frame->sig); |
168 | 159 | ||
169 | err |= __put_user(&frame->info, &frame->pinfo); | 160 | err |= __put_user(&frame->info, &frame->pinfo); |
170 | err |= __put_user(&frame->uc, &frame->puc); | 161 | err |= __put_user(&frame->uc, &frame->puc); |
171 | err |= copy_siginfo_to_user(&frame->info, info); | 162 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
172 | 163 | ||
173 | /* Create the ucontext. */ | 164 | /* Create the ucontext. */ |
174 | err |= __put_user(0, &frame->uc.uc_flags); | 165 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -183,7 +174,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info, | |||
183 | /* Set up registers for signal handler */ | 174 | /* Set up registers for signal handler */ |
184 | if (current->personality & FDPIC_FUNCPTRS) { | 175 | if (current->personality & FDPIC_FUNCPTRS) { |
185 | struct fdpic_func_descriptor __user *funcptr = | 176 | struct fdpic_func_descriptor __user *funcptr = |
186 | (struct fdpic_func_descriptor *) ka->sa.sa_handler; | 177 | (struct fdpic_func_descriptor *) ksig->ka.sa.sa_handler; |
187 | u32 pc, p3; | 178 | u32 pc, p3; |
188 | err |= __get_user(pc, &funcptr->text); | 179 | err |= __get_user(pc, &funcptr->text); |
189 | err |= __get_user(p3, &funcptr->GOT); | 180 | err |= __get_user(p3, &funcptr->GOT); |
@@ -192,7 +183,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info, | |||
192 | regs->pc = pc; | 183 | regs->pc = pc; |
193 | regs->p3 = p3; | 184 | regs->p3 = p3; |
194 | } else | 185 | } else |
195 | regs->pc = (unsigned long)ka->sa.sa_handler; | 186 | regs->pc = (unsigned long)ksig->ka.sa.sa_handler; |
196 | wrusp((unsigned long)frame); | 187 | wrusp((unsigned long)frame); |
197 | regs->rets = SIGRETURN_STUB; | 188 | regs->rets = SIGRETURN_STUB; |
198 | 189 | ||
@@ -237,20 +228,19 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) | |||
237 | * OK, we're invoking a handler | 228 | * OK, we're invoking a handler |
238 | */ | 229 | */ |
239 | static void | 230 | static void |
240 | handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | 231 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
241 | struct pt_regs *regs) | ||
242 | { | 232 | { |
233 | int ret; | ||
234 | |||
243 | /* are we from a system call? to see pt_regs->orig_p0 */ | 235 | /* are we from a system call? to see pt_regs->orig_p0 */ |
244 | if (regs->orig_p0 >= 0) | 236 | if (regs->orig_p0 >= 0) |
245 | /* If so, check system call restarting.. */ | 237 | /* If so, check system call restarting.. */ |
246 | handle_restart(regs, ka, 1); | 238 | handle_restart(regs, &ksig->ka, 1); |
247 | 239 | ||
248 | /* set up the stack frame */ | 240 | /* set up the stack frame */ |
249 | if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) | 241 | ret = setup_rt_frame(ksig, sigmask_to_save(), regs); |
250 | force_sigsegv(sig, current); | 242 | |
251 | else | 243 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
252 | signal_delivered(sig, info, ka, regs, | ||
253 | test_thread_flag(TIF_SINGLESTEP)); | ||
254 | } | 244 | } |
255 | 245 | ||
256 | /* | 246 | /* |
@@ -264,16 +254,13 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
264 | */ | 254 | */ |
265 | asmlinkage void do_signal(struct pt_regs *regs) | 255 | asmlinkage void do_signal(struct pt_regs *regs) |
266 | { | 256 | { |
267 | siginfo_t info; | 257 | struct ksignal ksig; |
268 | int signr; | ||
269 | struct k_sigaction ka; | ||
270 | 258 | ||
271 | current->thread.esp0 = (unsigned long)regs; | 259 | current->thread.esp0 = (unsigned long)regs; |
272 | 260 | ||
273 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 261 | if (get_signal(&ksig)) { |
274 | if (signr > 0) { | ||
275 | /* Whee! Actually deliver the signal. */ | 262 | /* Whee! Actually deliver the signal. */ |
276 | handle_signal(signr, &info, &ka, regs); | 263 | handle_signal(&ksig, regs); |
277 | return; | 264 | return; |
278 | } | 265 | } |
279 | 266 | ||
diff --git a/arch/c6x/kernel/signal.c b/arch/c6x/kernel/signal.c index 3998b24e26f2..fe68226f6c4d 100644 --- a/arch/c6x/kernel/signal.c +++ b/arch/c6x/kernel/signal.c | |||
@@ -127,17 +127,11 @@ static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
127 | return err; | 127 | return err; |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline void __user *get_sigframe(struct k_sigaction *ka, | 130 | static inline void __user *get_sigframe(struct ksignal *ksig, |
131 | struct pt_regs *regs, | 131 | struct pt_regs *regs, |
132 | unsigned long framesize) | 132 | unsigned long framesize) |
133 | { | 133 | { |
134 | unsigned long sp = regs->sp; | 134 | unsigned long sp = sigsp(regs->sp, ksig); |
135 | |||
136 | /* | ||
137 | * This is the X/Open sanctioned signal stack switching. | ||
138 | */ | ||
139 | if ((ka->sa.sa_flags & SA_ONSTACK) && sas_ss_flags(sp) == 0) | ||
140 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
141 | 135 | ||
142 | /* | 136 | /* |
143 | * No matter what happens, 'sp' must be dword | 137 | * No matter what happens, 'sp' must be dword |
@@ -146,21 +140,21 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, | |||
146 | return (void __user *)((sp - framesize) & ~7); | 140 | return (void __user *)((sp - framesize) & ~7); |
147 | } | 141 | } |
148 | 142 | ||
149 | static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | 143 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
150 | sigset_t *set, struct pt_regs *regs) | 144 | struct pt_regs *regs) |
151 | { | 145 | { |
152 | struct rt_sigframe __user *frame; | 146 | struct rt_sigframe __user *frame; |
153 | unsigned long __user *retcode; | 147 | unsigned long __user *retcode; |
154 | int err = 0; | 148 | int err = 0; |
155 | 149 | ||
156 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 150 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
157 | 151 | ||
158 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 152 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
159 | goto segv_and_exit; | 153 | return -EFAULT; |
160 | 154 | ||
161 | err |= __put_user(&frame->info, &frame->pinfo); | 155 | err |= __put_user(&frame->info, &frame->pinfo); |
162 | err |= __put_user(&frame->uc, &frame->puc); | 156 | err |= __put_user(&frame->uc, &frame->puc); |
163 | err |= copy_siginfo_to_user(&frame->info, info); | 157 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
164 | 158 | ||
165 | /* Clear all the bits of the ucontext we don't use. */ | 159 | /* Clear all the bits of the ucontext we don't use. */ |
166 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); | 160 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); |
@@ -188,7 +182,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
188 | #undef COPY | 182 | #undef COPY |
189 | 183 | ||
190 | if (err) | 184 | if (err) |
191 | goto segv_and_exit; | 185 | return -EFAULT; |
192 | 186 | ||
193 | flush_icache_range((unsigned long) &frame->retcode, | 187 | flush_icache_range((unsigned long) &frame->retcode, |
194 | (unsigned long) &frame->retcode + RETCODE_SIZE); | 188 | (unsigned long) &frame->retcode + RETCODE_SIZE); |
@@ -198,10 +192,10 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
198 | /* Change user context to branch to signal handler */ | 192 | /* Change user context to branch to signal handler */ |
199 | regs->sp = (unsigned long) frame - 8; | 193 | regs->sp = (unsigned long) frame - 8; |
200 | regs->b3 = (unsigned long) retcode; | 194 | regs->b3 = (unsigned long) retcode; |
201 | regs->pc = (unsigned long) ka->sa.sa_handler; | 195 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
202 | 196 | ||
203 | /* Give the signal number to the handler */ | 197 | /* Give the signal number to the handler */ |
204 | regs->a4 = signr; | 198 | regs->a4 = ksig->sig; |
205 | 199 | ||
206 | /* | 200 | /* |
207 | * For realtime signals we must also set the second and third | 201 | * For realtime signals we must also set the second and third |
@@ -212,10 +206,6 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
212 | regs->a6 = (unsigned long)&frame->uc; | 206 | regs->a6 = (unsigned long)&frame->uc; |
213 | 207 | ||
214 | return 0; | 208 | return 0; |
215 | |||
216 | segv_and_exit: | ||
217 | force_sigsegv(signr, current); | ||
218 | return -EFAULT; | ||
219 | } | 209 | } |
220 | 210 | ||
221 | static inline void | 211 | static inline void |
@@ -245,10 +235,11 @@ do_restart: | |||
245 | /* | 235 | /* |
246 | * handle the actual delivery of a signal to userspace | 236 | * handle the actual delivery of a signal to userspace |
247 | */ | 237 | */ |
248 | static void handle_signal(int sig, | 238 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs, |
249 | siginfo_t *info, struct k_sigaction *ka, | 239 | int syscall) |
250 | struct pt_regs *regs, int syscall) | ||
251 | { | 240 | { |
241 | int ret; | ||
242 | |||
252 | /* Are we from a system call? */ | 243 | /* Are we from a system call? */ |
253 | if (syscall) { | 244 | if (syscall) { |
254 | /* If so, check system call restarting.. */ | 245 | /* If so, check system call restarting.. */ |
@@ -259,7 +250,7 @@ static void handle_signal(int sig, | |||
259 | break; | 250 | break; |
260 | 251 | ||
261 | case -ERESTARTSYS: | 252 | case -ERESTARTSYS: |
262 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 253 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
263 | regs->a4 = -EINTR; | 254 | regs->a4 = -EINTR; |
264 | break; | 255 | break; |
265 | } | 256 | } |
@@ -272,9 +263,8 @@ static void handle_signal(int sig, | |||
272 | } | 263 | } |
273 | 264 | ||
274 | /* Set up the stack frame */ | 265 | /* Set up the stack frame */ |
275 | if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) | 266 | ret = setup_rt_frame(ksig, sigmask_to_save(), regs); |
276 | return; | 267 | signal_setup_done(ret, ksig, 0); |
277 | signal_delivered(sig, info, ka, regs, 0); | ||
278 | } | 268 | } |
279 | 269 | ||
280 | /* | 270 | /* |
@@ -282,18 +272,15 @@ static void handle_signal(int sig, | |||
282 | */ | 272 | */ |
283 | static void do_signal(struct pt_regs *regs, int syscall) | 273 | static void do_signal(struct pt_regs *regs, int syscall) |
284 | { | 274 | { |
285 | struct k_sigaction ka; | 275 | struct ksignal ksig; |
286 | siginfo_t info; | ||
287 | int signr; | ||
288 | 276 | ||
289 | /* we want the common case to go fast, which is why we may in certain | 277 | /* we want the common case to go fast, which is why we may in certain |
290 | * cases get here from kernel mode */ | 278 | * cases get here from kernel mode */ |
291 | if (!user_mode(regs)) | 279 | if (!user_mode(regs)) |
292 | return; | 280 | return; |
293 | 281 | ||
294 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 282 | if (get_signal(&ksig)) { |
295 | if (signr > 0) { | 283 | handle_signal(&ksig, regs, syscall); |
296 | handle_signal(signr, &info, &ka, regs, syscall); | ||
297 | return; | 284 | return; |
298 | } | 285 | } |
299 | 286 | ||
diff --git a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c index 61ce6273a895..9b32d338838b 100644 --- a/arch/cris/arch-v10/kernel/signal.c +++ b/arch/cris/arch-v10/kernel/signal.c | |||
@@ -203,15 +203,9 @@ static int setup_sigcontext(struct sigcontext __user *sc, | |||
203 | * - usually on the stack. */ | 203 | * - usually on the stack. */ |
204 | 204 | ||
205 | static inline void __user * | 205 | static inline void __user * |
206 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | 206 | get_sigframe(struct ksignal *ksig, size_t frame_size) |
207 | { | 207 | { |
208 | unsigned long sp = rdusp(); | 208 | unsigned long sp = sigsp(rdusp(), ksig); |
209 | |||
210 | /* This is the X/Open sanctioned signal stack switching. */ | ||
211 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
212 | if (! on_sig_stack(sp)) | ||
213 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
214 | } | ||
215 | 209 | ||
216 | /* make sure the frame is dword-aligned */ | 210 | /* make sure the frame is dword-aligned */ |
217 | 211 | ||
@@ -228,33 +222,33 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | |||
228 | * user-mode trampoline. | 222 | * user-mode trampoline. |
229 | */ | 223 | */ |
230 | 224 | ||
231 | static int setup_frame(int sig, struct k_sigaction *ka, | 225 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
232 | sigset_t *set, struct pt_regs *regs) | 226 | struct pt_regs *regs) |
233 | { | 227 | { |
234 | struct sigframe __user *frame; | 228 | struct sigframe __user *frame; |
235 | unsigned long return_ip; | 229 | unsigned long return_ip; |
236 | int err = 0; | 230 | int err = 0; |
237 | 231 | ||
238 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 232 | frame = get_sigframe(ksig, sizeof(*frame)); |
239 | 233 | ||
240 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 234 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
241 | goto give_sigsegv; | 235 | return -EFAULT; |
242 | 236 | ||
243 | err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); | 237 | err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); |
244 | if (err) | 238 | if (err) |
245 | goto give_sigsegv; | 239 | return -EFAULT; |
246 | 240 | ||
247 | if (_NSIG_WORDS > 1) { | 241 | if (_NSIG_WORDS > 1) { |
248 | err |= __copy_to_user(frame->extramask, &set->sig[1], | 242 | err |= __copy_to_user(frame->extramask, &set->sig[1], |
249 | sizeof(frame->extramask)); | 243 | sizeof(frame->extramask)); |
250 | } | 244 | } |
251 | if (err) | 245 | if (err) |
252 | goto give_sigsegv; | 246 | return -EFAULT; |
253 | 247 | ||
254 | /* Set up to return from userspace. If provided, use a stub | 248 | /* Set up to return from userspace. If provided, use a stub |
255 | already in userspace. */ | 249 | already in userspace. */ |
256 | if (ka->sa.sa_flags & SA_RESTORER) { | 250 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
257 | return_ip = (unsigned long)ka->sa.sa_restorer; | 251 | return_ip = (unsigned long)ksig->ka.sa.sa_restorer; |
258 | } else { | 252 | } else { |
259 | /* trampoline - the desired return ip is the retcode itself */ | 253 | /* trampoline - the desired return ip is the retcode itself */ |
260 | return_ip = (unsigned long)&frame->retcode; | 254 | return_ip = (unsigned long)&frame->retcode; |
@@ -265,42 +259,38 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
265 | } | 259 | } |
266 | 260 | ||
267 | if (err) | 261 | if (err) |
268 | goto give_sigsegv; | 262 | return -EFAULT; |
269 | 263 | ||
270 | /* Set up registers for signal handler */ | 264 | /* Set up registers for signal handler */ |
271 | 265 | ||
272 | regs->irp = (unsigned long) ka->sa.sa_handler; /* what we enter NOW */ | 266 | regs->irp = (unsigned long) ksig->ka.sa.sa_handler; /* what we enter NOW */ |
273 | regs->srp = return_ip; /* what we enter LATER */ | 267 | regs->srp = return_ip; /* what we enter LATER */ |
274 | regs->r10 = sig; /* first argument is signo */ | 268 | regs->r10 = ksig->sig; /* first argument is signo */ |
275 | 269 | ||
276 | /* actually move the usp to reflect the stacked frame */ | 270 | /* actually move the usp to reflect the stacked frame */ |
277 | 271 | ||
278 | wrusp((unsigned long)frame); | 272 | wrusp((unsigned long)frame); |
279 | 273 | ||
280 | return 0; | 274 | return 0; |
281 | |||
282 | give_sigsegv: | ||
283 | force_sigsegv(sig, current); | ||
284 | return -EFAULT; | ||
285 | } | 275 | } |
286 | 276 | ||
287 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 277 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
288 | sigset_t *set, struct pt_regs *regs) | 278 | struct pt_regs *regs) |
289 | { | 279 | { |
290 | struct rt_sigframe __user *frame; | 280 | struct rt_sigframe __user *frame; |
291 | unsigned long return_ip; | 281 | unsigned long return_ip; |
292 | int err = 0; | 282 | int err = 0; |
293 | 283 | ||
294 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 284 | frame = get_sigframe(ksig, sizeof(*frame)); |
295 | 285 | ||
296 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 286 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
297 | goto give_sigsegv; | 287 | return -EFAULT; |
298 | 288 | ||
299 | err |= __put_user(&frame->info, &frame->pinfo); | 289 | err |= __put_user(&frame->info, &frame->pinfo); |
300 | err |= __put_user(&frame->uc, &frame->puc); | 290 | err |= __put_user(&frame->uc, &frame->puc); |
301 | err |= copy_siginfo_to_user(&frame->info, info); | 291 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
302 | if (err) | 292 | if (err) |
303 | goto give_sigsegv; | 293 | return -EFAULT; |
304 | 294 | ||
305 | /* Clear all the bits of the ucontext we don't use. */ | 295 | /* Clear all the bits of the ucontext we don't use. */ |
306 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); | 296 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); |
@@ -312,12 +302,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
312 | err |= __save_altstack(&frame->uc.uc_stack, rdusp()); | 302 | err |= __save_altstack(&frame->uc.uc_stack, rdusp()); |
313 | 303 | ||
314 | if (err) | 304 | if (err) |
315 | goto give_sigsegv; | 305 | return -EFAULT; |
316 | 306 | ||
317 | /* Set up to return from userspace. If provided, use a stub | 307 | /* Set up to return from userspace. If provided, use a stub |
318 | already in userspace. */ | 308 | already in userspace. */ |
319 | if (ka->sa.sa_flags & SA_RESTORER) { | 309 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
320 | return_ip = (unsigned long)ka->sa.sa_restorer; | 310 | return_ip = (unsigned long)ksig->ka.sa.sa_restorer; |
321 | } else { | 311 | } else { |
322 | /* trampoline - the desired return ip is the retcode itself */ | 312 | /* trampoline - the desired return ip is the retcode itself */ |
323 | return_ip = (unsigned long)&frame->retcode; | 313 | return_ip = (unsigned long)&frame->retcode; |
@@ -329,18 +319,18 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
329 | } | 319 | } |
330 | 320 | ||
331 | if (err) | 321 | if (err) |
332 | goto give_sigsegv; | 322 | return -EFAULT; |
333 | 323 | ||
334 | /* TODO what is the current->exec_domain stuff and invmap ? */ | 324 | /* TODO what is the current->exec_domain stuff and invmap ? */ |
335 | 325 | ||
336 | /* Set up registers for signal handler */ | 326 | /* Set up registers for signal handler */ |
337 | 327 | ||
338 | /* What we enter NOW */ | 328 | /* What we enter NOW */ |
339 | regs->irp = (unsigned long) ka->sa.sa_handler; | 329 | regs->irp = (unsigned long) ksig->ka.sa.sa_handler; |
340 | /* What we enter LATER */ | 330 | /* What we enter LATER */ |
341 | regs->srp = return_ip; | 331 | regs->srp = return_ip; |
342 | /* First argument is signo */ | 332 | /* First argument is signo */ |
343 | regs->r10 = sig; | 333 | regs->r10 = ksig->sig; |
344 | /* Second argument is (siginfo_t *) */ | 334 | /* Second argument is (siginfo_t *) */ |
345 | regs->r11 = (unsigned long)&frame->info; | 335 | regs->r11 = (unsigned long)&frame->info; |
346 | /* Third argument is unused */ | 336 | /* Third argument is unused */ |
@@ -350,19 +340,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
350 | wrusp((unsigned long)frame); | 340 | wrusp((unsigned long)frame); |
351 | 341 | ||
352 | return 0; | 342 | return 0; |
353 | |||
354 | give_sigsegv: | ||
355 | force_sigsegv(sig, current); | ||
356 | return -EFAULT; | ||
357 | } | 343 | } |
358 | 344 | ||
359 | /* | 345 | /* |
360 | * OK, we're invoking a handler | 346 | * OK, we're invoking a handler |
361 | */ | 347 | */ |
362 | 348 | ||
363 | static inline void handle_signal(int canrestart, unsigned long sig, | 349 | static inline void handle_signal(int canrestart, struct ksignal *ksig, |
364 | siginfo_t *info, struct k_sigaction *ka, | 350 | struct pt_regs *regs) |
365 | struct pt_regs *regs) | ||
366 | { | 351 | { |
367 | sigset_t *oldset = sigmask_to_save(); | 352 | sigset_t *oldset = sigmask_to_save(); |
368 | int ret; | 353 | int ret; |
@@ -383,7 +368,7 @@ static inline void handle_signal(int canrestart, unsigned long sig, | |||
383 | /* ERESTARTSYS means to restart the syscall if | 368 | /* ERESTARTSYS means to restart the syscall if |
384 | * there is no handler or the handler was | 369 | * there is no handler or the handler was |
385 | * registered with SA_RESTART */ | 370 | * registered with SA_RESTART */ |
386 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 371 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
387 | regs->r10 = -EINTR; | 372 | regs->r10 = -EINTR; |
388 | break; | 373 | break; |
389 | } | 374 | } |
@@ -396,13 +381,12 @@ static inline void handle_signal(int canrestart, unsigned long sig, | |||
396 | } | 381 | } |
397 | 382 | ||
398 | /* Set up the stack frame */ | 383 | /* Set up the stack frame */ |
399 | if (ka->sa.sa_flags & SA_SIGINFO) | 384 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
400 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 385 | ret = setup_rt_frame(ksig, oldset, regs); |
401 | else | 386 | else |
402 | ret = setup_frame(sig, ka, oldset, regs); | 387 | ret = setup_frame(ksig, oldset, regs); |
403 | 388 | ||
404 | if (ret == 0) | 389 | signal_setup_done(ret, ksig, 0); |
405 | signal_delivered(sig, info, ka, regs, 0); | ||
406 | } | 390 | } |
407 | 391 | ||
408 | /* | 392 | /* |
@@ -419,9 +403,7 @@ static inline void handle_signal(int canrestart, unsigned long sig, | |||
419 | 403 | ||
420 | void do_signal(int canrestart, struct pt_regs *regs) | 404 | void do_signal(int canrestart, struct pt_regs *regs) |
421 | { | 405 | { |
422 | siginfo_t info; | 406 | struct ksignal ksig; |
423 | int signr; | ||
424 | struct k_sigaction ka; | ||
425 | 407 | ||
426 | /* | 408 | /* |
427 | * We want the common case to go fast, which | 409 | * We want the common case to go fast, which |
@@ -432,10 +414,9 @@ void do_signal(int canrestart, struct pt_regs *regs) | |||
432 | if (!user_mode(regs)) | 414 | if (!user_mode(regs)) |
433 | return; | 415 | return; |
434 | 416 | ||
435 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 417 | if (get_signal(&ksig)) { |
436 | if (signr > 0) { | ||
437 | /* Whee! Actually deliver the signal. */ | 418 | /* Whee! Actually deliver the signal. */ |
438 | handle_signal(canrestart, signr, &info, &ka, regs); | 419 | handle_signal(canrestart, &ksig, regs); |
439 | return; | 420 | return; |
440 | } | 421 | } |
441 | 422 | ||
diff --git a/arch/cris/arch-v32/kernel/signal.c b/arch/cris/arch-v32/kernel/signal.c index 01d1375c9004..78ce3b1c9bcb 100644 --- a/arch/cris/arch-v32/kernel/signal.c +++ b/arch/cris/arch-v32/kernel/signal.c | |||
@@ -189,17 +189,9 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
189 | 189 | ||
190 | /* Figure out where to put the new signal frame - usually on the stack. */ | 190 | /* Figure out where to put the new signal frame - usually on the stack. */ |
191 | static inline void __user * | 191 | static inline void __user * |
192 | get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) | 192 | get_sigframe(struct ksignal *ksig, size_t frame_size) |
193 | { | 193 | { |
194 | unsigned long sp; | 194 | unsigned long sp = sigsp(rdusp(), ksig); |
195 | |||
196 | sp = rdusp(); | ||
197 | |||
198 | /* This is the X/Open sanctioned signal stack switching. */ | ||
199 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
200 | if (!on_sig_stack(sp)) | ||
201 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
202 | } | ||
203 | 195 | ||
204 | /* Make sure the frame is dword-aligned. */ | 196 | /* Make sure the frame is dword-aligned. */ |
205 | sp &= ~3; | 197 | sp &= ~3; |
@@ -215,23 +207,22 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size) | |||
215 | * trampoline. | 207 | * trampoline. |
216 | */ | 208 | */ |
217 | static int | 209 | static int |
218 | setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | 210 | setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
219 | struct pt_regs * regs) | ||
220 | { | 211 | { |
221 | int err; | 212 | int err; |
222 | unsigned long return_ip; | 213 | unsigned long return_ip; |
223 | struct signal_frame __user *frame; | 214 | struct signal_frame __user *frame; |
224 | 215 | ||
225 | err = 0; | 216 | err = 0; |
226 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 217 | frame = get_sigframe(ksig, sizeof(*frame)); |
227 | 218 | ||
228 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 219 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
229 | goto give_sigsegv; | 220 | return -EFAULT; |
230 | 221 | ||
231 | err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); | 222 | err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); |
232 | 223 | ||
233 | if (err) | 224 | if (err) |
234 | goto give_sigsegv; | 225 | return -EFAULT; |
235 | 226 | ||
236 | if (_NSIG_WORDS > 1) { | 227 | if (_NSIG_WORDS > 1) { |
237 | err |= __copy_to_user(frame->extramask, &set->sig[1], | 228 | err |= __copy_to_user(frame->extramask, &set->sig[1], |
@@ -239,14 +230,14 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
239 | } | 230 | } |
240 | 231 | ||
241 | if (err) | 232 | if (err) |
242 | goto give_sigsegv; | 233 | return -EFAULT; |
243 | 234 | ||
244 | /* | 235 | /* |
245 | * Set up to return from user-space. If provided, use a stub | 236 | * Set up to return from user-space. If provided, use a stub |
246 | * already located in user-space. | 237 | * already located in user-space. |
247 | */ | 238 | */ |
248 | if (ka->sa.sa_flags & SA_RESTORER) { | 239 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
249 | return_ip = (unsigned long)ka->sa.sa_restorer; | 240 | return_ip = (unsigned long)ksig->ka.sa.sa_restorer; |
250 | } else { | 241 | } else { |
251 | /* Trampoline - the desired return ip is in the signal return page. */ | 242 | /* Trampoline - the desired return ip is in the signal return page. */ |
252 | return_ip = cris_signal_return_page; | 243 | return_ip = cris_signal_return_page; |
@@ -264,7 +255,7 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
264 | } | 255 | } |
265 | 256 | ||
266 | if (err) | 257 | if (err) |
267 | goto give_sigsegv; | 258 | return -EFAULT; |
268 | 259 | ||
269 | /* | 260 | /* |
270 | * Set up registers for signal handler. | 261 | * Set up registers for signal handler. |
@@ -273,42 +264,37 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
273 | * Where the code enter later. | 264 | * Where the code enter later. |
274 | * First argument, signo. | 265 | * First argument, signo. |
275 | */ | 266 | */ |
276 | regs->erp = (unsigned long) ka->sa.sa_handler; | 267 | regs->erp = (unsigned long) ksig->ka.sa.sa_handler; |
277 | regs->srp = return_ip; | 268 | regs->srp = return_ip; |
278 | regs->r10 = sig; | 269 | regs->r10 = ksig->sig; |
279 | 270 | ||
280 | /* Actually move the USP to reflect the stacked frame. */ | 271 | /* Actually move the USP to reflect the stacked frame. */ |
281 | wrusp((unsigned long)frame); | 272 | wrusp((unsigned long)frame); |
282 | 273 | ||
283 | return 0; | 274 | return 0; |
284 | |||
285 | give_sigsegv: | ||
286 | force_sigsegv(sig, current); | ||
287 | return -EFAULT; | ||
288 | } | 275 | } |
289 | 276 | ||
290 | static int | 277 | static int |
291 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 278 | setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
292 | sigset_t *set, struct pt_regs * regs) | ||
293 | { | 279 | { |
294 | int err; | 280 | int err; |
295 | unsigned long return_ip; | 281 | unsigned long return_ip; |
296 | struct rt_signal_frame __user *frame; | 282 | struct rt_signal_frame __user *frame; |
297 | 283 | ||
298 | err = 0; | 284 | err = 0; |
299 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 285 | frame = get_sigframe(ksig, sizeof(*frame)); |
300 | 286 | ||
301 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 287 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
302 | goto give_sigsegv; | 288 | return -EFAULT; |
303 | 289 | ||
304 | /* TODO: what is the current->exec_domain stuff and invmap ? */ | 290 | /* TODO: what is the current->exec_domain stuff and invmap ? */ |
305 | 291 | ||
306 | err |= __put_user(&frame->info, &frame->pinfo); | 292 | err |= __put_user(&frame->info, &frame->pinfo); |
307 | err |= __put_user(&frame->uc, &frame->puc); | 293 | err |= __put_user(&frame->uc, &frame->puc); |
308 | err |= copy_siginfo_to_user(&frame->info, info); | 294 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
309 | 295 | ||
310 | if (err) | 296 | if (err) |
311 | goto give_sigsegv; | 297 | return -EFAULT; |
312 | 298 | ||
313 | /* Clear all the bits of the ucontext we don't use. */ | 299 | /* Clear all the bits of the ucontext we don't use. */ |
314 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); | 300 | err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); |
@@ -317,14 +303,14 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
317 | err |= __save_altstack(&frame->uc.uc_stack, rdusp()); | 303 | err |= __save_altstack(&frame->uc.uc_stack, rdusp()); |
318 | 304 | ||
319 | if (err) | 305 | if (err) |
320 | goto give_sigsegv; | 306 | return -EFAULT; |
321 | 307 | ||
322 | /* | 308 | /* |
323 | * Set up to return from user-space. If provided, use a stub | 309 | * Set up to return from user-space. If provided, use a stub |
324 | * already located in user-space. | 310 | * already located in user-space. |
325 | */ | 311 | */ |
326 | if (ka->sa.sa_flags & SA_RESTORER) { | 312 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
327 | return_ip = (unsigned long) ka->sa.sa_restorer; | 313 | return_ip = (unsigned long) ksig->ka.sa.sa_restorer; |
328 | } else { | 314 | } else { |
329 | /* Trampoline - the desired return ip is in the signal return page. */ | 315 | /* Trampoline - the desired return ip is in the signal return page. */ |
330 | return_ip = cris_signal_return_page + 6; | 316 | return_ip = cris_signal_return_page + 6; |
@@ -345,7 +331,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
345 | } | 331 | } |
346 | 332 | ||
347 | if (err) | 333 | if (err) |
348 | goto give_sigsegv; | 334 | return -EFAULT; |
349 | 335 | ||
350 | /* | 336 | /* |
351 | * Set up registers for signal handler. | 337 | * Set up registers for signal handler. |
@@ -356,9 +342,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
356 | * Second argument is (siginfo_t *). | 342 | * Second argument is (siginfo_t *). |
357 | * Third argument is unused. | 343 | * Third argument is unused. |
358 | */ | 344 | */ |
359 | regs->erp = (unsigned long) ka->sa.sa_handler; | 345 | regs->erp = (unsigned long) ksig->ka.sa.sa_handler; |
360 | regs->srp = return_ip; | 346 | regs->srp = return_ip; |
361 | regs->r10 = sig; | 347 | regs->r10 = ksig->sig; |
362 | regs->r11 = (unsigned long) &frame->info; | 348 | regs->r11 = (unsigned long) &frame->info; |
363 | regs->r12 = 0; | 349 | regs->r12 = 0; |
364 | 350 | ||
@@ -366,17 +352,11 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
366 | wrusp((unsigned long)frame); | 352 | wrusp((unsigned long)frame); |
367 | 353 | ||
368 | return 0; | 354 | return 0; |
369 | |||
370 | give_sigsegv: | ||
371 | force_sigsegv(sig, current); | ||
372 | return -EFAULT; | ||
373 | } | 355 | } |
374 | 356 | ||
375 | /* Invoke a signal handler to, well, handle the signal. */ | 357 | /* Invoke a signal handler to, well, handle the signal. */ |
376 | static inline void | 358 | static inline void |
377 | handle_signal(int canrestart, unsigned long sig, | 359 | handle_signal(int canrestart, struct ksignal *ksig, struct pt_regs *regs) |
378 | siginfo_t *info, struct k_sigaction *ka, | ||
379 | struct pt_regs * regs) | ||
380 | { | 360 | { |
381 | sigset_t *oldset = sigmask_to_save(); | 361 | sigset_t *oldset = sigmask_to_save(); |
382 | int ret; | 362 | int ret; |
@@ -404,7 +384,7 @@ handle_signal(int canrestart, unsigned long sig, | |||
404 | * there is no handler, or the handler | 384 | * there is no handler, or the handler |
405 | * was registered with SA_RESTART. | 385 | * was registered with SA_RESTART. |
406 | */ | 386 | */ |
407 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 387 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
408 | regs->r10 = -EINTR; | 388 | regs->r10 = -EINTR; |
409 | break; | 389 | break; |
410 | } | 390 | } |
@@ -423,13 +403,12 @@ handle_signal(int canrestart, unsigned long sig, | |||
423 | } | 403 | } |
424 | 404 | ||
425 | /* Set up the stack frame. */ | 405 | /* Set up the stack frame. */ |
426 | if (ka->sa.sa_flags & SA_SIGINFO) | 406 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
427 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 407 | ret = setup_rt_frame(ksig, oldset, regs); |
428 | else | 408 | else |
429 | ret = setup_frame(sig, ka, oldset, regs); | 409 | ret = setup_frame(ksig, oldset, regs); |
430 | 410 | ||
431 | if (ret == 0) | 411 | signal_setup_done(ret, ksig, 0); |
432 | signal_delivered(sig, info, ka, regs, 0); | ||
433 | } | 412 | } |
434 | 413 | ||
435 | /* | 414 | /* |
@@ -446,9 +425,7 @@ handle_signal(int canrestart, unsigned long sig, | |||
446 | void | 425 | void |
447 | do_signal(int canrestart, struct pt_regs *regs) | 426 | do_signal(int canrestart, struct pt_regs *regs) |
448 | { | 427 | { |
449 | int signr; | 428 | struct ksignal ksig; |
450 | siginfo_t info; | ||
451 | struct k_sigaction ka; | ||
452 | 429 | ||
453 | /* | 430 | /* |
454 | * The common case should go fast, which is why this point is | 431 | * The common case should go fast, which is why this point is |
@@ -458,11 +435,9 @@ do_signal(int canrestart, struct pt_regs *regs) | |||
458 | if (!user_mode(regs)) | 435 | if (!user_mode(regs)) |
459 | return; | 436 | return; |
460 | 437 | ||
461 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 438 | if (get_signal(&ksig)) { |
462 | |||
463 | if (signr > 0) { | ||
464 | /* Whee! Actually deliver the signal. */ | 439 | /* Whee! Actually deliver the signal. */ |
465 | handle_signal(canrestart, signr, &info, &ka, regs); | 440 | handle_signal(canrestart, &ksig, regs); |
466 | return; | 441 | return; |
467 | } | 442 | } |
468 | 443 | ||
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c index d822700d4f15..dc3d59de0870 100644 --- a/arch/frv/kernel/signal.c +++ b/arch/frv/kernel/signal.c | |||
@@ -158,19 +158,10 @@ static int setup_sigcontext(struct sigcontext __user *sc, unsigned long mask) | |||
158 | /* | 158 | /* |
159 | * Determine which stack to use.. | 159 | * Determine which stack to use.. |
160 | */ | 160 | */ |
161 | static inline void __user *get_sigframe(struct k_sigaction *ka, | 161 | static inline void __user *get_sigframe(struct ksignal *ksig, |
162 | size_t frame_size) | 162 | size_t frame_size) |
163 | { | 163 | { |
164 | unsigned long sp; | 164 | unsigned long sp = sigsp(__frame->sp, ksig); |
165 | |||
166 | /* Default to using normal stack */ | ||
167 | sp = __frame->sp; | ||
168 | |||
169 | /* This is the X/Open sanctioned signal stack switching. */ | ||
170 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
171 | if (! sas_ss_flags(sp)) | ||
172 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
173 | } | ||
174 | 165 | ||
175 | return (void __user *) ((sp - frame_size) & ~7UL); | 166 | return (void __user *) ((sp - frame_size) & ~7UL); |
176 | 167 | ||
@@ -180,17 +171,17 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, | |||
180 | /* | 171 | /* |
181 | * | 172 | * |
182 | */ | 173 | */ |
183 | static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) | 174 | static int setup_frame(struct ksignal *ksig, sigset_t *set) |
184 | { | 175 | { |
185 | struct sigframe __user *frame; | 176 | struct sigframe __user *frame; |
186 | int rsig; | 177 | int rsig, sig = ksig->sig; |
187 | 178 | ||
188 | set_fs(USER_DS); | 179 | set_fs(USER_DS); |
189 | 180 | ||
190 | frame = get_sigframe(ka, sizeof(*frame)); | 181 | frame = get_sigframe(ksig, sizeof(*frame)); |
191 | 182 | ||
192 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 183 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
193 | goto give_sigsegv; | 184 | return -EFAULT; |
194 | 185 | ||
195 | rsig = sig; | 186 | rsig = sig; |
196 | if (sig < 32 && | 187 | if (sig < 32 && |
@@ -199,22 +190,22 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) | |||
199 | rsig = __current_thread_info->exec_domain->signal_invmap[sig]; | 190 | rsig = __current_thread_info->exec_domain->signal_invmap[sig]; |
200 | 191 | ||
201 | if (__put_user(rsig, &frame->sig) < 0) | 192 | if (__put_user(rsig, &frame->sig) < 0) |
202 | goto give_sigsegv; | 193 | return -EFAULT; |
203 | 194 | ||
204 | if (setup_sigcontext(&frame->sc, set->sig[0])) | 195 | if (setup_sigcontext(&frame->sc, set->sig[0])) |
205 | goto give_sigsegv; | 196 | return -EFAULT; |
206 | 197 | ||
207 | if (_NSIG_WORDS > 1) { | 198 | if (_NSIG_WORDS > 1) { |
208 | if (__copy_to_user(frame->extramask, &set->sig[1], | 199 | if (__copy_to_user(frame->extramask, &set->sig[1], |
209 | sizeof(frame->extramask))) | 200 | sizeof(frame->extramask))) |
210 | goto give_sigsegv; | 201 | return -EFAULT; |
211 | } | 202 | } |
212 | 203 | ||
213 | /* Set up to return from userspace. If provided, use a stub | 204 | /* Set up to return from userspace. If provided, use a stub |
214 | * already in userspace. */ | 205 | * already in userspace. */ |
215 | if (ka->sa.sa_flags & SA_RESTORER) { | 206 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
216 | if (__put_user(ka->sa.sa_restorer, &frame->pretcode) < 0) | 207 | if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode) < 0) |
217 | goto give_sigsegv; | 208 | return -EFAULT; |
218 | } | 209 | } |
219 | else { | 210 | else { |
220 | /* Set up the following code on the stack: | 211 | /* Set up the following code on the stack: |
@@ -224,7 +215,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) | |||
224 | if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || | 215 | if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || |
225 | __put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) || | 216 | __put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) || |
226 | __put_user(0xc0700000, &frame->retcode[1])) | 217 | __put_user(0xc0700000, &frame->retcode[1])) |
227 | goto give_sigsegv; | 218 | return -EFAULT; |
228 | 219 | ||
229 | flush_icache_range((unsigned long) frame->retcode, | 220 | flush_icache_range((unsigned long) frame->retcode, |
230 | (unsigned long) (frame->retcode + 2)); | 221 | (unsigned long) (frame->retcode + 2)); |
@@ -233,14 +224,14 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) | |||
233 | /* Set up registers for the signal handler */ | 224 | /* Set up registers for the signal handler */ |
234 | if (current->personality & FDPIC_FUNCPTRS) { | 225 | if (current->personality & FDPIC_FUNCPTRS) { |
235 | struct fdpic_func_descriptor __user *funcptr = | 226 | struct fdpic_func_descriptor __user *funcptr = |
236 | (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; | 227 | (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler; |
237 | struct fdpic_func_descriptor desc; | 228 | struct fdpic_func_descriptor desc; |
238 | if (copy_from_user(&desc, funcptr, sizeof(desc))) | 229 | if (copy_from_user(&desc, funcptr, sizeof(desc))) |
239 | goto give_sigsegv; | 230 | return -EFAULT; |
240 | __frame->pc = desc.text; | 231 | __frame->pc = desc.text; |
241 | __frame->gr15 = desc.GOT; | 232 | __frame->gr15 = desc.GOT; |
242 | } else { | 233 | } else { |
243 | __frame->pc = (unsigned long) ka->sa.sa_handler; | 234 | __frame->pc = (unsigned long) ksig->ka.sa.sa_handler; |
244 | __frame->gr15 = 0; | 235 | __frame->gr15 = 0; |
245 | } | 236 | } |
246 | 237 | ||
@@ -255,29 +246,23 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) | |||
255 | #endif | 246 | #endif |
256 | 247 | ||
257 | return 0; | 248 | return 0; |
258 | |||
259 | give_sigsegv: | ||
260 | force_sigsegv(sig, current); | ||
261 | return -EFAULT; | ||
262 | |||
263 | } /* end setup_frame() */ | 249 | } /* end setup_frame() */ |
264 | 250 | ||
265 | /*****************************************************************************/ | 251 | /*****************************************************************************/ |
266 | /* | 252 | /* |
267 | * | 253 | * |
268 | */ | 254 | */ |
269 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 255 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set) |
270 | sigset_t *set) | ||
271 | { | 256 | { |
272 | struct rt_sigframe __user *frame; | 257 | struct rt_sigframe __user *frame; |
273 | int rsig; | 258 | int rsig, sig = ksig->sig; |
274 | 259 | ||
275 | set_fs(USER_DS); | 260 | set_fs(USER_DS); |
276 | 261 | ||
277 | frame = get_sigframe(ka, sizeof(*frame)); | 262 | frame = get_sigframe(ksig, sizeof(*frame)); |
278 | 263 | ||
279 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 264 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
280 | goto give_sigsegv; | 265 | return -EFAULT; |
281 | 266 | ||
282 | rsig = sig; | 267 | rsig = sig; |
283 | if (sig < 32 && | 268 | if (sig < 32 && |
@@ -288,28 +273,28 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
288 | if (__put_user(rsig, &frame->sig) || | 273 | if (__put_user(rsig, &frame->sig) || |
289 | __put_user(&frame->info, &frame->pinfo) || | 274 | __put_user(&frame->info, &frame->pinfo) || |
290 | __put_user(&frame->uc, &frame->puc)) | 275 | __put_user(&frame->uc, &frame->puc)) |
291 | goto give_sigsegv; | 276 | return -EFAULT; |
292 | 277 | ||
293 | if (copy_siginfo_to_user(&frame->info, info)) | 278 | if (copy_siginfo_to_user(&frame->info, &ksig->info)) |
294 | goto give_sigsegv; | 279 | return -EFAULT; |
295 | 280 | ||
296 | /* Create the ucontext. */ | 281 | /* Create the ucontext. */ |
297 | if (__put_user(0, &frame->uc.uc_flags) || | 282 | if (__put_user(0, &frame->uc.uc_flags) || |
298 | __put_user(NULL, &frame->uc.uc_link) || | 283 | __put_user(NULL, &frame->uc.uc_link) || |
299 | __save_altstack(&frame->uc.uc_stack, __frame->sp)) | 284 | __save_altstack(&frame->uc.uc_stack, __frame->sp)) |
300 | goto give_sigsegv; | 285 | return -EFAULT; |
301 | 286 | ||
302 | if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0])) | 287 | if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0])) |
303 | goto give_sigsegv; | 288 | return -EFAULT; |
304 | 289 | ||
305 | if (__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) | 290 | if (__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) |
306 | goto give_sigsegv; | 291 | return -EFAULT; |
307 | 292 | ||
308 | /* Set up to return from userspace. If provided, use a stub | 293 | /* Set up to return from userspace. If provided, use a stub |
309 | * already in userspace. */ | 294 | * already in userspace. */ |
310 | if (ka->sa.sa_flags & SA_RESTORER) { | 295 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
311 | if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) | 296 | if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode)) |
312 | goto give_sigsegv; | 297 | return -EFAULT; |
313 | } | 298 | } |
314 | else { | 299 | else { |
315 | /* Set up the following code on the stack: | 300 | /* Set up the following code on the stack: |
@@ -319,7 +304,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
319 | if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || | 304 | if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || |
320 | __put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) || | 305 | __put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) || |
321 | __put_user(0xc0700000, &frame->retcode[1])) | 306 | __put_user(0xc0700000, &frame->retcode[1])) |
322 | goto give_sigsegv; | 307 | return -EFAULT; |
323 | 308 | ||
324 | flush_icache_range((unsigned long) frame->retcode, | 309 | flush_icache_range((unsigned long) frame->retcode, |
325 | (unsigned long) (frame->retcode + 2)); | 310 | (unsigned long) (frame->retcode + 2)); |
@@ -328,14 +313,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
328 | /* Set up registers for signal handler */ | 313 | /* Set up registers for signal handler */ |
329 | if (current->personality & FDPIC_FUNCPTRS) { | 314 | if (current->personality & FDPIC_FUNCPTRS) { |
330 | struct fdpic_func_descriptor __user *funcptr = | 315 | struct fdpic_func_descriptor __user *funcptr = |
331 | (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; | 316 | (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler; |
332 | struct fdpic_func_descriptor desc; | 317 | struct fdpic_func_descriptor desc; |
333 | if (copy_from_user(&desc, funcptr, sizeof(desc))) | 318 | if (copy_from_user(&desc, funcptr, sizeof(desc))) |
334 | goto give_sigsegv; | 319 | return -EFAULT; |
335 | __frame->pc = desc.text; | 320 | __frame->pc = desc.text; |
336 | __frame->gr15 = desc.GOT; | 321 | __frame->gr15 = desc.GOT; |
337 | } else { | 322 | } else { |
338 | __frame->pc = (unsigned long) ka->sa.sa_handler; | 323 | __frame->pc = (unsigned long) ksig->ka.sa.sa_handler; |
339 | __frame->gr15 = 0; | 324 | __frame->gr15 = 0; |
340 | } | 325 | } |
341 | 326 | ||
@@ -349,21 +334,15 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
349 | sig, current->comm, current->pid, frame, __frame->pc, | 334 | sig, current->comm, current->pid, frame, __frame->pc, |
350 | frame->pretcode); | 335 | frame->pretcode); |
351 | #endif | 336 | #endif |
352 | |||
353 | return 0; | 337 | return 0; |
354 | 338 | ||
355 | give_sigsegv: | ||
356 | force_sigsegv(sig, current); | ||
357 | return -EFAULT; | ||
358 | |||
359 | } /* end setup_rt_frame() */ | 339 | } /* end setup_rt_frame() */ |
360 | 340 | ||
361 | /*****************************************************************************/ | 341 | /*****************************************************************************/ |
362 | /* | 342 | /* |
363 | * OK, we're invoking a handler | 343 | * OK, we're invoking a handler |
364 | */ | 344 | */ |
365 | static void handle_signal(unsigned long sig, siginfo_t *info, | 345 | static void handle_signal(struct ksignal *ksig) |
366 | struct k_sigaction *ka) | ||
367 | { | 346 | { |
368 | sigset_t *oldset = sigmask_to_save(); | 347 | sigset_t *oldset = sigmask_to_save(); |
369 | int ret; | 348 | int ret; |
@@ -378,7 +357,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
378 | break; | 357 | break; |
379 | 358 | ||
380 | case -ERESTARTSYS: | 359 | case -ERESTARTSYS: |
381 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 360 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
382 | __frame->gr8 = -EINTR; | 361 | __frame->gr8 = -EINTR; |
383 | break; | 362 | break; |
384 | } | 363 | } |
@@ -392,16 +371,12 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
392 | } | 371 | } |
393 | 372 | ||
394 | /* Set up the stack frame */ | 373 | /* Set up the stack frame */ |
395 | if (ka->sa.sa_flags & SA_SIGINFO) | 374 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
396 | ret = setup_rt_frame(sig, ka, info, oldset); | 375 | ret = setup_rt_frame(ksig, oldset); |
397 | else | 376 | else |
398 | ret = setup_frame(sig, ka, oldset); | 377 | ret = setup_frame(ksig, oldset); |
399 | |||
400 | if (ret) | ||
401 | return; | ||
402 | 378 | ||
403 | signal_delivered(sig, info, ka, __frame, | 379 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
404 | test_thread_flag(TIF_SINGLESTEP)); | ||
405 | } /* end handle_signal() */ | 380 | } /* end handle_signal() */ |
406 | 381 | ||
407 | /*****************************************************************************/ | 382 | /*****************************************************************************/ |
@@ -412,13 +387,10 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
412 | */ | 387 | */ |
413 | static void do_signal(void) | 388 | static void do_signal(void) |
414 | { | 389 | { |
415 | struct k_sigaction ka; | 390 | struct ksignal ksig; |
416 | siginfo_t info; | ||
417 | int signr; | ||
418 | 391 | ||
419 | signr = get_signal_to_deliver(&info, &ka, __frame, NULL); | 392 | if (get_signal(&ksig)) { |
420 | if (signr > 0) { | 393 | handle_signal(&ksig); |
421 | handle_signal(signr, &info, &ka); | ||
422 | return; | 394 | return; |
423 | } | 395 | } |
424 | 396 | ||
diff --git a/arch/hexagon/kernel/signal.c b/arch/hexagon/kernel/signal.c index d7c73874b515..eadd70e47e7e 100644 --- a/arch/hexagon/kernel/signal.c +++ b/arch/hexagon/kernel/signal.c | |||
@@ -36,18 +36,10 @@ struct rt_sigframe { | |||
36 | struct ucontext uc; | 36 | struct ucontext uc; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, | 39 | static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, |
40 | size_t frame_size) | 40 | size_t frame_size) |
41 | { | 41 | { |
42 | unsigned long sp = regs->r29; | 42 | unsigned long sp = sigsp(regs->r29, ksig); |
43 | |||
44 | /* check if we would overflow the alt stack */ | ||
45 | if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size))) | ||
46 | return (void __user __force *)-1UL; | ||
47 | |||
48 | /* Switch to signal stack if appropriate */ | ||
49 | if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0)) | ||
50 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
51 | 43 | ||
52 | return (void __user *)((sp - frame_size) & ~(sizeof(long long) - 1)); | 44 | return (void __user *)((sp - frame_size) & ~(sizeof(long long) - 1)); |
53 | } | 45 | } |
@@ -112,20 +104,20 @@ static int restore_sigcontext(struct pt_regs *regs, | |||
112 | /* | 104 | /* |
113 | * Setup signal stack frame with siginfo structure | 105 | * Setup signal stack frame with siginfo structure |
114 | */ | 106 | */ |
115 | static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | 107 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
116 | sigset_t *set, struct pt_regs *regs) | 108 | struct pt_regs *regs) |
117 | { | 109 | { |
118 | int err = 0; | 110 | int err = 0; |
119 | struct rt_sigframe __user *frame; | 111 | struct rt_sigframe __user *frame; |
120 | struct hexagon_vdso *vdso = current->mm->context.vdso; | 112 | struct hexagon_vdso *vdso = current->mm->context.vdso; |
121 | 113 | ||
122 | frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe)); | 114 | frame = get_sigframe(ksig, regs, sizeof(struct rt_sigframe)); |
123 | 115 | ||
124 | if (!access_ok(VERIFY_WRITE, frame, sizeof(struct rt_sigframe))) | 116 | if (!access_ok(VERIFY_WRITE, frame, sizeof(struct rt_sigframe))) |
125 | goto sigsegv; | 117 | return -EFAULT; |
126 | 118 | ||
127 | if (copy_siginfo_to_user(&frame->info, info)) | 119 | if (copy_siginfo_to_user(&frame->info, &ksig->info)) |
128 | goto sigsegv; | 120 | return -EFAULT; |
129 | 121 | ||
130 | /* The on-stack signal trampoline is no longer executed; | 122 | /* The on-stack signal trampoline is no longer executed; |
131 | * however, the libgcc signal frame unwinding code checks for | 123 | * however, the libgcc signal frame unwinding code checks for |
@@ -137,29 +129,26 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
137 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 129 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
138 | err |= __save_altstack(&frame->uc.uc_stack, user_stack_pointer(regs)); | 130 | err |= __save_altstack(&frame->uc.uc_stack, user_stack_pointer(regs)); |
139 | if (err) | 131 | if (err) |
140 | goto sigsegv; | 132 | return -EFAULT; |
141 | 133 | ||
142 | /* Load r0/r1 pair with signumber/siginfo pointer... */ | 134 | /* Load r0/r1 pair with signumber/siginfo pointer... */ |
143 | regs->r0100 = ((unsigned long long)((unsigned long)&frame->info) << 32) | 135 | regs->r0100 = ((unsigned long long)((unsigned long)&frame->info) << 32) |
144 | | (unsigned long long)signr; | 136 | | (unsigned long long)ksig->sig; |
145 | regs->r02 = (unsigned long) &frame->uc; | 137 | regs->r02 = (unsigned long) &frame->uc; |
146 | regs->r31 = (unsigned long) vdso->rt_signal_trampoline; | 138 | regs->r31 = (unsigned long) vdso->rt_signal_trampoline; |
147 | pt_psp(regs) = (unsigned long) frame; | 139 | pt_psp(regs) = (unsigned long) frame; |
148 | pt_set_elr(regs, (unsigned long)ka->sa.sa_handler); | 140 | pt_set_elr(regs, (unsigned long)ksig->ka.sa.sa_handler); |
149 | 141 | ||
150 | return 0; | 142 | return 0; |
151 | |||
152 | sigsegv: | ||
153 | force_sigsegv(signr, current); | ||
154 | return -EFAULT; | ||
155 | } | 143 | } |
156 | 144 | ||
157 | /* | 145 | /* |
158 | * Setup invocation of signal handler | 146 | * Setup invocation of signal handler |
159 | */ | 147 | */ |
160 | static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | 148 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
161 | struct pt_regs *regs) | ||
162 | { | 149 | { |
150 | int ret; | ||
151 | |||
163 | /* | 152 | /* |
164 | * If we're handling a signal that aborted a system call, | 153 | * If we're handling a signal that aborted a system call, |
165 | * set up the error return value before adding the signal | 154 | * set up the error return value before adding the signal |
@@ -173,7 +162,7 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
173 | regs->r00 = -EINTR; | 162 | regs->r00 = -EINTR; |
174 | break; | 163 | break; |
175 | case -ERESTARTSYS: | 164 | case -ERESTARTSYS: |
176 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 165 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
177 | regs->r00 = -EINTR; | 166 | regs->r00 = -EINTR; |
178 | break; | 167 | break; |
179 | } | 168 | } |
@@ -193,11 +182,9 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
193 | * only set up the rt_frame flavor. | 182 | * only set up the rt_frame flavor. |
194 | */ | 183 | */ |
195 | /* If there was an error on setup, no signal was delivered. */ | 184 | /* If there was an error on setup, no signal was delivered. */ |
196 | if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) | 185 | ret = setup_rt_frame(ksig, sigmask_to_save(), regs); |
197 | return; | ||
198 | 186 | ||
199 | signal_delivered(sig, info, ka, regs, | 187 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
200 | test_thread_flag(TIF_SINGLESTEP)); | ||
201 | } | 188 | } |
202 | 189 | ||
203 | /* | 190 | /* |
@@ -205,17 +192,13 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
205 | */ | 192 | */ |
206 | void do_signal(struct pt_regs *regs) | 193 | void do_signal(struct pt_regs *regs) |
207 | { | 194 | { |
208 | struct k_sigaction sigact; | 195 | struct ksignal ksig; |
209 | siginfo_t info; | ||
210 | int signo; | ||
211 | 196 | ||
212 | if (!user_mode(regs)) | 197 | if (!user_mode(regs)) |
213 | return; | 198 | return; |
214 | 199 | ||
215 | signo = get_signal_to_deliver(&info, &sigact, regs, NULL); | 200 | if (get_signal(&ksig)) { |
216 | 201 | handle_signal(&ksig, regs); | |
217 | if (signo > 0) { | ||
218 | handle_signal(signo, &info, &sigact, regs); | ||
219 | return; | 202 | return; |
220 | } | 203 | } |
221 | 204 | ||
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c index 33cab9a8adff..6d92170be457 100644 --- a/arch/ia64/kernel/signal.c +++ b/arch/ia64/kernel/signal.c | |||
@@ -309,12 +309,11 @@ force_sigsegv_info (int sig, void __user *addr) | |||
309 | si.si_uid = from_kuid_munged(current_user_ns(), current_uid()); | 309 | si.si_uid = from_kuid_munged(current_user_ns(), current_uid()); |
310 | si.si_addr = addr; | 310 | si.si_addr = addr; |
311 | force_sig_info(SIGSEGV, &si, current); | 311 | force_sig_info(SIGSEGV, &si, current); |
312 | return 0; | 312 | return 1; |
313 | } | 313 | } |
314 | 314 | ||
315 | static long | 315 | static long |
316 | setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, | 316 | setup_frame(struct ksignal *ksig, sigset_t *set, struct sigscratch *scr) |
317 | struct sigscratch *scr) | ||
318 | { | 317 | { |
319 | extern char __kernel_sigtramp[]; | 318 | extern char __kernel_sigtramp[]; |
320 | unsigned long tramp_addr, new_rbs = 0, new_sp; | 319 | unsigned long tramp_addr, new_rbs = 0, new_sp; |
@@ -323,7 +322,7 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, | |||
323 | 322 | ||
324 | new_sp = scr->pt.r12; | 323 | new_sp = scr->pt.r12; |
325 | tramp_addr = (unsigned long) __kernel_sigtramp; | 324 | tramp_addr = (unsigned long) __kernel_sigtramp; |
326 | if (ka->sa.sa_flags & SA_ONSTACK) { | 325 | if (ksig->ka.sa.sa_flags & SA_ONSTACK) { |
327 | int onstack = sas_ss_flags(new_sp); | 326 | int onstack = sas_ss_flags(new_sp); |
328 | 327 | ||
329 | if (onstack == 0) { | 328 | if (onstack == 0) { |
@@ -347,29 +346,29 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, | |||
347 | */ | 346 | */ |
348 | check_sp = (new_sp - sizeof(*frame)) & -STACK_ALIGN; | 347 | check_sp = (new_sp - sizeof(*frame)) & -STACK_ALIGN; |
349 | if (!likely(on_sig_stack(check_sp))) | 348 | if (!likely(on_sig_stack(check_sp))) |
350 | return force_sigsegv_info(sig, (void __user *) | 349 | return force_sigsegv_info(ksig->sig, (void __user *) |
351 | check_sp); | 350 | check_sp); |
352 | } | 351 | } |
353 | } | 352 | } |
354 | frame = (void __user *) ((new_sp - sizeof(*frame)) & -STACK_ALIGN); | 353 | frame = (void __user *) ((new_sp - sizeof(*frame)) & -STACK_ALIGN); |
355 | 354 | ||
356 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 355 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
357 | return force_sigsegv_info(sig, frame); | 356 | return force_sigsegv_info(ksig->sig, frame); |
358 | 357 | ||
359 | err = __put_user(sig, &frame->arg0); | 358 | err = __put_user(ksig->sig, &frame->arg0); |
360 | err |= __put_user(&frame->info, &frame->arg1); | 359 | err |= __put_user(&frame->info, &frame->arg1); |
361 | err |= __put_user(&frame->sc, &frame->arg2); | 360 | err |= __put_user(&frame->sc, &frame->arg2); |
362 | err |= __put_user(new_rbs, &frame->sc.sc_rbs_base); | 361 | err |= __put_user(new_rbs, &frame->sc.sc_rbs_base); |
363 | err |= __put_user(0, &frame->sc.sc_loadrs); /* initialize to zero */ | 362 | err |= __put_user(0, &frame->sc.sc_loadrs); /* initialize to zero */ |
364 | err |= __put_user(ka->sa.sa_handler, &frame->handler); | 363 | err |= __put_user(ksig->ka.sa.sa_handler, &frame->handler); |
365 | 364 | ||
366 | err |= copy_siginfo_to_user(&frame->info, info); | 365 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
367 | 366 | ||
368 | err |= __save_altstack(&frame->sc.sc_stack, scr->pt.r12); | 367 | err |= __save_altstack(&frame->sc.sc_stack, scr->pt.r12); |
369 | err |= setup_sigcontext(&frame->sc, set, scr); | 368 | err |= setup_sigcontext(&frame->sc, set, scr); |
370 | 369 | ||
371 | if (unlikely(err)) | 370 | if (unlikely(err)) |
372 | return force_sigsegv_info(sig, frame); | 371 | return force_sigsegv_info(ksig->sig, frame); |
373 | 372 | ||
374 | scr->pt.r12 = (unsigned long) frame - 16; /* new stack pointer */ | 373 | scr->pt.r12 = (unsigned long) frame - 16; /* new stack pointer */ |
375 | scr->pt.ar_fpsr = FPSR_DEFAULT; /* reset fpsr for signal handler */ | 374 | scr->pt.ar_fpsr = FPSR_DEFAULT; /* reset fpsr for signal handler */ |
@@ -394,22 +393,20 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, | |||
394 | 393 | ||
395 | #if DEBUG_SIG | 394 | #if DEBUG_SIG |
396 | printk("SIG deliver (%s:%d): sig=%d sp=%lx ip=%lx handler=%p\n", | 395 | printk("SIG deliver (%s:%d): sig=%d sp=%lx ip=%lx handler=%p\n", |
397 | current->comm, current->pid, sig, scr->pt.r12, frame->sc.sc_ip, frame->handler); | 396 | current->comm, current->pid, ksig->sig, scr->pt.r12, frame->sc.sc_ip, frame->handler); |
398 | #endif | 397 | #endif |
399 | return 1; | 398 | return 0; |
400 | } | 399 | } |
401 | 400 | ||
402 | static long | 401 | static long |
403 | handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 402 | handle_signal (struct ksignal *ksig, struct sigscratch *scr) |
404 | struct sigscratch *scr) | ||
405 | { | 403 | { |
406 | if (!setup_frame(sig, ka, info, sigmask_to_save(), scr)) | 404 | int ret = setup_frame(ksig, sigmask_to_save(), scr); |
407 | return 0; | ||
408 | 405 | ||
409 | signal_delivered(sig, info, ka, &scr->pt, | 406 | if (!ret) |
410 | test_thread_flag(TIF_SINGLESTEP)); | 407 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
411 | 408 | ||
412 | return 1; | 409 | return ret; |
413 | } | 410 | } |
414 | 411 | ||
415 | /* | 412 | /* |
@@ -419,17 +416,16 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
419 | void | 416 | void |
420 | ia64_do_signal (struct sigscratch *scr, long in_syscall) | 417 | ia64_do_signal (struct sigscratch *scr, long in_syscall) |
421 | { | 418 | { |
422 | struct k_sigaction ka; | ||
423 | siginfo_t info; | ||
424 | long restart = in_syscall; | 419 | long restart = in_syscall; |
425 | long errno = scr->pt.r8; | 420 | long errno = scr->pt.r8; |
421 | struct ksignal ksig; | ||
426 | 422 | ||
427 | /* | 423 | /* |
428 | * This only loops in the rare cases of handle_signal() failing, in which case we | 424 | * This only loops in the rare cases of handle_signal() failing, in which case we |
429 | * need to push through a forced SIGSEGV. | 425 | * need to push through a forced SIGSEGV. |
430 | */ | 426 | */ |
431 | while (1) { | 427 | while (1) { |
432 | int signr = get_signal_to_deliver(&info, &ka, &scr->pt, NULL); | 428 | get_signal(&ksig); |
433 | 429 | ||
434 | /* | 430 | /* |
435 | * get_signal_to_deliver() may have run a debugger (via notify_parent()) | 431 | * get_signal_to_deliver() may have run a debugger (via notify_parent()) |
@@ -446,7 +442,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
446 | */ | 442 | */ |
447 | restart = 0; | 443 | restart = 0; |
448 | 444 | ||
449 | if (signr <= 0) | 445 | if (ksig.sig <= 0) |
450 | break; | 446 | break; |
451 | 447 | ||
452 | if (unlikely(restart)) { | 448 | if (unlikely(restart)) { |
@@ -458,7 +454,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
458 | break; | 454 | break; |
459 | 455 | ||
460 | case ERESTARTSYS: | 456 | case ERESTARTSYS: |
461 | if ((ka.sa.sa_flags & SA_RESTART) == 0) { | 457 | if ((ksig.ka.sa.sa_flags & SA_RESTART) == 0) { |
462 | scr->pt.r8 = EINTR; | 458 | scr->pt.r8 = EINTR; |
463 | /* note: scr->pt.r10 is already -1 */ | 459 | /* note: scr->pt.r10 is already -1 */ |
464 | break; | 460 | break; |
@@ -473,7 +469,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
473 | * Whee! Actually deliver the signal. If the delivery failed, we need to | 469 | * Whee! Actually deliver the signal. If the delivery failed, we need to |
474 | * continue to iterate in this loop so we can deliver the SIGSEGV... | 470 | * continue to iterate in this loop so we can deliver the SIGSEGV... |
475 | */ | 471 | */ |
476 | if (handle_signal(signr, &ka, &info, scr)) | 472 | if (handle_signal(&ksig, scr)) |
477 | return; | 473 | return; |
478 | } | 474 | } |
479 | 475 | ||
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c index d503568cb753..95408b8f130a 100644 --- a/arch/m32r/kernel/signal.c +++ b/arch/m32r/kernel/signal.c | |||
@@ -162,28 +162,22 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
162 | * Determine which stack to use.. | 162 | * Determine which stack to use.. |
163 | */ | 163 | */ |
164 | static inline void __user * | 164 | static inline void __user * |
165 | get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) | 165 | get_sigframe(struct ksignal *ksig, unsigned long sp, size_t frame_size) |
166 | { | 166 | { |
167 | /* This is the X/Open sanctioned signal stack switching. */ | 167 | return (void __user *)((sigsp(sp, ksig) - frame_size) & -8ul); |
168 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
169 | if (sas_ss_flags(sp) == 0) | ||
170 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
171 | } | ||
172 | |||
173 | return (void __user *)((sp - frame_size) & -8ul); | ||
174 | } | 168 | } |
175 | 169 | ||
176 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 170 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
177 | sigset_t *set, struct pt_regs *regs) | 171 | struct pt_regs *regs) |
178 | { | 172 | { |
179 | struct rt_sigframe __user *frame; | 173 | struct rt_sigframe __user *frame; |
180 | int err = 0; | 174 | int err = 0; |
181 | int signal; | 175 | int signal, sig = ksig->sig; |
182 | 176 | ||
183 | frame = get_sigframe(ka, regs->spu, sizeof(*frame)); | 177 | frame = get_sigframe(ksig, regs->spu, sizeof(*frame)); |
184 | 178 | ||
185 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 179 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
186 | goto give_sigsegv; | 180 | return -EFAULT; |
187 | 181 | ||
188 | signal = current_thread_info()->exec_domain | 182 | signal = current_thread_info()->exec_domain |
189 | && current_thread_info()->exec_domain->signal_invmap | 183 | && current_thread_info()->exec_domain->signal_invmap |
@@ -193,13 +187,13 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
193 | 187 | ||
194 | err |= __put_user(signal, &frame->sig); | 188 | err |= __put_user(signal, &frame->sig); |
195 | if (err) | 189 | if (err) |
196 | goto give_sigsegv; | 190 | return -EFAULT; |
197 | 191 | ||
198 | err |= __put_user(&frame->info, &frame->pinfo); | 192 | err |= __put_user(&frame->info, &frame->pinfo); |
199 | err |= __put_user(&frame->uc, &frame->puc); | 193 | err |= __put_user(&frame->uc, &frame->puc); |
200 | err |= copy_siginfo_to_user(&frame->info, info); | 194 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
201 | if (err) | 195 | if (err) |
202 | goto give_sigsegv; | 196 | return -EFAULT; |
203 | 197 | ||
204 | /* Create the ucontext. */ | 198 | /* Create the ucontext. */ |
205 | err |= __put_user(0, &frame->uc.uc_flags); | 199 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -208,17 +202,17 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
208 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); | 202 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); |
209 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 203 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
210 | if (err) | 204 | if (err) |
211 | goto give_sigsegv; | 205 | return -EFAULT; |
212 | 206 | ||
213 | /* Set up to return from userspace. */ | 207 | /* Set up to return from userspace. */ |
214 | regs->lr = (unsigned long)ka->sa.sa_restorer; | 208 | regs->lr = (unsigned long)ksig->ka.sa.sa_restorer; |
215 | 209 | ||
216 | /* Set up registers for signal handler */ | 210 | /* Set up registers for signal handler */ |
217 | regs->spu = (unsigned long)frame; | 211 | regs->spu = (unsigned long)frame; |
218 | regs->r0 = signal; /* Arg for signal handler */ | 212 | regs->r0 = signal; /* Arg for signal handler */ |
219 | regs->r1 = (unsigned long)&frame->info; | 213 | regs->r1 = (unsigned long)&frame->info; |
220 | regs->r2 = (unsigned long)&frame->uc; | 214 | regs->r2 = (unsigned long)&frame->uc; |
221 | regs->bpc = (unsigned long)ka->sa.sa_handler; | 215 | regs->bpc = (unsigned long)ksig->ka.sa.sa_handler; |
222 | 216 | ||
223 | set_fs(USER_DS); | 217 | set_fs(USER_DS); |
224 | 218 | ||
@@ -228,10 +222,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
228 | #endif | 222 | #endif |
229 | 223 | ||
230 | return 0; | 224 | return 0; |
231 | |||
232 | give_sigsegv: | ||
233 | force_sigsegv(sig, current); | ||
234 | return -EFAULT; | ||
235 | } | 225 | } |
236 | 226 | ||
237 | static int prev_insn(struct pt_regs *regs) | 227 | static int prev_insn(struct pt_regs *regs) |
@@ -252,9 +242,10 @@ static int prev_insn(struct pt_regs *regs) | |||
252 | */ | 242 | */ |
253 | 243 | ||
254 | static void | 244 | static void |
255 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 245 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
256 | struct pt_regs *regs) | ||
257 | { | 246 | { |
247 | int ret; | ||
248 | |||
258 | /* Are we from a system call? */ | 249 | /* Are we from a system call? */ |
259 | if (regs->syscall_nr >= 0) { | 250 | if (regs->syscall_nr >= 0) { |
260 | /* If so, check system call restarting.. */ | 251 | /* If so, check system call restarting.. */ |
@@ -265,7 +256,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
265 | break; | 256 | break; |
266 | 257 | ||
267 | case -ERESTARTSYS: | 258 | case -ERESTARTSYS: |
268 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 259 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
269 | regs->r0 = -EINTR; | 260 | regs->r0 = -EINTR; |
270 | break; | 261 | break; |
271 | } | 262 | } |
@@ -278,10 +269,9 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
278 | } | 269 | } |
279 | 270 | ||
280 | /* Set up the stack frame */ | 271 | /* Set up the stack frame */ |
281 | if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs)) | 272 | ret = setup_rt_frame(ksig, sigmask_to_save(), regs); |
282 | return; | ||
283 | 273 | ||
284 | signal_delivered(sig, info, ka, regs, 0); | 274 | signal_setup_done(ret, ksig, 0); |
285 | } | 275 | } |
286 | 276 | ||
287 | /* | 277 | /* |
@@ -291,9 +281,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
291 | */ | 281 | */ |
292 | static void do_signal(struct pt_regs *regs) | 282 | static void do_signal(struct pt_regs *regs) |
293 | { | 283 | { |
294 | siginfo_t info; | 284 | struct ksignal ksig; |
295 | int signr; | ||
296 | struct k_sigaction ka; | ||
297 | 285 | ||
298 | /* | 286 | /* |
299 | * We want the common case to go fast, which | 287 | * We want the common case to go fast, which |
@@ -304,8 +292,7 @@ static void do_signal(struct pt_regs *regs) | |||
304 | if (!user_mode(regs)) | 292 | if (!user_mode(regs)) |
305 | return; | 293 | return; |
306 | 294 | ||
307 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 295 | if (get_signal(&ksig)) { |
308 | if (signr > 0) { | ||
309 | /* Re-enable any watchpoints before delivering the | 296 | /* Re-enable any watchpoints before delivering the |
310 | * signal to user space. The processor register will | 297 | * signal to user space. The processor register will |
311 | * have been cleared if the watchpoint triggered | 298 | * have been cleared if the watchpoint triggered |
@@ -313,7 +300,7 @@ static void do_signal(struct pt_regs *regs) | |||
313 | */ | 300 | */ |
314 | 301 | ||
315 | /* Whee! Actually deliver the signal. */ | 302 | /* Whee! Actually deliver the signal. */ |
316 | handle_signal(signr, &ka, &info, regs); | 303 | handle_signal(&ksig, regs); |
317 | 304 | ||
318 | return; | 305 | return; |
319 | } | 306 | } |
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c index 57fd286e4b0b..967a8b7e1527 100644 --- a/arch/m68k/kernel/signal.c +++ b/arch/m68k/kernel/signal.c | |||
@@ -835,38 +835,30 @@ static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs * | |||
835 | } | 835 | } |
836 | 836 | ||
837 | static inline void __user * | 837 | static inline void __user * |
838 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | 838 | get_sigframe(struct ksignal *ksig, size_t frame_size) |
839 | { | 839 | { |
840 | unsigned long usp; | 840 | unsigned long usp = sigsp(rdusp(), ksig); |
841 | |||
842 | /* Default to using normal stack. */ | ||
843 | usp = rdusp(); | ||
844 | 841 | ||
845 | /* This is the X/Open sanctioned signal stack switching. */ | ||
846 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
847 | if (!sas_ss_flags(usp)) | ||
848 | usp = current->sas_ss_sp + current->sas_ss_size; | ||
849 | } | ||
850 | return (void __user *)((usp - frame_size) & -8UL); | 842 | return (void __user *)((usp - frame_size) & -8UL); |
851 | } | 843 | } |
852 | 844 | ||
853 | static int setup_frame (int sig, struct k_sigaction *ka, | 845 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
854 | sigset_t *set, struct pt_regs *regs) | 846 | struct pt_regs *regs) |
855 | { | 847 | { |
856 | struct sigframe __user *frame; | 848 | struct sigframe __user *frame; |
857 | int fsize = frame_extra_sizes(regs->format); | 849 | int fsize = frame_extra_sizes(regs->format); |
858 | struct sigcontext context; | 850 | struct sigcontext context; |
859 | int err = 0; | 851 | int err = 0, sig = ksig->sig; |
860 | 852 | ||
861 | if (fsize < 0) { | 853 | if (fsize < 0) { |
862 | #ifdef DEBUG | 854 | #ifdef DEBUG |
863 | printk ("setup_frame: Unknown frame format %#x\n", | 855 | printk ("setup_frame: Unknown frame format %#x\n", |
864 | regs->format); | 856 | regs->format); |
865 | #endif | 857 | #endif |
866 | goto give_sigsegv; | 858 | return -EFAULT; |
867 | } | 859 | } |
868 | 860 | ||
869 | frame = get_sigframe(ka, regs, sizeof(*frame) + fsize); | 861 | frame = get_sigframe(ksig, sizeof(*frame) + fsize); |
870 | 862 | ||
871 | if (fsize) | 863 | if (fsize) |
872 | err |= copy_to_user (frame + 1, regs + 1, fsize); | 864 | err |= copy_to_user (frame + 1, regs + 1, fsize); |
@@ -899,7 +891,7 @@ static int setup_frame (int sig, struct k_sigaction *ka, | |||
899 | #endif | 891 | #endif |
900 | 892 | ||
901 | if (err) | 893 | if (err) |
902 | goto give_sigsegv; | 894 | return -EFAULT; |
903 | 895 | ||
904 | push_cache ((unsigned long) &frame->retcode); | 896 | push_cache ((unsigned long) &frame->retcode); |
905 | 897 | ||
@@ -908,7 +900,7 @@ static int setup_frame (int sig, struct k_sigaction *ka, | |||
908 | * to destroy is successfully copied to sigframe. | 900 | * to destroy is successfully copied to sigframe. |
909 | */ | 901 | */ |
910 | wrusp ((unsigned long) frame); | 902 | wrusp ((unsigned long) frame); |
911 | regs->pc = (unsigned long) ka->sa.sa_handler; | 903 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
912 | adjustformat(regs); | 904 | adjustformat(regs); |
913 | 905 | ||
914 | /* | 906 | /* |
@@ -934,28 +926,24 @@ static int setup_frame (int sig, struct k_sigaction *ka, | |||
934 | tregs->sr = regs->sr; | 926 | tregs->sr = regs->sr; |
935 | } | 927 | } |
936 | return 0; | 928 | return 0; |
937 | |||
938 | give_sigsegv: | ||
939 | force_sigsegv(sig, current); | ||
940 | return err; | ||
941 | } | 929 | } |
942 | 930 | ||
943 | static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | 931 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
944 | sigset_t *set, struct pt_regs *regs) | 932 | struct pt_regs *regs) |
945 | { | 933 | { |
946 | struct rt_sigframe __user *frame; | 934 | struct rt_sigframe __user *frame; |
947 | int fsize = frame_extra_sizes(regs->format); | 935 | int fsize = frame_extra_sizes(regs->format); |
948 | int err = 0; | 936 | int err = 0, sig = ksig->sig; |
949 | 937 | ||
950 | if (fsize < 0) { | 938 | if (fsize < 0) { |
951 | #ifdef DEBUG | 939 | #ifdef DEBUG |
952 | printk ("setup_frame: Unknown frame format %#x\n", | 940 | printk ("setup_frame: Unknown frame format %#x\n", |
953 | regs->format); | 941 | regs->format); |
954 | #endif | 942 | #endif |
955 | goto give_sigsegv; | 943 | return -EFAULT; |
956 | } | 944 | } |
957 | 945 | ||
958 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 946 | frame = get_sigframe(ksig, sizeof(*frame)); |
959 | 947 | ||
960 | if (fsize) | 948 | if (fsize) |
961 | err |= copy_to_user (&frame->uc.uc_extra, regs + 1, fsize); | 949 | err |= copy_to_user (&frame->uc.uc_extra, regs + 1, fsize); |
@@ -968,7 +956,7 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | |||
968 | &frame->sig); | 956 | &frame->sig); |
969 | err |= __put_user(&frame->info, &frame->pinfo); | 957 | err |= __put_user(&frame->info, &frame->pinfo); |
970 | err |= __put_user(&frame->uc, &frame->puc); | 958 | err |= __put_user(&frame->uc, &frame->puc); |
971 | err |= copy_siginfo_to_user(&frame->info, info); | 959 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
972 | 960 | ||
973 | /* Create the ucontext. */ | 961 | /* Create the ucontext. */ |
974 | err |= __put_user(0, &frame->uc.uc_flags); | 962 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -996,7 +984,7 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | |||
996 | #endif /* CONFIG_MMU */ | 984 | #endif /* CONFIG_MMU */ |
997 | 985 | ||
998 | if (err) | 986 | if (err) |
999 | goto give_sigsegv; | 987 | return -EFAULT; |
1000 | 988 | ||
1001 | push_cache ((unsigned long) &frame->retcode); | 989 | push_cache ((unsigned long) &frame->retcode); |
1002 | 990 | ||
@@ -1005,7 +993,7 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | |||
1005 | * to destroy is successfully copied to sigframe. | 993 | * to destroy is successfully copied to sigframe. |
1006 | */ | 994 | */ |
1007 | wrusp ((unsigned long) frame); | 995 | wrusp ((unsigned long) frame); |
1008 | regs->pc = (unsigned long) ka->sa.sa_handler; | 996 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
1009 | adjustformat(regs); | 997 | adjustformat(regs); |
1010 | 998 | ||
1011 | /* | 999 | /* |
@@ -1031,10 +1019,6 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, | |||
1031 | tregs->sr = regs->sr; | 1019 | tregs->sr = regs->sr; |
1032 | } | 1020 | } |
1033 | return 0; | 1021 | return 0; |
1034 | |||
1035 | give_sigsegv: | ||
1036 | force_sigsegv(sig, current); | ||
1037 | return err; | ||
1038 | } | 1022 | } |
1039 | 1023 | ||
1040 | static inline void | 1024 | static inline void |
@@ -1074,26 +1058,22 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) | |||
1074 | * OK, we're invoking a handler | 1058 | * OK, we're invoking a handler |
1075 | */ | 1059 | */ |
1076 | static void | 1060 | static void |
1077 | handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, | 1061 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
1078 | struct pt_regs *regs) | ||
1079 | { | 1062 | { |
1080 | sigset_t *oldset = sigmask_to_save(); | 1063 | sigset_t *oldset = sigmask_to_save(); |
1081 | int err; | 1064 | int err; |
1082 | /* are we from a system call? */ | 1065 | /* are we from a system call? */ |
1083 | if (regs->orig_d0 >= 0) | 1066 | if (regs->orig_d0 >= 0) |
1084 | /* If so, check system call restarting.. */ | 1067 | /* If so, check system call restarting.. */ |
1085 | handle_restart(regs, ka, 1); | 1068 | handle_restart(regs, &ksig->ka, 1); |
1086 | 1069 | ||
1087 | /* set up the stack frame */ | 1070 | /* set up the stack frame */ |
1088 | if (ka->sa.sa_flags & SA_SIGINFO) | 1071 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
1089 | err = setup_rt_frame(sig, ka, info, oldset, regs); | 1072 | err = setup_rt_frame(ksig, oldset, regs); |
1090 | else | 1073 | else |
1091 | err = setup_frame(sig, ka, oldset, regs); | 1074 | err = setup_frame(ksig, oldset, regs); |
1092 | |||
1093 | if (err) | ||
1094 | return; | ||
1095 | 1075 | ||
1096 | signal_delivered(sig, info, ka, regs, 0); | 1076 | signal_setup_done(err, ksig, 0); |
1097 | 1077 | ||
1098 | if (test_thread_flag(TIF_DELAYED_TRACE)) { | 1078 | if (test_thread_flag(TIF_DELAYED_TRACE)) { |
1099 | regs->sr &= ~0x8000; | 1079 | regs->sr &= ~0x8000; |
@@ -1108,16 +1088,13 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
1108 | */ | 1088 | */ |
1109 | static void do_signal(struct pt_regs *regs) | 1089 | static void do_signal(struct pt_regs *regs) |
1110 | { | 1090 | { |
1111 | siginfo_t info; | 1091 | struct ksignal ksig; |
1112 | struct k_sigaction ka; | ||
1113 | int signr; | ||
1114 | 1092 | ||
1115 | current->thread.esp0 = (unsigned long) regs; | 1093 | current->thread.esp0 = (unsigned long) regs; |
1116 | 1094 | ||
1117 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 1095 | if (get_signal(&ksig)) { |
1118 | if (signr > 0) { | ||
1119 | /* Whee! Actually deliver the signal. */ | 1096 | /* Whee! Actually deliver the signal. */ |
1120 | handle_signal(signr, &ka, &info, regs); | 1097 | handle_signal(&ksig, regs); |
1121 | return; | 1098 | return; |
1122 | } | 1099 | } |
1123 | 1100 | ||
diff --git a/arch/metag/kernel/signal.c b/arch/metag/kernel/signal.c index b9e4a82d2bd4..0d100d5c1407 100644 --- a/arch/metag/kernel/signal.c +++ b/arch/metag/kernel/signal.c | |||
@@ -140,13 +140,9 @@ static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
140 | /* | 140 | /* |
141 | * Determine which stack to use.. | 141 | * Determine which stack to use.. |
142 | */ | 142 | */ |
143 | static void __user *get_sigframe(struct k_sigaction *ka, unsigned long sp, | 143 | static void __user *get_sigframe(struct ksignal *ksig, unsigned long sp) |
144 | size_t frame_size) | ||
145 | { | 144 | { |
146 | /* Meta stacks grows upwards */ | 145 | sp = sigsp(sp, ksig); |
147 | if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0)) | ||
148 | sp = current->sas_ss_sp; | ||
149 | |||
150 | sp = (sp + 7) & ~7; /* 8byte align stack */ | 146 | sp = (sp + 7) & ~7; /* 8byte align stack */ |
151 | 147 | ||
152 | return (void __user *)sp; | 148 | return (void __user *)sp; |
@@ -159,7 +155,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, | |||
159 | int err; | 155 | int err; |
160 | unsigned long code; | 156 | unsigned long code; |
161 | 157 | ||
162 | frame = get_sigframe(&ksig->ka, regs->REG_SP, sizeof(*frame)); | 158 | frame = get_sigframe(ksig, regs->REG_SP); |
163 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 159 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
164 | return -EFAULT; | 160 | return -EFAULT; |
165 | 161 | ||
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c index 49a07a4d76d0..8955a3829cf0 100644 --- a/arch/microblaze/kernel/signal.c +++ b/arch/microblaze/kernel/signal.c | |||
@@ -145,22 +145,19 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
145 | * Determine which stack to use.. | 145 | * Determine which stack to use.. |
146 | */ | 146 | */ |
147 | static inline void __user * | 147 | static inline void __user * |
148 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | 148 | get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size) |
149 | { | 149 | { |
150 | /* Default to using normal stack */ | 150 | /* Default to using normal stack */ |
151 | unsigned long sp = regs->r1; | 151 | unsigned long sp = sigsp(regs->r1, ksig); |
152 | |||
153 | if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && !on_sig_stack(sp)) | ||
154 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
155 | 152 | ||
156 | return (void __user *)((sp - frame_size) & -8UL); | 153 | return (void __user *)((sp - frame_size) & -8UL); |
157 | } | 154 | } |
158 | 155 | ||
159 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 156 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
160 | sigset_t *set, struct pt_regs *regs) | 157 | struct pt_regs *regs) |
161 | { | 158 | { |
162 | struct rt_sigframe __user *frame; | 159 | struct rt_sigframe __user *frame; |
163 | int err = 0; | 160 | int err = 0, sig = ksig->sig; |
164 | int signal; | 161 | int signal; |
165 | unsigned long address = 0; | 162 | unsigned long address = 0; |
166 | #ifdef CONFIG_MMU | 163 | #ifdef CONFIG_MMU |
@@ -168,10 +165,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
168 | pte_t *ptep; | 165 | pte_t *ptep; |
169 | #endif | 166 | #endif |
170 | 167 | ||
171 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 168 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
172 | 169 | ||
173 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 170 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
174 | goto give_sigsegv; | 171 | return -EFAULT; |
175 | 172 | ||
176 | signal = current_thread_info()->exec_domain | 173 | signal = current_thread_info()->exec_domain |
177 | && current_thread_info()->exec_domain->signal_invmap | 174 | && current_thread_info()->exec_domain->signal_invmap |
@@ -179,8 +176,8 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
179 | ? current_thread_info()->exec_domain->signal_invmap[sig] | 176 | ? current_thread_info()->exec_domain->signal_invmap[sig] |
180 | : sig; | 177 | : sig; |
181 | 178 | ||
182 | if (info) | 179 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
183 | err |= copy_siginfo_to_user(&frame->info, info); | 180 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
184 | 181 | ||
185 | /* Create the ucontext. */ | 182 | /* Create the ucontext. */ |
186 | err |= __put_user(0, &frame->uc.uc_flags); | 183 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -227,7 +224,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
227 | flush_dcache_range(address, address + 8); | 224 | flush_dcache_range(address, address + 8); |
228 | #endif | 225 | #endif |
229 | if (err) | 226 | if (err) |
230 | goto give_sigsegv; | 227 | return -EFAULT; |
231 | 228 | ||
232 | /* Set up registers for signal handler */ | 229 | /* Set up registers for signal handler */ |
233 | regs->r1 = (unsigned long) frame; | 230 | regs->r1 = (unsigned long) frame; |
@@ -237,7 +234,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
237 | regs->r6 = (unsigned long) &frame->info; /* arg 1: siginfo */ | 234 | regs->r6 = (unsigned long) &frame->info; /* arg 1: siginfo */ |
238 | regs->r7 = (unsigned long) &frame->uc; /* arg2: ucontext */ | 235 | regs->r7 = (unsigned long) &frame->uc; /* arg2: ucontext */ |
239 | /* Offset to handle microblaze rtid r14, 0 */ | 236 | /* Offset to handle microblaze rtid r14, 0 */ |
240 | regs->pc = (unsigned long)ka->sa.sa_handler; | 237 | regs->pc = (unsigned long)ksig->ka.sa.sa_handler; |
241 | 238 | ||
242 | set_fs(USER_DS); | 239 | set_fs(USER_DS); |
243 | 240 | ||
@@ -247,10 +244,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
247 | #endif | 244 | #endif |
248 | 245 | ||
249 | return 0; | 246 | return 0; |
250 | |||
251 | give_sigsegv: | ||
252 | force_sigsegv(sig, current); | ||
253 | return -EFAULT; | ||
254 | } | 247 | } |
255 | 248 | ||
256 | /* Handle restarting system calls */ | 249 | /* Handle restarting system calls */ |
@@ -283,23 +276,15 @@ do_restart: | |||
283 | */ | 276 | */ |
284 | 277 | ||
285 | static void | 278 | static void |
286 | handle_signal(unsigned long sig, struct k_sigaction *ka, | 279 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
287 | siginfo_t *info, struct pt_regs *regs) | ||
288 | { | 280 | { |
289 | sigset_t *oldset = sigmask_to_save(); | 281 | sigset_t *oldset = sigmask_to_save(); |
290 | int ret; | 282 | int ret; |
291 | 283 | ||
292 | /* Set up the stack frame */ | 284 | /* Set up the stack frame */ |
293 | if (ka->sa.sa_flags & SA_SIGINFO) | 285 | ret = setup_rt_frame(ksig, oldset, regs); |
294 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | ||
295 | else | ||
296 | ret = setup_rt_frame(sig, ka, NULL, oldset, regs); | ||
297 | 286 | ||
298 | if (ret) | 287 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
299 | return; | ||
300 | |||
301 | signal_delivered(sig, info, ka, regs, | ||
302 | test_thread_flag(TIF_SINGLESTEP)); | ||
303 | } | 288 | } |
304 | 289 | ||
305 | /* | 290 | /* |
@@ -313,21 +298,19 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
313 | */ | 298 | */ |
314 | static void do_signal(struct pt_regs *regs, int in_syscall) | 299 | static void do_signal(struct pt_regs *regs, int in_syscall) |
315 | { | 300 | { |
316 | siginfo_t info; | 301 | struct ksignal ksig; |
317 | int signr; | 302 | |
318 | struct k_sigaction ka; | ||
319 | #ifdef DEBUG_SIG | 303 | #ifdef DEBUG_SIG |
320 | pr_info("do signal: %p %d\n", regs, in_syscall); | 304 | pr_info("do signal: %p %d\n", regs, in_syscall); |
321 | pr_info("do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1, | 305 | pr_info("do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1, |
322 | regs->r12, current_thread_info()->flags); | 306 | regs->r12, current_thread_info()->flags); |
323 | #endif | 307 | #endif |
324 | 308 | ||
325 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 309 | if (get_signal(&ksig)) { |
326 | if (signr > 0) { | ||
327 | /* Whee! Actually deliver the signal. */ | 310 | /* Whee! Actually deliver the signal. */ |
328 | if (in_syscall) | 311 | if (in_syscall) |
329 | handle_restart(regs, &ka, 1); | 312 | handle_restart(regs, &ksig.ka, 1); |
330 | handle_signal(signr, &ka, &info, regs); | 313 | handle_signal(&ksig, regs); |
331 | return; | 314 | return; |
332 | } | 315 | } |
333 | 316 | ||
diff --git a/arch/mips/include/asm/abi.h b/arch/mips/include/asm/abi.h index 909bb6984866..7186bb51b89b 100644 --- a/arch/mips/include/asm/abi.h +++ b/arch/mips/include/asm/abi.h | |||
@@ -13,13 +13,11 @@ | |||
13 | #include <asm/siginfo.h> | 13 | #include <asm/siginfo.h> |
14 | 14 | ||
15 | struct mips_abi { | 15 | struct mips_abi { |
16 | int (* const setup_frame)(void *sig_return, struct k_sigaction *ka, | 16 | int (* const setup_frame)(void *sig_return, struct ksignal *ksig, |
17 | struct pt_regs *regs, int signr, | 17 | struct pt_regs *regs, sigset_t *set); |
18 | sigset_t *set); | ||
19 | const unsigned long signal_return_offset; | 18 | const unsigned long signal_return_offset; |
20 | int (* const setup_rt_frame)(void *sig_return, struct k_sigaction *ka, | 19 | int (* const setup_rt_frame)(void *sig_return, struct ksignal *ksig, |
21 | struct pt_regs *regs, int signr, | 20 | struct pt_regs *regs, sigset_t *set); |
22 | sigset_t *set, siginfo_t *info); | ||
23 | const unsigned long rt_signal_return_offset; | 21 | const unsigned long rt_signal_return_offset; |
24 | const unsigned long restart; | 22 | const unsigned long restart; |
25 | }; | 23 | }; |
diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h index 9c60d09e62a7..06805e09bcd3 100644 --- a/arch/mips/kernel/signal-common.h +++ b/arch/mips/kernel/signal-common.h | |||
@@ -22,7 +22,7 @@ | |||
22 | /* | 22 | /* |
23 | * Determine which stack to use.. | 23 | * Determine which stack to use.. |
24 | */ | 24 | */ |
25 | extern void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, | 25 | extern void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, |
26 | size_t frame_size); | 26 | size_t frame_size); |
27 | /* Check and clear pending FPU exceptions in saved CSR */ | 27 | /* Check and clear pending FPU exceptions in saved CSR */ |
28 | extern int fpcsr_pending(unsigned int __user *fpcsr); | 28 | extern int fpcsr_pending(unsigned int __user *fpcsr); |
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index 9e60d117e41e..1d57605e4615 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c | |||
@@ -280,7 +280,7 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) | |||
280 | return err; | 280 | return err; |
281 | } | 281 | } |
282 | 282 | ||
283 | void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, | 283 | void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, |
284 | size_t frame_size) | 284 | size_t frame_size) |
285 | { | 285 | { |
286 | unsigned long sp; | 286 | unsigned long sp; |
@@ -295,9 +295,7 @@ void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, | |||
295 | */ | 295 | */ |
296 | sp -= 32; | 296 | sp -= 32; |
297 | 297 | ||
298 | /* This is the X/Open sanctioned signal stack switching. */ | 298 | sp = sigsp(sp, ksig); |
299 | if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0)) | ||
300 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
301 | 299 | ||
302 | return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size()-1) : ALMASK)); | 300 | return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size()-1) : ALMASK)); |
303 | } | 301 | } |
@@ -428,20 +426,20 @@ badframe: | |||
428 | } | 426 | } |
429 | 427 | ||
430 | #ifdef CONFIG_TRAD_SIGNALS | 428 | #ifdef CONFIG_TRAD_SIGNALS |
431 | static int setup_frame(void *sig_return, struct k_sigaction *ka, | 429 | static int setup_frame(void *sig_return, struct ksignal *ksig, |
432 | struct pt_regs *regs, int signr, sigset_t *set) | 430 | struct pt_regs *regs, sigset_t *set) |
433 | { | 431 | { |
434 | struct sigframe __user *frame; | 432 | struct sigframe __user *frame; |
435 | int err = 0; | 433 | int err = 0; |
436 | 434 | ||
437 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 435 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
438 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 436 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
439 | goto give_sigsegv; | 437 | return -EFAULT; |
440 | 438 | ||
441 | err |= setup_sigcontext(regs, &frame->sf_sc); | 439 | err |= setup_sigcontext(regs, &frame->sf_sc); |
442 | err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set)); | 440 | err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set)); |
443 | if (err) | 441 | if (err) |
444 | goto give_sigsegv; | 442 | return -EFAULT; |
445 | 443 | ||
446 | /* | 444 | /* |
447 | * Arguments to signal handler: | 445 | * Arguments to signal handler: |
@@ -453,37 +451,32 @@ static int setup_frame(void *sig_return, struct k_sigaction *ka, | |||
453 | * $25 and c0_epc point to the signal handler, $29 points to the | 451 | * $25 and c0_epc point to the signal handler, $29 points to the |
454 | * struct sigframe. | 452 | * struct sigframe. |
455 | */ | 453 | */ |
456 | regs->regs[ 4] = signr; | 454 | regs->regs[ 4] = ksig->sig; |
457 | regs->regs[ 5] = 0; | 455 | regs->regs[ 5] = 0; |
458 | regs->regs[ 6] = (unsigned long) &frame->sf_sc; | 456 | regs->regs[ 6] = (unsigned long) &frame->sf_sc; |
459 | regs->regs[29] = (unsigned long) frame; | 457 | regs->regs[29] = (unsigned long) frame; |
460 | regs->regs[31] = (unsigned long) sig_return; | 458 | regs->regs[31] = (unsigned long) sig_return; |
461 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; | 459 | regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; |
462 | 460 | ||
463 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", | 461 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
464 | current->comm, current->pid, | 462 | current->comm, current->pid, |
465 | frame, regs->cp0_epc, regs->regs[31]); | 463 | frame, regs->cp0_epc, regs->regs[31]); |
466 | return 0; | 464 | return 0; |
467 | |||
468 | give_sigsegv: | ||
469 | force_sigsegv(signr, current); | ||
470 | return -EFAULT; | ||
471 | } | 465 | } |
472 | #endif | 466 | #endif |
473 | 467 | ||
474 | static int setup_rt_frame(void *sig_return, struct k_sigaction *ka, | 468 | static int setup_rt_frame(void *sig_return, struct ksignal *ksig, |
475 | struct pt_regs *regs, int signr, sigset_t *set, | 469 | struct pt_regs *regs, sigset_t *set) |
476 | siginfo_t *info) | ||
477 | { | 470 | { |
478 | struct rt_sigframe __user *frame; | 471 | struct rt_sigframe __user *frame; |
479 | int err = 0; | 472 | int err = 0; |
480 | 473 | ||
481 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 474 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
482 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 475 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
483 | goto give_sigsegv; | 476 | return -EFAULT; |
484 | 477 | ||
485 | /* Create siginfo. */ | 478 | /* Create siginfo. */ |
486 | err |= copy_siginfo_to_user(&frame->rs_info, info); | 479 | err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info); |
487 | 480 | ||
488 | /* Create the ucontext. */ | 481 | /* Create the ucontext. */ |
489 | err |= __put_user(0, &frame->rs_uc.uc_flags); | 482 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
@@ -493,7 +486,7 @@ static int setup_rt_frame(void *sig_return, struct k_sigaction *ka, | |||
493 | err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); | 486 | err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); |
494 | 487 | ||
495 | if (err) | 488 | if (err) |
496 | goto give_sigsegv; | 489 | return -EFAULT; |
497 | 490 | ||
498 | /* | 491 | /* |
499 | * Arguments to signal handler: | 492 | * Arguments to signal handler: |
@@ -505,22 +498,18 @@ static int setup_rt_frame(void *sig_return, struct k_sigaction *ka, | |||
505 | * $25 and c0_epc point to the signal handler, $29 points to | 498 | * $25 and c0_epc point to the signal handler, $29 points to |
506 | * the struct rt_sigframe. | 499 | * the struct rt_sigframe. |
507 | */ | 500 | */ |
508 | regs->regs[ 4] = signr; | 501 | regs->regs[ 4] = ksig->sig; |
509 | regs->regs[ 5] = (unsigned long) &frame->rs_info; | 502 | regs->regs[ 5] = (unsigned long) &frame->rs_info; |
510 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; | 503 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; |
511 | regs->regs[29] = (unsigned long) frame; | 504 | regs->regs[29] = (unsigned long) frame; |
512 | regs->regs[31] = (unsigned long) sig_return; | 505 | regs->regs[31] = (unsigned long) sig_return; |
513 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; | 506 | regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; |
514 | 507 | ||
515 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", | 508 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
516 | current->comm, current->pid, | 509 | current->comm, current->pid, |
517 | frame, regs->cp0_epc, regs->regs[31]); | 510 | frame, regs->cp0_epc, regs->regs[31]); |
518 | 511 | ||
519 | return 0; | 512 | return 0; |
520 | |||
521 | give_sigsegv: | ||
522 | force_sigsegv(signr, current); | ||
523 | return -EFAULT; | ||
524 | } | 513 | } |
525 | 514 | ||
526 | struct mips_abi mips_abi = { | 515 | struct mips_abi mips_abi = { |
@@ -534,8 +523,7 @@ struct mips_abi mips_abi = { | |||
534 | .restart = __NR_restart_syscall | 523 | .restart = __NR_restart_syscall |
535 | }; | 524 | }; |
536 | 525 | ||
537 | static void handle_signal(unsigned long sig, siginfo_t *info, | 526 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
538 | struct k_sigaction *ka, struct pt_regs *regs) | ||
539 | { | 527 | { |
540 | sigset_t *oldset = sigmask_to_save(); | 528 | sigset_t *oldset = sigmask_to_save(); |
541 | int ret; | 529 | int ret; |
@@ -557,7 +545,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
557 | regs->regs[2] = EINTR; | 545 | regs->regs[2] = EINTR; |
558 | break; | 546 | break; |
559 | case ERESTARTSYS: | 547 | case ERESTARTSYS: |
560 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 548 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
561 | regs->regs[2] = EINTR; | 549 | regs->regs[2] = EINTR; |
562 | break; | 550 | break; |
563 | } | 551 | } |
@@ -571,29 +559,23 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
571 | regs->regs[0] = 0; /* Don't deal with this again. */ | 559 | regs->regs[0] = 0; /* Don't deal with this again. */ |
572 | } | 560 | } |
573 | 561 | ||
574 | if (sig_uses_siginfo(ka)) | 562 | if (sig_uses_siginfo(&ksig->ka)) |
575 | ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset, | 563 | ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset, |
576 | ka, regs, sig, oldset, info); | 564 | ksig, regs, oldset); |
577 | else | 565 | else |
578 | ret = abi->setup_frame(vdso + abi->signal_return_offset, | 566 | ret = abi->setup_frame(vdso + abi->signal_return_offset, ksig, |
579 | ka, regs, sig, oldset); | 567 | regs, oldset); |
580 | |||
581 | if (ret) | ||
582 | return; | ||
583 | 568 | ||
584 | signal_delivered(sig, info, ka, regs, 0); | 569 | signal_setup_done(ret, ksig, 0); |
585 | } | 570 | } |
586 | 571 | ||
587 | static void do_signal(struct pt_regs *regs) | 572 | static void do_signal(struct pt_regs *regs) |
588 | { | 573 | { |
589 | struct k_sigaction ka; | 574 | struct ksignal ksig; |
590 | siginfo_t info; | ||
591 | int signr; | ||
592 | 575 | ||
593 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 576 | if (get_signal(&ksig)) { |
594 | if (signr > 0) { | ||
595 | /* Whee! Actually deliver the signal. */ | 577 | /* Whee! Actually deliver the signal. */ |
596 | handle_signal(signr, &info, &ka, regs); | 578 | handle_signal(&ksig, regs); |
597 | return; | 579 | return; |
598 | } | 580 | } |
599 | 581 | ||
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c index bae2e6ee2109..d69179c0d49d 100644 --- a/arch/mips/kernel/signal32.c +++ b/arch/mips/kernel/signal32.c | |||
@@ -490,21 +490,21 @@ badframe: | |||
490 | force_sig(SIGSEGV, current); | 490 | force_sig(SIGSEGV, current); |
491 | } | 491 | } |
492 | 492 | ||
493 | static int setup_frame_32(void *sig_return, struct k_sigaction *ka, | 493 | static int setup_frame_32(void *sig_return, struct ksignal *ksig, |
494 | struct pt_regs *regs, int signr, sigset_t *set) | 494 | struct pt_regs *regs, sigset_t *set) |
495 | { | 495 | { |
496 | struct sigframe32 __user *frame; | 496 | struct sigframe32 __user *frame; |
497 | int err = 0; | 497 | int err = 0; |
498 | 498 | ||
499 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 499 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
500 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 500 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
501 | goto give_sigsegv; | 501 | return -EFAULT; |
502 | 502 | ||
503 | err |= setup_sigcontext32(regs, &frame->sf_sc); | 503 | err |= setup_sigcontext32(regs, &frame->sf_sc); |
504 | err |= __copy_conv_sigset_to_user(&frame->sf_mask, set); | 504 | err |= __copy_conv_sigset_to_user(&frame->sf_mask, set); |
505 | 505 | ||
506 | if (err) | 506 | if (err) |
507 | goto give_sigsegv; | 507 | return -EFAULT; |
508 | 508 | ||
509 | /* | 509 | /* |
510 | * Arguments to signal handler: | 510 | * Arguments to signal handler: |
@@ -516,37 +516,32 @@ static int setup_frame_32(void *sig_return, struct k_sigaction *ka, | |||
516 | * $25 and c0_epc point to the signal handler, $29 points to the | 516 | * $25 and c0_epc point to the signal handler, $29 points to the |
517 | * struct sigframe. | 517 | * struct sigframe. |
518 | */ | 518 | */ |
519 | regs->regs[ 4] = signr; | 519 | regs->regs[ 4] = ksig->sig; |
520 | regs->regs[ 5] = 0; | 520 | regs->regs[ 5] = 0; |
521 | regs->regs[ 6] = (unsigned long) &frame->sf_sc; | 521 | regs->regs[ 6] = (unsigned long) &frame->sf_sc; |
522 | regs->regs[29] = (unsigned long) frame; | 522 | regs->regs[29] = (unsigned long) frame; |
523 | regs->regs[31] = (unsigned long) sig_return; | 523 | regs->regs[31] = (unsigned long) sig_return; |
524 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; | 524 | regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; |
525 | 525 | ||
526 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", | 526 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
527 | current->comm, current->pid, | 527 | current->comm, current->pid, |
528 | frame, regs->cp0_epc, regs->regs[31]); | 528 | frame, regs->cp0_epc, regs->regs[31]); |
529 | 529 | ||
530 | return 0; | 530 | return 0; |
531 | |||
532 | give_sigsegv: | ||
533 | force_sigsegv(signr, current); | ||
534 | return -EFAULT; | ||
535 | } | 531 | } |
536 | 532 | ||
537 | static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, | 533 | static int setup_rt_frame_32(void *sig_return, struct ksignal *ksig, |
538 | struct pt_regs *regs, int signr, sigset_t *set, | 534 | struct pt_regs *regs, sigset_t *set) |
539 | siginfo_t *info) | ||
540 | { | 535 | { |
541 | struct rt_sigframe32 __user *frame; | 536 | struct rt_sigframe32 __user *frame; |
542 | int err = 0; | 537 | int err = 0; |
543 | 538 | ||
544 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 539 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
545 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 540 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
546 | goto give_sigsegv; | 541 | return -EFAULT; |
547 | 542 | ||
548 | /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */ | 543 | /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */ |
549 | err |= copy_siginfo_to_user32(&frame->rs_info, info); | 544 | err |= copy_siginfo_to_user32(&frame->rs_info, &ksig->info); |
550 | 545 | ||
551 | /* Create the ucontext. */ | 546 | /* Create the ucontext. */ |
552 | err |= __put_user(0, &frame->rs_uc.uc_flags); | 547 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
@@ -556,7 +551,7 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, | |||
556 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); | 551 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); |
557 | 552 | ||
558 | if (err) | 553 | if (err) |
559 | goto give_sigsegv; | 554 | return -EFAULT; |
560 | 555 | ||
561 | /* | 556 | /* |
562 | * Arguments to signal handler: | 557 | * Arguments to signal handler: |
@@ -568,22 +563,18 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, | |||
568 | * $25 and c0_epc point to the signal handler, $29 points to | 563 | * $25 and c0_epc point to the signal handler, $29 points to |
569 | * the struct rt_sigframe32. | 564 | * the struct rt_sigframe32. |
570 | */ | 565 | */ |
571 | regs->regs[ 4] = signr; | 566 | regs->regs[ 4] = ksig->sig; |
572 | regs->regs[ 5] = (unsigned long) &frame->rs_info; | 567 | regs->regs[ 5] = (unsigned long) &frame->rs_info; |
573 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; | 568 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; |
574 | regs->regs[29] = (unsigned long) frame; | 569 | regs->regs[29] = (unsigned long) frame; |
575 | regs->regs[31] = (unsigned long) sig_return; | 570 | regs->regs[31] = (unsigned long) sig_return; |
576 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; | 571 | regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; |
577 | 572 | ||
578 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", | 573 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
579 | current->comm, current->pid, | 574 | current->comm, current->pid, |
580 | frame, regs->cp0_epc, regs->regs[31]); | 575 | frame, regs->cp0_epc, regs->regs[31]); |
581 | 576 | ||
582 | return 0; | 577 | return 0; |
583 | |||
584 | give_sigsegv: | ||
585 | force_sigsegv(signr, current); | ||
586 | return -EFAULT; | ||
587 | } | 578 | } |
588 | 579 | ||
589 | /* | 580 | /* |
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c index b2241bb9cac1..f1d4751eead0 100644 --- a/arch/mips/kernel/signal_n32.c +++ b/arch/mips/kernel/signal_n32.c | |||
@@ -102,18 +102,18 @@ badframe: | |||
102 | force_sig(SIGSEGV, current); | 102 | force_sig(SIGSEGV, current); |
103 | } | 103 | } |
104 | 104 | ||
105 | static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka, | 105 | static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig, |
106 | struct pt_regs *regs, int signr, sigset_t *set, siginfo_t *info) | 106 | struct pt_regs *regs, sigset_t *set) |
107 | { | 107 | { |
108 | struct rt_sigframe_n32 __user *frame; | 108 | struct rt_sigframe_n32 __user *frame; |
109 | int err = 0; | 109 | int err = 0; |
110 | 110 | ||
111 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 111 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
112 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 112 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
113 | goto give_sigsegv; | 113 | return -EFAULT; |
114 | 114 | ||
115 | /* Create siginfo. */ | 115 | /* Create siginfo. */ |
116 | err |= copy_siginfo_to_user32(&frame->rs_info, info); | 116 | err |= copy_siginfo_to_user32(&frame->rs_info, &ksig->info); |
117 | 117 | ||
118 | /* Create the ucontext. */ | 118 | /* Create the ucontext. */ |
119 | err |= __put_user(0, &frame->rs_uc.uc_flags); | 119 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
@@ -123,7 +123,7 @@ static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka, | |||
123 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); | 123 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); |
124 | 124 | ||
125 | if (err) | 125 | if (err) |
126 | goto give_sigsegv; | 126 | return -EFAULT; |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * Arguments to signal handler: | 129 | * Arguments to signal handler: |
@@ -135,22 +135,18 @@ static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka, | |||
135 | * $25 and c0_epc point to the signal handler, $29 points to | 135 | * $25 and c0_epc point to the signal handler, $29 points to |
136 | * the struct rt_sigframe. | 136 | * the struct rt_sigframe. |
137 | */ | 137 | */ |
138 | regs->regs[ 4] = signr; | 138 | regs->regs[ 4] = ksig->sig; |
139 | regs->regs[ 5] = (unsigned long) &frame->rs_info; | 139 | regs->regs[ 5] = (unsigned long) &frame->rs_info; |
140 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; | 140 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; |
141 | regs->regs[29] = (unsigned long) frame; | 141 | regs->regs[29] = (unsigned long) frame; |
142 | regs->regs[31] = (unsigned long) sig_return; | 142 | regs->regs[31] = (unsigned long) sig_return; |
143 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; | 143 | regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; |
144 | 144 | ||
145 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", | 145 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
146 | current->comm, current->pid, | 146 | current->comm, current->pid, |
147 | frame, regs->cp0_epc, regs->regs[31]); | 147 | frame, regs->cp0_epc, regs->regs[31]); |
148 | 148 | ||
149 | return 0; | 149 | return 0; |
150 | |||
151 | give_sigsegv: | ||
152 | force_sigsegv(signr, current); | ||
153 | return -EFAULT; | ||
154 | } | 150 | } |
155 | 151 | ||
156 | struct mips_abi mips_abi_n32 = { | 152 | struct mips_abi mips_abi_n32 = { |
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c index 9dfac5cd16e6..a6c0858592c3 100644 --- a/arch/mn10300/kernel/signal.c +++ b/arch/mn10300/kernel/signal.c | |||
@@ -186,20 +186,11 @@ static int setup_sigcontext(struct sigcontext __user *sc, | |||
186 | /* | 186 | /* |
187 | * determine which stack to use.. | 187 | * determine which stack to use.. |
188 | */ | 188 | */ |
189 | static inline void __user *get_sigframe(struct k_sigaction *ka, | 189 | static inline void __user *get_sigframe(struct ksignal *ksig, |
190 | struct pt_regs *regs, | 190 | struct pt_regs *regs, |
191 | size_t frame_size) | 191 | size_t frame_size) |
192 | { | 192 | { |
193 | unsigned long sp; | 193 | unsigned long sp = sigsp(regs->sp, ksig); |
194 | |||
195 | /* default to using normal stack */ | ||
196 | sp = regs->sp; | ||
197 | |||
198 | /* this is the X/Open sanctioned signal stack switching. */ | ||
199 | if (ka->sa.sa_flags & SA_ONSTACK) { | ||
200 | if (sas_ss_flags(sp) == 0) | ||
201 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
202 | } | ||
203 | 194 | ||
204 | return (void __user *) ((sp - frame_size) & ~7UL); | 195 | return (void __user *) ((sp - frame_size) & ~7UL); |
205 | } | 196 | } |
@@ -207,16 +198,16 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, | |||
207 | /* | 198 | /* |
208 | * set up a normal signal frame | 199 | * set up a normal signal frame |
209 | */ | 200 | */ |
210 | static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | 201 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
211 | struct pt_regs *regs) | 202 | struct pt_regs *regs) |
212 | { | 203 | { |
213 | struct sigframe __user *frame; | 204 | struct sigframe __user *frame; |
214 | int rsig; | 205 | int rsig, sig = ksig->sig; |
215 | 206 | ||
216 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 207 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
217 | 208 | ||
218 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 209 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
219 | goto give_sigsegv; | 210 | return -EFAULT; |
220 | 211 | ||
221 | rsig = sig; | 212 | rsig = sig; |
222 | if (sig < 32 && | 213 | if (sig < 32 && |
@@ -226,40 +217,40 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
226 | 217 | ||
227 | if (__put_user(rsig, &frame->sig) < 0 || | 218 | if (__put_user(rsig, &frame->sig) < 0 || |
228 | __put_user(&frame->sc, &frame->psc) < 0) | 219 | __put_user(&frame->sc, &frame->psc) < 0) |
229 | goto give_sigsegv; | 220 | return -EFAULT; |
230 | 221 | ||
231 | if (setup_sigcontext(&frame->sc, &frame->fpuctx, regs, set->sig[0])) | 222 | if (setup_sigcontext(&frame->sc, &frame->fpuctx, regs, set->sig[0])) |
232 | goto give_sigsegv; | 223 | return -EFAULT; |
233 | 224 | ||
234 | if (_NSIG_WORDS > 1) { | 225 | if (_NSIG_WORDS > 1) { |
235 | if (__copy_to_user(frame->extramask, &set->sig[1], | 226 | if (__copy_to_user(frame->extramask, &set->sig[1], |
236 | sizeof(frame->extramask))) | 227 | sizeof(frame->extramask))) |
237 | goto give_sigsegv; | 228 | return -EFAULT; |
238 | } | 229 | } |
239 | 230 | ||
240 | /* set up to return from userspace. If provided, use a stub already in | 231 | /* set up to return from userspace. If provided, use a stub already in |
241 | * userspace */ | 232 | * userspace */ |
242 | if (ka->sa.sa_flags & SA_RESTORER) { | 233 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
243 | if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) | 234 | if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode)) |
244 | goto give_sigsegv; | 235 | return -EFAULT; |
245 | } else { | 236 | } else { |
246 | if (__put_user((void (*)(void))frame->retcode, | 237 | if (__put_user((void (*)(void))frame->retcode, |
247 | &frame->pretcode)) | 238 | &frame->pretcode)) |
248 | goto give_sigsegv; | 239 | return -EFAULT; |
249 | /* this is mov $,d0; syscall 0 */ | 240 | /* this is mov $,d0; syscall 0 */ |
250 | if (__put_user(0x2c, (char *)(frame->retcode + 0)) || | 241 | if (__put_user(0x2c, (char *)(frame->retcode + 0)) || |
251 | __put_user(__NR_sigreturn, (char *)(frame->retcode + 1)) || | 242 | __put_user(__NR_sigreturn, (char *)(frame->retcode + 1)) || |
252 | __put_user(0x00, (char *)(frame->retcode + 2)) || | 243 | __put_user(0x00, (char *)(frame->retcode + 2)) || |
253 | __put_user(0xf0, (char *)(frame->retcode + 3)) || | 244 | __put_user(0xf0, (char *)(frame->retcode + 3)) || |
254 | __put_user(0xe0, (char *)(frame->retcode + 4))) | 245 | __put_user(0xe0, (char *)(frame->retcode + 4))) |
255 | goto give_sigsegv; | 246 | return -EFAULT; |
256 | flush_icache_range((unsigned long) frame->retcode, | 247 | flush_icache_range((unsigned long) frame->retcode, |
257 | (unsigned long) frame->retcode + 5); | 248 | (unsigned long) frame->retcode + 5); |
258 | } | 249 | } |
259 | 250 | ||
260 | /* set up registers for signal handler */ | 251 | /* set up registers for signal handler */ |
261 | regs->sp = (unsigned long) frame; | 252 | regs->sp = (unsigned long) frame; |
262 | regs->pc = (unsigned long) ka->sa.sa_handler; | 253 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
263 | regs->d0 = sig; | 254 | regs->d0 = sig; |
264 | regs->d1 = (unsigned long) &frame->sc; | 255 | regs->d1 = (unsigned long) &frame->sc; |
265 | 256 | ||
@@ -270,25 +261,21 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
270 | #endif | 261 | #endif |
271 | 262 | ||
272 | return 0; | 263 | return 0; |
273 | |||
274 | give_sigsegv: | ||
275 | force_sigsegv(sig, current); | ||
276 | return -EFAULT; | ||
277 | } | 264 | } |
278 | 265 | ||
279 | /* | 266 | /* |
280 | * set up a realtime signal frame | 267 | * set up a realtime signal frame |
281 | */ | 268 | */ |
282 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 269 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
283 | sigset_t *set, struct pt_regs *regs) | 270 | struct pt_regs *regs) |
284 | { | 271 | { |
285 | struct rt_sigframe __user *frame; | 272 | struct rt_sigframe __user *frame; |
286 | int rsig; | 273 | int rsig, sig = ksig->sig; |
287 | 274 | ||
288 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 275 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
289 | 276 | ||
290 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 277 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
291 | goto give_sigsegv; | 278 | return -EFAULT; |
292 | 279 | ||
293 | rsig = sig; | 280 | rsig = sig; |
294 | if (sig < 32 && | 281 | if (sig < 32 && |
@@ -299,8 +286,8 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
299 | if (__put_user(rsig, &frame->sig) || | 286 | if (__put_user(rsig, &frame->sig) || |
300 | __put_user(&frame->info, &frame->pinfo) || | 287 | __put_user(&frame->info, &frame->pinfo) || |
301 | __put_user(&frame->uc, &frame->puc) || | 288 | __put_user(&frame->uc, &frame->puc) || |
302 | copy_siginfo_to_user(&frame->info, info)) | 289 | copy_siginfo_to_user(&frame->info, &ksig->info)) |
303 | goto give_sigsegv; | 290 | return -EFAULT; |
304 | 291 | ||
305 | /* create the ucontext. */ | 292 | /* create the ucontext. */ |
306 | if (__put_user(0, &frame->uc.uc_flags) || | 293 | if (__put_user(0, &frame->uc.uc_flags) || |
@@ -309,13 +296,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
309 | setup_sigcontext(&frame->uc.uc_mcontext, | 296 | setup_sigcontext(&frame->uc.uc_mcontext, |
310 | &frame->fpuctx, regs, set->sig[0]) || | 297 | &frame->fpuctx, regs, set->sig[0]) || |
311 | __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) | 298 | __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) |
312 | goto give_sigsegv; | 299 | return -EFAULT; |
313 | 300 | ||
314 | /* set up to return from userspace. If provided, use a stub already in | 301 | /* set up to return from userspace. If provided, use a stub already in |
315 | * userspace */ | 302 | * userspace */ |
316 | if (ka->sa.sa_flags & SA_RESTORER) { | 303 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
317 | if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) | 304 | if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode)) |
318 | goto give_sigsegv; | 305 | return -EFAULT; |
306 | |||
319 | } else { | 307 | } else { |
320 | if (__put_user((void(*)(void))frame->retcode, | 308 | if (__put_user((void(*)(void))frame->retcode, |
321 | &frame->pretcode) || | 309 | &frame->pretcode) || |
@@ -326,7 +314,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
326 | __put_user(0x00, (char *)(frame->retcode + 2)) || | 314 | __put_user(0x00, (char *)(frame->retcode + 2)) || |
327 | __put_user(0xf0, (char *)(frame->retcode + 3)) || | 315 | __put_user(0xf0, (char *)(frame->retcode + 3)) || |
328 | __put_user(0xe0, (char *)(frame->retcode + 4))) | 316 | __put_user(0xe0, (char *)(frame->retcode + 4))) |
329 | goto give_sigsegv; | 317 | return -EFAULT; |
330 | 318 | ||
331 | flush_icache_range((u_long) frame->retcode, | 319 | flush_icache_range((u_long) frame->retcode, |
332 | (u_long) frame->retcode + 5); | 320 | (u_long) frame->retcode + 5); |
@@ -334,7 +322,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
334 | 322 | ||
335 | /* Set up registers for signal handler */ | 323 | /* Set up registers for signal handler */ |
336 | regs->sp = (unsigned long) frame; | 324 | regs->sp = (unsigned long) frame; |
337 | regs->pc = (unsigned long) ka->sa.sa_handler; | 325 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
338 | regs->d0 = sig; | 326 | regs->d0 = sig; |
339 | regs->d1 = (long) &frame->info; | 327 | regs->d1 = (long) &frame->info; |
340 | 328 | ||
@@ -345,10 +333,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
345 | #endif | 333 | #endif |
346 | 334 | ||
347 | return 0; | 335 | return 0; |
348 | |||
349 | give_sigsegv: | ||
350 | force_sigsegv(sig, current); | ||
351 | return -EFAULT; | ||
352 | } | 336 | } |
353 | 337 | ||
354 | static inline void stepback(struct pt_regs *regs) | 338 | static inline void stepback(struct pt_regs *regs) |
@@ -360,9 +344,7 @@ static inline void stepback(struct pt_regs *regs) | |||
360 | /* | 344 | /* |
361 | * handle the actual delivery of a signal to userspace | 345 | * handle the actual delivery of a signal to userspace |
362 | */ | 346 | */ |
363 | static int handle_signal(int sig, | 347 | static int handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
364 | siginfo_t *info, struct k_sigaction *ka, | ||
365 | struct pt_regs *regs) | ||
366 | { | 348 | { |
367 | sigset_t *oldset = sigmask_to_save(); | 349 | sigset_t *oldset = sigmask_to_save(); |
368 | int ret; | 350 | int ret; |
@@ -377,7 +359,7 @@ static int handle_signal(int sig, | |||
377 | break; | 359 | break; |
378 | 360 | ||
379 | case -ERESTARTSYS: | 361 | case -ERESTARTSYS: |
380 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 362 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
381 | regs->d0 = -EINTR; | 363 | regs->d0 = -EINTR; |
382 | break; | 364 | break; |
383 | } | 365 | } |
@@ -390,15 +372,12 @@ static int handle_signal(int sig, | |||
390 | } | 372 | } |
391 | 373 | ||
392 | /* Set up the stack frame */ | 374 | /* Set up the stack frame */ |
393 | if (ka->sa.sa_flags & SA_SIGINFO) | 375 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
394 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 376 | ret = setup_rt_frame(ksig, oldset, regs); |
395 | else | 377 | else |
396 | ret = setup_frame(sig, ka, oldset, regs); | 378 | ret = setup_frame(ksig, oldset, regs); |
397 | if (ret) | ||
398 | return ret; | ||
399 | 379 | ||
400 | signal_delivered(sig, info, ka, regs, | 380 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
401 | test_thread_flag(TIF_SINGLESTEP)); | ||
402 | return 0; | 381 | return 0; |
403 | } | 382 | } |
404 | 383 | ||
@@ -407,15 +386,10 @@ static int handle_signal(int sig, | |||
407 | */ | 386 | */ |
408 | static void do_signal(struct pt_regs *regs) | 387 | static void do_signal(struct pt_regs *regs) |
409 | { | 388 | { |
410 | struct k_sigaction ka; | 389 | struct ksignal ksig; |
411 | siginfo_t info; | ||
412 | int signr; | ||
413 | |||
414 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | ||
415 | if (signr > 0) { | ||
416 | if (handle_signal(signr, &info, &ka, regs) == 0) { | ||
417 | } | ||
418 | 390 | ||
391 | if (get_signal(&ksig)) { | ||
392 | handle_signal(&ksig, regs); | ||
419 | return; | 393 | return; |
420 | } | 394 | } |
421 | 395 | ||
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c index 66775bc07a8e..7d1b8235bf90 100644 --- a/arch/openrisc/kernel/signal.c +++ b/arch/openrisc/kernel/signal.c | |||
@@ -132,30 +132,16 @@ static inline unsigned long align_sigframe(unsigned long sp) | |||
132 | * or the alternate stack. | 132 | * or the alternate stack. |
133 | */ | 133 | */ |
134 | 134 | ||
135 | static inline void __user *get_sigframe(struct k_sigaction *ka, | 135 | static inline void __user *get_sigframe(struct ksignal *ksig, |
136 | struct pt_regs *regs, size_t frame_size) | 136 | struct pt_regs *regs, size_t frame_size) |
137 | { | 137 | { |
138 | unsigned long sp = regs->sp; | 138 | unsigned long sp = regs->sp; |
139 | int onsigstack = on_sig_stack(sp); | ||
140 | 139 | ||
141 | /* redzone */ | 140 | /* redzone */ |
142 | sp -= STACK_FRAME_OVERHEAD; | 141 | sp -= STACK_FRAME_OVERHEAD; |
143 | 142 | sp = sigsp(sp, ksig); | |
144 | /* This is the X/Open sanctioned signal stack switching. */ | ||
145 | if ((ka->sa.sa_flags & SA_ONSTACK) && !onsigstack) { | ||
146 | if (current->sas_ss_size) | ||
147 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
148 | } | ||
149 | |||
150 | sp = align_sigframe(sp - frame_size); | 143 | sp = align_sigframe(sp - frame_size); |
151 | 144 | ||
152 | /* | ||
153 | * If we are on the alternate signal stack and would overflow it, don't. | ||
154 | * Return an always-bogus address instead so we will die with SIGSEGV. | ||
155 | */ | ||
156 | if (onsigstack && !likely(on_sig_stack(sp))) | ||
157 | return (void __user *)-1L; | ||
158 | |||
159 | return (void __user *)sp; | 145 | return (void __user *)sp; |
160 | } | 146 | } |
161 | 147 | ||
@@ -173,7 +159,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, | |||
173 | unsigned long return_ip; | 159 | unsigned long return_ip; |
174 | int err = 0; | 160 | int err = 0; |
175 | 161 | ||
176 | frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); | 162 | frame = get_sigframe(ksig, regs, sizeof(*frame)); |
177 | 163 | ||
178 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 164 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
179 | return -EFAULT; | 165 | return -EFAULT; |
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index 1cba8f29bb49..012d4fa63d97 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c | |||
@@ -227,8 +227,8 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, int in_sysc | |||
227 | } | 227 | } |
228 | 228 | ||
229 | static long | 229 | static long |
230 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 230 | setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs, |
231 | sigset_t *set, struct pt_regs *regs, int in_syscall) | 231 | int in_syscall) |
232 | { | 232 | { |
233 | struct rt_sigframe __user *frame; | 233 | struct rt_sigframe __user *frame; |
234 | unsigned long rp, usp; | 234 | unsigned long rp, usp; |
@@ -241,10 +241,10 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
241 | 241 | ||
242 | usp = (regs->gr[30] & ~(0x01UL)); | 242 | usp = (regs->gr[30] & ~(0x01UL)); |
243 | /*FIXME: frame_size parameter is unused, remove it. */ | 243 | /*FIXME: frame_size parameter is unused, remove it. */ |
244 | frame = get_sigframe(ka, usp, sizeof(*frame)); | 244 | frame = get_sigframe(&ksig->ka, usp, sizeof(*frame)); |
245 | 245 | ||
246 | DBG(1,"SETUP_RT_FRAME: START\n"); | 246 | DBG(1,"SETUP_RT_FRAME: START\n"); |
247 | DBG(1,"setup_rt_frame: frame %p info %p\n", frame, info); | 247 | DBG(1,"setup_rt_frame: frame %p info %p\n", frame, ksig->info); |
248 | 248 | ||
249 | 249 | ||
250 | #ifdef CONFIG_64BIT | 250 | #ifdef CONFIG_64BIT |
@@ -253,7 +253,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
253 | 253 | ||
254 | if (is_compat_task()) { | 254 | if (is_compat_task()) { |
255 | DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); | 255 | DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); |
256 | err |= copy_siginfo_to_user32(&compat_frame->info, info); | 256 | err |= copy_siginfo_to_user32(&compat_frame->info, &ksig->info); |
257 | err |= __compat_save_altstack( &compat_frame->uc.uc_stack, regs->gr[30]); | 257 | err |= __compat_save_altstack( &compat_frame->uc.uc_stack, regs->gr[30]); |
258 | DBG(1,"setup_rt_frame: frame->uc = 0x%p\n", &compat_frame->uc); | 258 | DBG(1,"setup_rt_frame: frame->uc = 0x%p\n", &compat_frame->uc); |
259 | DBG(1,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n", &compat_frame->uc.uc_mcontext); | 259 | DBG(1,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n", &compat_frame->uc.uc_mcontext); |
@@ -265,7 +265,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
265 | #endif | 265 | #endif |
266 | { | 266 | { |
267 | DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &frame->info); | 267 | DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &frame->info); |
268 | err |= copy_siginfo_to_user(&frame->info, info); | 268 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
269 | err |= __save_altstack(&frame->uc.uc_stack, regs->gr[30]); | 269 | err |= __save_altstack(&frame->uc.uc_stack, regs->gr[30]); |
270 | DBG(1,"setup_rt_frame: frame->uc = 0x%p\n", &frame->uc); | 270 | DBG(1,"setup_rt_frame: frame->uc = 0x%p\n", &frame->uc); |
271 | DBG(1,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n", &frame->uc.uc_mcontext); | 271 | DBG(1,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n", &frame->uc.uc_mcontext); |
@@ -275,7 +275,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
275 | } | 275 | } |
276 | 276 | ||
277 | if (err) | 277 | if (err) |
278 | goto give_sigsegv; | 278 | return -EFAULT; |
279 | 279 | ||
280 | /* Set up to return from userspace. If provided, use a stub | 280 | /* Set up to return from userspace. If provided, use a stub |
281 | already in userspace. The first words of tramp are used to | 281 | already in userspace. The first words of tramp are used to |
@@ -312,9 +312,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
312 | rp = (unsigned long) &frame->tramp[SIGRESTARTBLOCK_TRAMP]; | 312 | rp = (unsigned long) &frame->tramp[SIGRESTARTBLOCK_TRAMP]; |
313 | 313 | ||
314 | if (err) | 314 | if (err) |
315 | goto give_sigsegv; | 315 | return -EFAULT; |
316 | 316 | ||
317 | haddr = A(ka->sa.sa_handler); | 317 | haddr = A(ksig->ka.sa.sa_handler); |
318 | /* The sa_handler may be a pointer to a function descriptor */ | 318 | /* The sa_handler may be a pointer to a function descriptor */ |
319 | #ifdef CONFIG_64BIT | 319 | #ifdef CONFIG_64BIT |
320 | if (is_compat_task()) { | 320 | if (is_compat_task()) { |
@@ -326,7 +326,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
326 | err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); | 326 | err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); |
327 | 327 | ||
328 | if (err) | 328 | if (err) |
329 | goto give_sigsegv; | 329 | return -EFAULT; |
330 | 330 | ||
331 | haddr = fdesc.addr; | 331 | haddr = fdesc.addr; |
332 | regs->gr[19] = fdesc.gp; | 332 | regs->gr[19] = fdesc.gp; |
@@ -339,7 +339,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
339 | err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); | 339 | err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); |
340 | 340 | ||
341 | if (err) | 341 | if (err) |
342 | goto give_sigsegv; | 342 | return -EFAULT; |
343 | 343 | ||
344 | haddr = fdesc.addr; | 344 | haddr = fdesc.addr; |
345 | regs->gr[19] = fdesc.gp; | 345 | regs->gr[19] = fdesc.gp; |
@@ -386,7 +386,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
386 | } | 386 | } |
387 | 387 | ||
388 | regs->gr[2] = rp; /* userland return pointer */ | 388 | regs->gr[2] = rp; /* userland return pointer */ |
389 | regs->gr[26] = sig; /* signal number */ | 389 | regs->gr[26] = ksig->sig; /* signal number */ |
390 | 390 | ||
391 | #ifdef CONFIG_64BIT | 391 | #ifdef CONFIG_64BIT |
392 | if (is_compat_task()) { | 392 | if (is_compat_task()) { |
@@ -410,11 +410,6 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
410 | current->comm, current->pid, frame, regs->gr[30], | 410 | current->comm, current->pid, frame, regs->gr[30], |
411 | regs->iaoq[0], regs->iaoq[1], rp); | 411 | regs->iaoq[0], regs->iaoq[1], rp); |
412 | 412 | ||
413 | return 1; | ||
414 | |||
415 | give_sigsegv: | ||
416 | DBG(1,"setup_rt_frame: sending SIGSEGV\n"); | ||
417 | force_sigsegv(sig, current); | ||
418 | return 0; | 413 | return 0; |
419 | } | 414 | } |
420 | 415 | ||
@@ -423,20 +418,19 @@ give_sigsegv: | |||
423 | */ | 418 | */ |
424 | 419 | ||
425 | static void | 420 | static void |
426 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 421 | handle_signal(struct ksignal *ksig, struct pt_regs *regs, int in_syscall) |
427 | struct pt_regs *regs, int in_syscall) | ||
428 | { | 422 | { |
423 | int ret; | ||
429 | sigset_t *oldset = sigmask_to_save(); | 424 | sigset_t *oldset = sigmask_to_save(); |
425 | |||
430 | DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n", | 426 | DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n", |
431 | sig, ka, info, oldset, regs); | 427 | ksig->sig, ksig->ka, ksig->info, oldset, regs); |
432 | 428 | ||
433 | /* Set up the stack frame */ | 429 | /* Set up the stack frame */ |
434 | if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall)) | 430 | ret = setup_rt_frame(ksig, oldset, regs, in_syscall); |
435 | return; | ||
436 | 431 | ||
437 | signal_delivered(sig, info, ka, regs, | 432 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP) || |
438 | test_thread_flag(TIF_SINGLESTEP) || | 433 | test_thread_flag(TIF_BLOCKSTEP)); |
439 | test_thread_flag(TIF_BLOCKSTEP)); | ||
440 | 434 | ||
441 | DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n", | 435 | DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n", |
442 | regs->gr[28]); | 436 | regs->gr[28]); |
@@ -544,22 +538,18 @@ insert_restart_trampoline(struct pt_regs *regs) | |||
544 | asmlinkage void | 538 | asmlinkage void |
545 | do_signal(struct pt_regs *regs, long in_syscall) | 539 | do_signal(struct pt_regs *regs, long in_syscall) |
546 | { | 540 | { |
547 | siginfo_t info; | 541 | struct ksignal ksig; |
548 | struct k_sigaction ka; | ||
549 | int signr; | ||
550 | 542 | ||
551 | DBG(1,"\ndo_signal: regs=0x%p, sr7 %#lx, in_syscall=%d\n", | 543 | DBG(1,"\ndo_signal: regs=0x%p, sr7 %#lx, in_syscall=%d\n", |
552 | regs, regs->sr[7], in_syscall); | 544 | regs, regs->sr[7], in_syscall); |
553 | 545 | ||
554 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 546 | if (get_signal(&ksig)) { |
555 | DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); | 547 | DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); |
556 | |||
557 | if (signr > 0) { | ||
558 | /* Restart a system call if necessary. */ | 548 | /* Restart a system call if necessary. */ |
559 | if (in_syscall) | 549 | if (in_syscall) |
560 | syscall_restart(regs, &ka); | 550 | syscall_restart(regs, &ksig.ka); |
561 | 551 | ||
562 | handle_signal(signr, &info, &ka, regs, in_syscall); | 552 | handle_signal(&ksig, regs, in_syscall); |
563 | return; | 553 | return; |
564 | } | 554 | } |
565 | 555 | ||
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c index 1c794cef2883..cf8c7e4e0b21 100644 --- a/arch/powerpc/kernel/signal.c +++ b/arch/powerpc/kernel/signal.c | |||
@@ -31,20 +31,14 @@ int show_unhandled_signals = 1; | |||
31 | /* | 31 | /* |
32 | * Allocate space for the signal frame | 32 | * Allocate space for the signal frame |
33 | */ | 33 | */ |
34 | void __user * get_sigframe(struct k_sigaction *ka, unsigned long sp, | 34 | void __user *get_sigframe(struct ksignal *ksig, unsigned long sp, |
35 | size_t frame_size, int is_32) | 35 | size_t frame_size, int is_32) |
36 | { | 36 | { |
37 | unsigned long oldsp, newsp; | 37 | unsigned long oldsp, newsp; |
38 | 38 | ||
39 | /* Default to using normal stack */ | 39 | /* Default to using normal stack */ |
40 | oldsp = get_clean_sp(sp, is_32); | 40 | oldsp = get_clean_sp(sp, is_32); |
41 | 41 | oldsp = sigsp(oldsp, ksig); | |
42 | /* Check for alt stack */ | ||
43 | if ((ka->sa.sa_flags & SA_ONSTACK) && | ||
44 | current->sas_ss_size && !on_sig_stack(oldsp)) | ||
45 | oldsp = (current->sas_ss_sp + current->sas_ss_size); | ||
46 | |||
47 | /* Get aligned frame */ | ||
48 | newsp = (oldsp - frame_size) & ~0xFUL; | 42 | newsp = (oldsp - frame_size) & ~0xFUL; |
49 | 43 | ||
50 | /* Check access */ | 44 | /* Check access */ |
@@ -105,25 +99,23 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka, | |||
105 | } | 99 | } |
106 | } | 100 | } |
107 | 101 | ||
108 | static int do_signal(struct pt_regs *regs) | 102 | static void do_signal(struct pt_regs *regs) |
109 | { | 103 | { |
110 | sigset_t *oldset = sigmask_to_save(); | 104 | sigset_t *oldset = sigmask_to_save(); |
111 | siginfo_t info; | 105 | struct ksignal ksig; |
112 | int signr; | ||
113 | struct k_sigaction ka; | ||
114 | int ret; | 106 | int ret; |
115 | int is32 = is_32bit_task(); | 107 | int is32 = is_32bit_task(); |
116 | 108 | ||
117 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 109 | get_signal(&ksig); |
118 | 110 | ||
119 | /* Is there any syscall restart business here ? */ | 111 | /* Is there any syscall restart business here ? */ |
120 | check_syscall_restart(regs, &ka, signr > 0); | 112 | check_syscall_restart(regs, &ksig.ka, ksig.sig > 0); |
121 | 113 | ||
122 | if (signr <= 0) { | 114 | if (ksig.sig <= 0) { |
123 | /* No signal to deliver -- put the saved sigmask back */ | 115 | /* No signal to deliver -- put the saved sigmask back */ |
124 | restore_saved_sigmask(); | 116 | restore_saved_sigmask(); |
125 | regs->trap = 0; | 117 | regs->trap = 0; |
126 | return 0; /* no signals delivered */ | 118 | return; /* no signals delivered */ |
127 | } | 119 | } |
128 | 120 | ||
129 | #ifndef CONFIG_PPC_ADV_DEBUG_REGS | 121 | #ifndef CONFIG_PPC_ADV_DEBUG_REGS |
@@ -140,23 +132,16 @@ static int do_signal(struct pt_regs *regs) | |||
140 | thread_change_pc(current, regs); | 132 | thread_change_pc(current, regs); |
141 | 133 | ||
142 | if (is32) { | 134 | if (is32) { |
143 | if (ka.sa.sa_flags & SA_SIGINFO) | 135 | if (ksig.ka.sa.sa_flags & SA_SIGINFO) |
144 | ret = handle_rt_signal32(signr, &ka, &info, oldset, | 136 | ret = handle_rt_signal32(&ksig, oldset, regs); |
145 | regs); | ||
146 | else | 137 | else |
147 | ret = handle_signal32(signr, &ka, &info, oldset, | 138 | ret = handle_signal32(&ksig, oldset, regs); |
148 | regs); | ||
149 | } else { | 139 | } else { |
150 | ret = handle_rt_signal64(signr, &ka, &info, oldset, regs); | 140 | ret = handle_rt_signal64(&ksig, oldset, regs); |
151 | } | 141 | } |
152 | 142 | ||
153 | regs->trap = 0; | 143 | regs->trap = 0; |
154 | if (ret) { | 144 | signal_setup_done(ret, &ksig, test_thread_flag(TIF_SINGLESTEP)); |
155 | signal_delivered(signr, &info, &ka, regs, | ||
156 | test_thread_flag(TIF_SINGLESTEP)); | ||
157 | } | ||
158 | |||
159 | return ret; | ||
160 | } | 145 | } |
161 | 146 | ||
162 | void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) | 147 | void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) |
diff --git a/arch/powerpc/kernel/signal.h b/arch/powerpc/kernel/signal.h index c69b9aeb9f23..51b274199dd9 100644 --- a/arch/powerpc/kernel/signal.h +++ b/arch/powerpc/kernel/signal.h | |||
@@ -12,15 +12,13 @@ | |||
12 | 12 | ||
13 | extern void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags); | 13 | extern void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags); |
14 | 14 | ||
15 | extern void __user * get_sigframe(struct k_sigaction *ka, unsigned long sp, | 15 | extern void __user *get_sigframe(struct ksignal *ksig, unsigned long sp, |
16 | size_t frame_size, int is_32); | 16 | size_t frame_size, int is_32); |
17 | 17 | ||
18 | extern int handle_signal32(unsigned long sig, struct k_sigaction *ka, | 18 | extern int handle_signal32(struct ksignal *ksig, sigset_t *oldset, |
19 | siginfo_t *info, sigset_t *oldset, | ||
20 | struct pt_regs *regs); | 19 | struct pt_regs *regs); |
21 | 20 | ||
22 | extern int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, | 21 | extern int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, |
23 | siginfo_t *info, sigset_t *oldset, | ||
24 | struct pt_regs *regs); | 22 | struct pt_regs *regs); |
25 | 23 | ||
26 | extern unsigned long copy_fpr_to_user(void __user *to, | 24 | extern unsigned long copy_fpr_to_user(void __user *to, |
@@ -44,14 +42,12 @@ extern unsigned long copy_transact_vsx_from_user(struct task_struct *task, | |||
44 | 42 | ||
45 | #ifdef CONFIG_PPC64 | 43 | #ifdef CONFIG_PPC64 |
46 | 44 | ||
47 | extern int handle_rt_signal64(int signr, struct k_sigaction *ka, | 45 | extern int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, |
48 | siginfo_t *info, sigset_t *set, | ||
49 | struct pt_regs *regs); | 46 | struct pt_regs *regs); |
50 | 47 | ||
51 | #else /* CONFIG_PPC64 */ | 48 | #else /* CONFIG_PPC64 */ |
52 | 49 | ||
53 | static inline int handle_rt_signal64(int signr, struct k_sigaction *ka, | 50 | static inline int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, |
54 | siginfo_t *info, sigset_t *set, | ||
55 | struct pt_regs *regs) | 51 | struct pt_regs *regs) |
56 | { | 52 | { |
57 | return -EFAULT; | 53 | return -EFAULT; |
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index 1bc5a1755ed4..b171001698ff 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c | |||
@@ -981,9 +981,8 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from) | |||
981 | * Set up a signal frame for a "real-time" signal handler | 981 | * Set up a signal frame for a "real-time" signal handler |
982 | * (one which gets siginfo). | 982 | * (one which gets siginfo). |
983 | */ | 983 | */ |
984 | int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, | 984 | int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, |
985 | siginfo_t *info, sigset_t *oldset, | 985 | struct pt_regs *regs) |
986 | struct pt_regs *regs) | ||
987 | { | 986 | { |
988 | struct rt_sigframe __user *rt_sf; | 987 | struct rt_sigframe __user *rt_sf; |
989 | struct mcontext __user *frame; | 988 | struct mcontext __user *frame; |
@@ -995,13 +994,13 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, | |||
995 | 994 | ||
996 | /* Set up Signal Frame */ | 995 | /* Set up Signal Frame */ |
997 | /* Put a Real Time Context onto stack */ | 996 | /* Put a Real Time Context onto stack */ |
998 | rt_sf = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*rt_sf), 1); | 997 | rt_sf = get_sigframe(ksig, get_tm_stackpointer(regs), sizeof(*rt_sf), 1); |
999 | addr = rt_sf; | 998 | addr = rt_sf; |
1000 | if (unlikely(rt_sf == NULL)) | 999 | if (unlikely(rt_sf == NULL)) |
1001 | goto badframe; | 1000 | goto badframe; |
1002 | 1001 | ||
1003 | /* Put the siginfo & fill in most of the ucontext */ | 1002 | /* Put the siginfo & fill in most of the ucontext */ |
1004 | if (copy_siginfo_to_user(&rt_sf->info, info) | 1003 | if (copy_siginfo_to_user(&rt_sf->info, &ksig->info) |
1005 | || __put_user(0, &rt_sf->uc.uc_flags) | 1004 | || __put_user(0, &rt_sf->uc.uc_flags) |
1006 | || __save_altstack(&rt_sf->uc.uc_stack, regs->gpr[1]) | 1005 | || __save_altstack(&rt_sf->uc.uc_stack, regs->gpr[1]) |
1007 | || __put_user(to_user_ptr(&rt_sf->uc.uc_mcontext), | 1006 | || __put_user(to_user_ptr(&rt_sf->uc.uc_mcontext), |
@@ -1051,15 +1050,15 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, | |||
1051 | 1050 | ||
1052 | /* Fill registers for signal handler */ | 1051 | /* Fill registers for signal handler */ |
1053 | regs->gpr[1] = newsp; | 1052 | regs->gpr[1] = newsp; |
1054 | regs->gpr[3] = sig; | 1053 | regs->gpr[3] = ksig->sig; |
1055 | regs->gpr[4] = (unsigned long) &rt_sf->info; | 1054 | regs->gpr[4] = (unsigned long) &rt_sf->info; |
1056 | regs->gpr[5] = (unsigned long) &rt_sf->uc; | 1055 | regs->gpr[5] = (unsigned long) &rt_sf->uc; |
1057 | regs->gpr[6] = (unsigned long) rt_sf; | 1056 | regs->gpr[6] = (unsigned long) rt_sf; |
1058 | regs->nip = (unsigned long) ka->sa.sa_handler; | 1057 | regs->nip = (unsigned long) ksig->ka.sa.sa_handler; |
1059 | /* enter the signal handler in native-endian mode */ | 1058 | /* enter the signal handler in native-endian mode */ |
1060 | regs->msr &= ~MSR_LE; | 1059 | regs->msr &= ~MSR_LE; |
1061 | regs->msr |= (MSR_KERNEL & MSR_LE); | 1060 | regs->msr |= (MSR_KERNEL & MSR_LE); |
1062 | return 1; | 1061 | return 0; |
1063 | 1062 | ||
1064 | badframe: | 1063 | badframe: |
1065 | if (show_unhandled_signals) | 1064 | if (show_unhandled_signals) |
@@ -1069,8 +1068,7 @@ badframe: | |||
1069 | current->comm, current->pid, | 1068 | current->comm, current->pid, |
1070 | addr, regs->nip, regs->link); | 1069 | addr, regs->nip, regs->link); |
1071 | 1070 | ||
1072 | force_sigsegv(sig, current); | 1071 | return 1; |
1073 | return 0; | ||
1074 | } | 1072 | } |
1075 | 1073 | ||
1076 | static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int sig) | 1074 | static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int sig) |
@@ -1409,8 +1407,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx, | |||
1409 | /* | 1407 | /* |
1410 | * OK, we're invoking a handler | 1408 | * OK, we're invoking a handler |
1411 | */ | 1409 | */ |
1412 | int handle_signal32(unsigned long sig, struct k_sigaction *ka, | 1410 | int handle_signal32(struct ksignal *ksig, sigset_t *oldset, struct pt_regs *regs) |
1413 | siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) | ||
1414 | { | 1411 | { |
1415 | struct sigcontext __user *sc; | 1412 | struct sigcontext __user *sc; |
1416 | struct sigframe __user *frame; | 1413 | struct sigframe __user *frame; |
@@ -1420,7 +1417,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka, | |||
1420 | unsigned long tramp; | 1417 | unsigned long tramp; |
1421 | 1418 | ||
1422 | /* Set up Signal Frame */ | 1419 | /* Set up Signal Frame */ |
1423 | frame = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*frame), 1); | 1420 | frame = get_sigframe(ksig, get_tm_stackpointer(regs), sizeof(*frame), 1); |
1424 | if (unlikely(frame == NULL)) | 1421 | if (unlikely(frame == NULL)) |
1425 | goto badframe; | 1422 | goto badframe; |
1426 | sc = (struct sigcontext __user *) &frame->sctx; | 1423 | sc = (struct sigcontext __user *) &frame->sctx; |
@@ -1428,7 +1425,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka, | |||
1428 | #if _NSIG != 64 | 1425 | #if _NSIG != 64 |
1429 | #error "Please adjust handle_signal()" | 1426 | #error "Please adjust handle_signal()" |
1430 | #endif | 1427 | #endif |
1431 | if (__put_user(to_user_ptr(ka->sa.sa_handler), &sc->handler) | 1428 | if (__put_user(to_user_ptr(ksig->ka.sa.sa_handler), &sc->handler) |
1432 | || __put_user(oldset->sig[0], &sc->oldmask) | 1429 | || __put_user(oldset->sig[0], &sc->oldmask) |
1433 | #ifdef CONFIG_PPC64 | 1430 | #ifdef CONFIG_PPC64 |
1434 | || __put_user((oldset->sig[0] >> 32), &sc->_unused[3]) | 1431 | || __put_user((oldset->sig[0] >> 32), &sc->_unused[3]) |
@@ -1436,7 +1433,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka, | |||
1436 | || __put_user(oldset->sig[1], &sc->_unused[3]) | 1433 | || __put_user(oldset->sig[1], &sc->_unused[3]) |
1437 | #endif | 1434 | #endif |
1438 | || __put_user(to_user_ptr(&frame->mctx), &sc->regs) | 1435 | || __put_user(to_user_ptr(&frame->mctx), &sc->regs) |
1439 | || __put_user(sig, &sc->signal)) | 1436 | || __put_user(ksig->sig, &sc->signal)) |
1440 | goto badframe; | 1437 | goto badframe; |
1441 | 1438 | ||
1442 | if (vdso32_sigtramp && current->mm->context.vdso_base) { | 1439 | if (vdso32_sigtramp && current->mm->context.vdso_base) { |
@@ -1471,12 +1468,12 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka, | |||
1471 | goto badframe; | 1468 | goto badframe; |
1472 | 1469 | ||
1473 | regs->gpr[1] = newsp; | 1470 | regs->gpr[1] = newsp; |
1474 | regs->gpr[3] = sig; | 1471 | regs->gpr[3] = ksig->sig; |
1475 | regs->gpr[4] = (unsigned long) sc; | 1472 | regs->gpr[4] = (unsigned long) sc; |
1476 | regs->nip = (unsigned long) ka->sa.sa_handler; | 1473 | regs->nip = (unsigned long) (unsigned long)ksig->ka.sa.sa_handler; |
1477 | /* enter the signal handler in big-endian mode */ | 1474 | /* enter the signal handler in big-endian mode */ |
1478 | regs->msr &= ~MSR_LE; | 1475 | regs->msr &= ~MSR_LE; |
1479 | return 1; | 1476 | return 0; |
1480 | 1477 | ||
1481 | badframe: | 1478 | badframe: |
1482 | if (show_unhandled_signals) | 1479 | if (show_unhandled_signals) |
@@ -1486,8 +1483,7 @@ badframe: | |||
1486 | current->comm, current->pid, | 1483 | current->comm, current->pid, |
1487 | frame, regs->nip, regs->link); | 1484 | frame, regs->nip, regs->link); |
1488 | 1485 | ||
1489 | force_sigsegv(sig, current); | 1486 | return 1; |
1490 | return 0; | ||
1491 | } | 1487 | } |
1492 | 1488 | ||
1493 | /* | 1489 | /* |
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 97c1e4b683fc..2cb0c94cafa5 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c | |||
@@ -708,20 +708,19 @@ badframe: | |||
708 | return 0; | 708 | return 0; |
709 | } | 709 | } |
710 | 710 | ||
711 | int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | 711 | int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
712 | sigset_t *set, struct pt_regs *regs) | ||
713 | { | 712 | { |
714 | struct rt_sigframe __user *frame; | 713 | struct rt_sigframe __user *frame; |
715 | unsigned long newsp = 0; | 714 | unsigned long newsp = 0; |
716 | long err = 0; | 715 | long err = 0; |
717 | 716 | ||
718 | frame = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*frame), 0); | 717 | frame = get_sigframe(ksig, get_tm_stackpointer(regs), sizeof(*frame), 0); |
719 | if (unlikely(frame == NULL)) | 718 | if (unlikely(frame == NULL)) |
720 | goto badframe; | 719 | goto badframe; |
721 | 720 | ||
722 | err |= __put_user(&frame->info, &frame->pinfo); | 721 | err |= __put_user(&frame->info, &frame->pinfo); |
723 | err |= __put_user(&frame->uc, &frame->puc); | 722 | err |= __put_user(&frame->uc, &frame->puc); |
724 | err |= copy_siginfo_to_user(&frame->info, info); | 723 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
725 | if (err) | 724 | if (err) |
726 | goto badframe; | 725 | goto badframe; |
727 | 726 | ||
@@ -736,15 +735,15 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
736 | err |= __put_user(&frame->uc_transact, &frame->uc.uc_link); | 735 | err |= __put_user(&frame->uc_transact, &frame->uc.uc_link); |
737 | err |= setup_tm_sigcontexts(&frame->uc.uc_mcontext, | 736 | err |= setup_tm_sigcontexts(&frame->uc.uc_mcontext, |
738 | &frame->uc_transact.uc_mcontext, | 737 | &frame->uc_transact.uc_mcontext, |
739 | regs, signr, | 738 | regs, ksig->sig, |
740 | NULL, | 739 | NULL, |
741 | (unsigned long)ka->sa.sa_handler); | 740 | (unsigned long)ksig->ka.sa.sa_handler); |
742 | } else | 741 | } else |
743 | #endif | 742 | #endif |
744 | { | 743 | { |
745 | err |= __put_user(0, &frame->uc.uc_link); | 744 | err |= __put_user(0, &frame->uc.uc_link); |
746 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, signr, | 745 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, ksig->sig, |
747 | NULL, (unsigned long)ka->sa.sa_handler, | 746 | NULL, (unsigned long)ksig->ka.sa.sa_handler, |
748 | 1); | 747 | 1); |
749 | } | 748 | } |
750 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 749 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
@@ -770,7 +769,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
770 | 769 | ||
771 | /* Set up "regs" so we "return" to the signal handler. */ | 770 | /* Set up "regs" so we "return" to the signal handler. */ |
772 | if (is_elf2_task()) { | 771 | if (is_elf2_task()) { |
773 | regs->nip = (unsigned long) ka->sa.sa_handler; | 772 | regs->nip = (unsigned long) ksig->ka.sa.sa_handler; |
774 | regs->gpr[12] = regs->nip; | 773 | regs->gpr[12] = regs->nip; |
775 | } else { | 774 | } else { |
776 | /* Handler is *really* a pointer to the function descriptor for | 775 | /* Handler is *really* a pointer to the function descriptor for |
@@ -779,7 +778,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
779 | * entry is the TOC value we need to use. | 778 | * entry is the TOC value we need to use. |
780 | */ | 779 | */ |
781 | func_descr_t __user *funct_desc_ptr = | 780 | func_descr_t __user *funct_desc_ptr = |
782 | (func_descr_t __user *) ka->sa.sa_handler; | 781 | (func_descr_t __user *) ksig->ka.sa.sa_handler; |
783 | 782 | ||
784 | err |= get_user(regs->nip, &funct_desc_ptr->entry); | 783 | err |= get_user(regs->nip, &funct_desc_ptr->entry); |
785 | err |= get_user(regs->gpr[2], &funct_desc_ptr->toc); | 784 | err |= get_user(regs->gpr[2], &funct_desc_ptr->toc); |
@@ -789,9 +788,9 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
789 | regs->msr &= ~MSR_LE; | 788 | regs->msr &= ~MSR_LE; |
790 | regs->msr |= (MSR_KERNEL & MSR_LE); | 789 | regs->msr |= (MSR_KERNEL & MSR_LE); |
791 | regs->gpr[1] = newsp; | 790 | regs->gpr[1] = newsp; |
792 | regs->gpr[3] = signr; | 791 | regs->gpr[3] = ksig->sig; |
793 | regs->result = 0; | 792 | regs->result = 0; |
794 | if (ka->sa.sa_flags & SA_SIGINFO) { | 793 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
795 | err |= get_user(regs->gpr[4], (unsigned long __user *)&frame->pinfo); | 794 | err |= get_user(regs->gpr[4], (unsigned long __user *)&frame->pinfo); |
796 | err |= get_user(regs->gpr[5], (unsigned long __user *)&frame->puc); | 795 | err |= get_user(regs->gpr[5], (unsigned long __user *)&frame->puc); |
797 | regs->gpr[6] = (unsigned long) frame; | 796 | regs->gpr[6] = (unsigned long) frame; |
@@ -801,7 +800,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, | |||
801 | if (err) | 800 | if (err) |
802 | goto badframe; | 801 | goto badframe; |
803 | 802 | ||
804 | return 1; | 803 | return 0; |
805 | 804 | ||
806 | badframe: | 805 | badframe: |
807 | if (show_unhandled_signals) | 806 | if (show_unhandled_signals) |
@@ -809,6 +808,5 @@ badframe: | |||
809 | current->comm, current->pid, "setup_rt_frame", | 808 | current->comm, current->pid, "setup_rt_frame", |
810 | (long)frame, regs->nip, regs->link); | 809 | (long)frame, regs->nip, regs->link); |
811 | 810 | ||
812 | force_sigsegv(signr, current); | 811 | return 1; |
813 | return 0; | ||
814 | } | 812 | } |
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c index f204d6920368..598b0b42668b 100644 --- a/arch/s390/kernel/compat_signal.c +++ b/arch/s390/kernel/compat_signal.c | |||
@@ -320,38 +320,39 @@ static inline int map_signal(int sig) | |||
320 | return sig; | 320 | return sig; |
321 | } | 321 | } |
322 | 322 | ||
323 | static int setup_frame32(int sig, struct k_sigaction *ka, | 323 | static int setup_frame32(struct ksignal *ksig, sigset_t *set, |
324 | sigset_t *set, struct pt_regs * regs) | 324 | struct pt_regs *regs) |
325 | { | 325 | { |
326 | sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(sigframe32)); | 326 | int sig = ksig->sig; |
327 | sigframe32 __user *frame = get_sigframe(&ksig->ka, regs, sizeof(sigframe32)); | ||
327 | 328 | ||
328 | if (frame == (void __user *) -1UL) | 329 | if (frame == (void __user *) -1UL) |
329 | goto give_sigsegv; | 330 | return -EFAULT; |
330 | 331 | ||
331 | if (__copy_to_user(&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE32)) | 332 | if (__copy_to_user(&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE32)) |
332 | goto give_sigsegv; | 333 | return -EFAULT; |
333 | 334 | ||
334 | if (save_sigregs32(regs, &frame->sregs)) | 335 | if (save_sigregs32(regs, &frame->sregs)) |
335 | goto give_sigsegv; | 336 | return -EFAULT; |
336 | if (save_sigregs_gprs_high(regs, frame->gprs_high)) | 337 | if (save_sigregs_gprs_high(regs, frame->gprs_high)) |
337 | goto give_sigsegv; | 338 | return -EFAULT; |
338 | if (__put_user((unsigned long) &frame->sregs, &frame->sc.sregs)) | 339 | if (__put_user((unsigned long) &frame->sregs, &frame->sc.sregs)) |
339 | goto give_sigsegv; | 340 | return -EFAULT; |
340 | 341 | ||
341 | /* Set up to return from userspace. If provided, use a stub | 342 | /* Set up to return from userspace. If provided, use a stub |
342 | already in userspace. */ | 343 | already in userspace. */ |
343 | if (ka->sa.sa_flags & SA_RESTORER) { | 344 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
344 | regs->gprs[14] = (__u64 __force) ka->sa.sa_restorer | PSW32_ADDR_AMODE; | 345 | regs->gprs[14] = (__u64 __force) ksig->ka.sa.sa_restorer | PSW32_ADDR_AMODE; |
345 | } else { | 346 | } else { |
346 | regs->gprs[14] = (__u64 __force) frame->retcode | PSW32_ADDR_AMODE; | 347 | regs->gprs[14] = (__u64 __force) frame->retcode | PSW32_ADDR_AMODE; |
347 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, | 348 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, |
348 | (u16 __force __user *)(frame->retcode))) | 349 | (u16 __force __user *)(frame->retcode))) |
349 | goto give_sigsegv; | 350 | return -EFAULT; |
350 | } | 351 | } |
351 | 352 | ||
352 | /* Set up backchain. */ | 353 | /* Set up backchain. */ |
353 | if (__put_user(regs->gprs[15], (unsigned int __user *) frame)) | 354 | if (__put_user(regs->gprs[15], (unsigned int __user *) frame)) |
354 | goto give_sigsegv; | 355 | return -EFAULT; |
355 | 356 | ||
356 | /* Set up registers for signal handler */ | 357 | /* Set up registers for signal handler */ |
357 | regs->gprs[15] = (__force __u64) frame; | 358 | regs->gprs[15] = (__force __u64) frame; |
@@ -359,7 +360,7 @@ static int setup_frame32(int sig, struct k_sigaction *ka, | |||
359 | regs->psw.mask = PSW_MASK_BA | | 360 | regs->psw.mask = PSW_MASK_BA | |
360 | (PSW_USER_BITS & PSW_MASK_ASC) | | 361 | (PSW_USER_BITS & PSW_MASK_ASC) | |
361 | (regs->psw.mask & ~PSW_MASK_ASC); | 362 | (regs->psw.mask & ~PSW_MASK_ASC); |
362 | regs->psw.addr = (__force __u64) ka->sa.sa_handler; | 363 | regs->psw.addr = (__force __u64) ksig->ka.sa.sa_handler; |
363 | 364 | ||
364 | regs->gprs[2] = map_signal(sig); | 365 | regs->gprs[2] = map_signal(sig); |
365 | regs->gprs[3] = (__force __u64) &frame->sc; | 366 | regs->gprs[3] = (__force __u64) &frame->sc; |
@@ -376,25 +377,21 @@ static int setup_frame32(int sig, struct k_sigaction *ka, | |||
376 | 377 | ||
377 | /* Place signal number on stack to allow backtrace from handler. */ | 378 | /* Place signal number on stack to allow backtrace from handler. */ |
378 | if (__put_user(regs->gprs[2], (int __force __user *) &frame->signo)) | 379 | if (__put_user(regs->gprs[2], (int __force __user *) &frame->signo)) |
379 | goto give_sigsegv; | 380 | return -EFAULT; |
380 | return 0; | 381 | return 0; |
381 | |||
382 | give_sigsegv: | ||
383 | force_sigsegv(sig, current); | ||
384 | return -EFAULT; | ||
385 | } | 382 | } |
386 | 383 | ||
387 | static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info, | 384 | static int setup_rt_frame32(struct ksignal *ksig, sigset_t *set, |
388 | sigset_t *set, struct pt_regs * regs) | 385 | struct pt_regs *regs) |
389 | { | 386 | { |
390 | int err = 0; | 387 | int err = 0; |
391 | rt_sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(rt_sigframe32)); | 388 | rt_sigframe32 __user *frame = get_sigframe(&ksig->ka, regs, sizeof(rt_sigframe32)); |
392 | 389 | ||
393 | if (frame == (void __user *) -1UL) | 390 | if (frame == (void __user *) -1UL) |
394 | goto give_sigsegv; | 391 | return -EFAULT; |
395 | 392 | ||
396 | if (copy_siginfo_to_user32(&frame->info, info)) | 393 | if (copy_siginfo_to_user32(&frame->info, &ksig->info)) |
397 | goto give_sigsegv; | 394 | return -EFAULT; |
398 | 395 | ||
399 | /* Create the ucontext. */ | 396 | /* Create the ucontext. */ |
400 | err |= __put_user(UC_EXTENDED, &frame->uc.uc_flags); | 397 | err |= __put_user(UC_EXTENDED, &frame->uc.uc_flags); |
@@ -404,22 +401,22 @@ static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
404 | err |= save_sigregs_gprs_high(regs, frame->gprs_high); | 401 | err |= save_sigregs_gprs_high(regs, frame->gprs_high); |
405 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 402 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
406 | if (err) | 403 | if (err) |
407 | goto give_sigsegv; | 404 | return -EFAULT; |
408 | 405 | ||
409 | /* Set up to return from userspace. If provided, use a stub | 406 | /* Set up to return from userspace. If provided, use a stub |
410 | already in userspace. */ | 407 | already in userspace. */ |
411 | if (ka->sa.sa_flags & SA_RESTORER) { | 408 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
412 | regs->gprs[14] = (__u64 __force) ka->sa.sa_restorer | PSW32_ADDR_AMODE; | 409 | regs->gprs[14] = (__u64 __force) ksig->ka.sa.sa_restorer | PSW32_ADDR_AMODE; |
413 | } else { | 410 | } else { |
414 | regs->gprs[14] = (__u64 __force) frame->retcode | PSW32_ADDR_AMODE; | 411 | regs->gprs[14] = (__u64 __force) frame->retcode | PSW32_ADDR_AMODE; |
415 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, | 412 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, |
416 | (u16 __force __user *)(frame->retcode))) | 413 | (u16 __force __user *)(frame->retcode))) |
417 | goto give_sigsegv; | 414 | return -EFAULT; |
418 | } | 415 | } |
419 | 416 | ||
420 | /* Set up backchain. */ | 417 | /* Set up backchain. */ |
421 | if (__put_user(regs->gprs[15], (unsigned int __force __user *) frame)) | 418 | if (__put_user(regs->gprs[15], (unsigned int __force __user *) frame)) |
422 | goto give_sigsegv; | 419 | return -EFAULT; |
423 | 420 | ||
424 | /* Set up registers for signal handler */ | 421 | /* Set up registers for signal handler */ |
425 | regs->gprs[15] = (__force __u64) frame; | 422 | regs->gprs[15] = (__force __u64) frame; |
@@ -427,36 +424,30 @@ static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
427 | regs->psw.mask = PSW_MASK_BA | | 424 | regs->psw.mask = PSW_MASK_BA | |
428 | (PSW_USER_BITS & PSW_MASK_ASC) | | 425 | (PSW_USER_BITS & PSW_MASK_ASC) | |
429 | (regs->psw.mask & ~PSW_MASK_ASC); | 426 | (regs->psw.mask & ~PSW_MASK_ASC); |
430 | regs->psw.addr = (__u64 __force) ka->sa.sa_handler; | 427 | regs->psw.addr = (__u64 __force) ksig->ka.sa.sa_handler; |
431 | 428 | ||
432 | regs->gprs[2] = map_signal(sig); | 429 | regs->gprs[2] = map_signal(ksig->sig); |
433 | regs->gprs[3] = (__force __u64) &frame->info; | 430 | regs->gprs[3] = (__force __u64) &frame->info; |
434 | regs->gprs[4] = (__force __u64) &frame->uc; | 431 | regs->gprs[4] = (__force __u64) &frame->uc; |
435 | regs->gprs[5] = task_thread_info(current)->last_break; | 432 | regs->gprs[5] = task_thread_info(current)->last_break; |
436 | return 0; | 433 | return 0; |
437 | |||
438 | give_sigsegv: | ||
439 | force_sigsegv(sig, current); | ||
440 | return -EFAULT; | ||
441 | } | 434 | } |
442 | 435 | ||
443 | /* | 436 | /* |
444 | * OK, we're invoking a handler | 437 | * OK, we're invoking a handler |
445 | */ | 438 | */ |
446 | 439 | ||
447 | void handle_signal32(unsigned long sig, struct k_sigaction *ka, | 440 | void handle_signal32(struct ksignal *ksig, sigset_t *oldset, |
448 | siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) | 441 | struct pt_regs *regs) |
449 | { | 442 | { |
450 | int ret; | 443 | int ret; |
451 | 444 | ||
452 | /* Set up the stack frame */ | 445 | /* Set up the stack frame */ |
453 | if (ka->sa.sa_flags & SA_SIGINFO) | 446 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
454 | ret = setup_rt_frame32(sig, ka, info, oldset, regs); | 447 | ret = setup_rt_frame32(ksig, oldset, regs); |
455 | else | 448 | else |
456 | ret = setup_frame32(sig, ka, oldset, regs); | 449 | ret = setup_frame32(ksig, oldset, regs); |
457 | if (ret) | 450 | |
458 | return; | 451 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLE_STEP)); |
459 | signal_delivered(sig, info, ka, regs, | ||
460 | test_thread_flag(TIF_SINGLE_STEP)); | ||
461 | } | 452 | } |
462 | 453 | ||
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h index 6ac78192455f..1aad48398d06 100644 --- a/arch/s390/kernel/entry.h +++ b/arch/s390/kernel/entry.h | |||
@@ -48,8 +48,8 @@ void do_per_trap(struct pt_regs *regs); | |||
48 | void syscall_trace(struct pt_regs *regs, int entryexit); | 48 | void syscall_trace(struct pt_regs *regs, int entryexit); |
49 | void kernel_stack_overflow(struct pt_regs * regs); | 49 | void kernel_stack_overflow(struct pt_regs * regs); |
50 | void do_signal(struct pt_regs *regs); | 50 | void do_signal(struct pt_regs *regs); |
51 | void handle_signal32(unsigned long sig, struct k_sigaction *ka, | 51 | void handle_signal32(struct ksignal *ksig, sigset_t *oldset, |
52 | siginfo_t *info, sigset_t *oldset, struct pt_regs *regs); | 52 | struct pt_regs *regs); |
53 | void do_notify_resume(struct pt_regs *regs); | 53 | void do_notify_resume(struct pt_regs *regs); |
54 | 54 | ||
55 | void __init init_IRQ(void); | 55 | void __init init_IRQ(void); |
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c index 42b49f9e19bf..469c4c6d9182 100644 --- a/arch/s390/kernel/signal.c +++ b/arch/s390/kernel/signal.c | |||
@@ -200,15 +200,15 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
200 | frame = get_sigframe(ka, regs, sizeof(sigframe)); | 200 | frame = get_sigframe(ka, regs, sizeof(sigframe)); |
201 | 201 | ||
202 | if (frame == (void __user *) -1UL) | 202 | if (frame == (void __user *) -1UL) |
203 | goto give_sigsegv; | 203 | return -EFAULT; |
204 | 204 | ||
205 | if (__copy_to_user(&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE)) | 205 | if (__copy_to_user(&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE)) |
206 | goto give_sigsegv; | 206 | return -EFAULT; |
207 | 207 | ||
208 | if (save_sigregs(regs, &frame->sregs)) | 208 | if (save_sigregs(regs, &frame->sregs)) |
209 | goto give_sigsegv; | 209 | return -EFAULT; |
210 | if (__put_user(&frame->sregs, &frame->sc.sregs)) | 210 | if (__put_user(&frame->sregs, &frame->sc.sregs)) |
211 | goto give_sigsegv; | 211 | return -EFAULT; |
212 | 212 | ||
213 | /* Set up to return from userspace. If provided, use a stub | 213 | /* Set up to return from userspace. If provided, use a stub |
214 | already in userspace. */ | 214 | already in userspace. */ |
@@ -220,12 +220,12 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
220 | frame->retcode | PSW_ADDR_AMODE; | 220 | frame->retcode | PSW_ADDR_AMODE; |
221 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, | 221 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, |
222 | (u16 __user *)(frame->retcode))) | 222 | (u16 __user *)(frame->retcode))) |
223 | goto give_sigsegv; | 223 | return -EFAULT; |
224 | } | 224 | } |
225 | 225 | ||
226 | /* Set up backchain. */ | 226 | /* Set up backchain. */ |
227 | if (__put_user(regs->gprs[15], (addr_t __user *) frame)) | 227 | if (__put_user(regs->gprs[15], (addr_t __user *) frame)) |
228 | goto give_sigsegv; | 228 | return -EFAULT; |
229 | 229 | ||
230 | /* Set up registers for signal handler */ | 230 | /* Set up registers for signal handler */ |
231 | regs->gprs[15] = (unsigned long) frame; | 231 | regs->gprs[15] = (unsigned long) frame; |
@@ -250,27 +250,23 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
250 | 250 | ||
251 | /* Place signal number on stack to allow backtrace from handler. */ | 251 | /* Place signal number on stack to allow backtrace from handler. */ |
252 | if (__put_user(regs->gprs[2], (int __user *) &frame->signo)) | 252 | if (__put_user(regs->gprs[2], (int __user *) &frame->signo)) |
253 | goto give_sigsegv; | 253 | return -EFAULT; |
254 | return 0; | 254 | return 0; |
255 | |||
256 | give_sigsegv: | ||
257 | force_sigsegv(sig, current); | ||
258 | return -EFAULT; | ||
259 | } | 255 | } |
260 | 256 | ||
261 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 257 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
262 | sigset_t *set, struct pt_regs * regs) | 258 | struct pt_regs *regs) |
263 | { | 259 | { |
264 | int err = 0; | 260 | int err = 0; |
265 | rt_sigframe __user *frame; | 261 | rt_sigframe __user *frame; |
266 | 262 | ||
267 | frame = get_sigframe(ka, regs, sizeof(rt_sigframe)); | 263 | frame = get_sigframe(&ksig->ka, regs, sizeof(rt_sigframe)); |
268 | 264 | ||
269 | if (frame == (void __user *) -1UL) | 265 | if (frame == (void __user *) -1UL) |
270 | goto give_sigsegv; | 266 | return -EFAULT; |
271 | 267 | ||
272 | if (copy_siginfo_to_user(&frame->info, info)) | 268 | if (copy_siginfo_to_user(&frame->info, &ksig->info)) |
273 | goto give_sigsegv; | 269 | return -EFAULT; |
274 | 270 | ||
275 | /* Create the ucontext. */ | 271 | /* Create the ucontext. */ |
276 | err |= __put_user(0, &frame->uc.uc_flags); | 272 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -279,24 +275,24 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
279 | err |= save_sigregs(regs, &frame->uc.uc_mcontext); | 275 | err |= save_sigregs(regs, &frame->uc.uc_mcontext); |
280 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 276 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
281 | if (err) | 277 | if (err) |
282 | goto give_sigsegv; | 278 | return -EFAULT; |
283 | 279 | ||
284 | /* Set up to return from userspace. If provided, use a stub | 280 | /* Set up to return from userspace. If provided, use a stub |
285 | already in userspace. */ | 281 | already in userspace. */ |
286 | if (ka->sa.sa_flags & SA_RESTORER) { | 282 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
287 | regs->gprs[14] = (unsigned long) | 283 | regs->gprs[14] = (unsigned long) |
288 | ka->sa.sa_restorer | PSW_ADDR_AMODE; | 284 | ksig->ka.sa.sa_restorer | PSW_ADDR_AMODE; |
289 | } else { | 285 | } else { |
290 | regs->gprs[14] = (unsigned long) | 286 | regs->gprs[14] = (unsigned long) |
291 | frame->retcode | PSW_ADDR_AMODE; | 287 | frame->retcode | PSW_ADDR_AMODE; |
292 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, | 288 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, |
293 | (u16 __user *)(frame->retcode))) | 289 | (u16 __user *)(frame->retcode))) |
294 | goto give_sigsegv; | 290 | return -EFAULT; |
295 | } | 291 | } |
296 | 292 | ||
297 | /* Set up backchain. */ | 293 | /* Set up backchain. */ |
298 | if (__put_user(regs->gprs[15], (addr_t __user *) frame)) | 294 | if (__put_user(regs->gprs[15], (addr_t __user *) frame)) |
299 | goto give_sigsegv; | 295 | return -EFAULT; |
300 | 296 | ||
301 | /* Set up registers for signal handler */ | 297 | /* Set up registers for signal handler */ |
302 | regs->gprs[15] = (unsigned long) frame; | 298 | regs->gprs[15] = (unsigned long) frame; |
@@ -304,34 +300,27 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
304 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | | 300 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | |
305 | (PSW_USER_BITS & PSW_MASK_ASC) | | 301 | (PSW_USER_BITS & PSW_MASK_ASC) | |
306 | (regs->psw.mask & ~PSW_MASK_ASC); | 302 | (regs->psw.mask & ~PSW_MASK_ASC); |
307 | regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; | 303 | regs->psw.addr = (unsigned long) ksig->ka.sa.sa_handler | PSW_ADDR_AMODE; |
308 | 304 | ||
309 | regs->gprs[2] = map_signal(sig); | 305 | regs->gprs[2] = map_signal(ksig->sig); |
310 | regs->gprs[3] = (unsigned long) &frame->info; | 306 | regs->gprs[3] = (unsigned long) &frame->info; |
311 | regs->gprs[4] = (unsigned long) &frame->uc; | 307 | regs->gprs[4] = (unsigned long) &frame->uc; |
312 | regs->gprs[5] = task_thread_info(current)->last_break; | 308 | regs->gprs[5] = task_thread_info(current)->last_break; |
313 | return 0; | 309 | return 0; |
314 | |||
315 | give_sigsegv: | ||
316 | force_sigsegv(sig, current); | ||
317 | return -EFAULT; | ||
318 | } | 310 | } |
319 | 311 | ||
320 | static void handle_signal(unsigned long sig, struct k_sigaction *ka, | 312 | static void handle_signal(struct ksignal *ksig, sigset_t *oldset, |
321 | siginfo_t *info, sigset_t *oldset, | 313 | struct pt_regs *regs) |
322 | struct pt_regs *regs) | ||
323 | { | 314 | { |
324 | int ret; | 315 | int ret; |
325 | 316 | ||
326 | /* Set up the stack frame */ | 317 | /* Set up the stack frame */ |
327 | if (ka->sa.sa_flags & SA_SIGINFO) | 318 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
328 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 319 | ret = setup_rt_frame(ksig, oldset, regs); |
329 | else | 320 | else |
330 | ret = setup_frame(sig, ka, oldset, regs); | 321 | ret = setup_frame(ksig->sig, &ksig->ka, oldset, regs); |
331 | if (ret) | 322 | |
332 | return; | 323 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLE_STEP)); |
333 | signal_delivered(sig, info, ka, regs, | ||
334 | test_thread_flag(TIF_SINGLE_STEP)); | ||
335 | } | 324 | } |
336 | 325 | ||
337 | /* | 326 | /* |
@@ -345,9 +334,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
345 | */ | 334 | */ |
346 | void do_signal(struct pt_regs *regs) | 335 | void do_signal(struct pt_regs *regs) |
347 | { | 336 | { |
348 | siginfo_t info; | 337 | struct ksignal ksig; |
349 | int signr; | ||
350 | struct k_sigaction ka; | ||
351 | sigset_t *oldset = sigmask_to_save(); | 338 | sigset_t *oldset = sigmask_to_save(); |
352 | 339 | ||
353 | /* | 340 | /* |
@@ -357,9 +344,8 @@ void do_signal(struct pt_regs *regs) | |||
357 | */ | 344 | */ |
358 | current_thread_info()->system_call = | 345 | current_thread_info()->system_call = |
359 | test_pt_regs_flag(regs, PIF_SYSCALL) ? regs->int_code : 0; | 346 | test_pt_regs_flag(regs, PIF_SYSCALL) ? regs->int_code : 0; |
360 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | ||
361 | 347 | ||
362 | if (signr > 0) { | 348 | if (get_signal(&ksig)) { |
363 | /* Whee! Actually deliver the signal. */ | 349 | /* Whee! Actually deliver the signal. */ |
364 | if (current_thread_info()->system_call) { | 350 | if (current_thread_info()->system_call) { |
365 | regs->int_code = current_thread_info()->system_call; | 351 | regs->int_code = current_thread_info()->system_call; |
@@ -370,7 +356,7 @@ void do_signal(struct pt_regs *regs) | |||
370 | regs->gprs[2] = -EINTR; | 356 | regs->gprs[2] = -EINTR; |
371 | break; | 357 | break; |
372 | case -ERESTARTSYS: | 358 | case -ERESTARTSYS: |
373 | if (!(ka.sa.sa_flags & SA_RESTART)) { | 359 | if (!(ksig.ka.sa.sa_flags & SA_RESTART)) { |
374 | regs->gprs[2] = -EINTR; | 360 | regs->gprs[2] = -EINTR; |
375 | break; | 361 | break; |
376 | } | 362 | } |
@@ -387,9 +373,9 @@ void do_signal(struct pt_regs *regs) | |||
387 | clear_pt_regs_flag(regs, PIF_SYSCALL); | 373 | clear_pt_regs_flag(regs, PIF_SYSCALL); |
388 | 374 | ||
389 | if (is_compat_task()) | 375 | if (is_compat_task()) |
390 | handle_signal32(signr, &ka, &info, oldset, regs); | 376 | handle_signal32(&ksig, oldset, regs); |
391 | else | 377 | else |
392 | handle_signal(signr, &ka, &info, oldset, regs); | 378 | handle_signal(&ksig, oldset, regs); |
393 | return; | 379 | return; |
394 | } | 380 | } |
395 | 381 | ||
diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c index a00fba32b0eb..1651807774ad 100644 --- a/arch/score/kernel/signal.c +++ b/arch/score/kernel/signal.c | |||
@@ -173,15 +173,15 @@ badframe: | |||
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
175 | 175 | ||
176 | static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | 176 | static int setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs, |
177 | int signr, sigset_t *set, siginfo_t *info) | 177 | sigset_t *set) |
178 | { | 178 | { |
179 | struct rt_sigframe __user *frame; | 179 | struct rt_sigframe __user *frame; |
180 | int err = 0; | 180 | int err = 0; |
181 | 181 | ||
182 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 182 | frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); |
183 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 183 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
184 | goto give_sigsegv; | 184 | return -EFAULT; |
185 | 185 | ||
186 | /* | 186 | /* |
187 | * Set up the return code ... | 187 | * Set up the return code ... |
@@ -194,7 +194,7 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
194 | err |= __put_user(0x80008002, frame->rs_code + 1); | 194 | err |= __put_user(0x80008002, frame->rs_code + 1); |
195 | flush_cache_sigtramp((unsigned long) frame->rs_code); | 195 | flush_cache_sigtramp((unsigned long) frame->rs_code); |
196 | 196 | ||
197 | err |= copy_siginfo_to_user(&frame->rs_info, info); | 197 | err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info); |
198 | err |= __put_user(0, &frame->rs_uc.uc_flags); | 198 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
199 | err |= __put_user(NULL, &frame->rs_uc.uc_link); | 199 | err |= __put_user(NULL, &frame->rs_uc.uc_link); |
200 | err |= __save_altstack(&frame->rs_uc.uc_stack, regs->regs[0]); | 200 | err |= __save_altstack(&frame->rs_uc.uc_stack, regs->regs[0]); |
@@ -202,26 +202,23 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
202 | err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); | 202 | err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); |
203 | 203 | ||
204 | if (err) | 204 | if (err) |
205 | goto give_sigsegv; | 205 | return -EFAULT; |
206 | 206 | ||
207 | regs->regs[0] = (unsigned long) frame; | 207 | regs->regs[0] = (unsigned long) frame; |
208 | regs->regs[3] = (unsigned long) frame->rs_code; | 208 | regs->regs[3] = (unsigned long) frame->rs_code; |
209 | regs->regs[4] = signr; | 209 | regs->regs[4] = ksig->sig; |
210 | regs->regs[5] = (unsigned long) &frame->rs_info; | 210 | regs->regs[5] = (unsigned long) &frame->rs_info; |
211 | regs->regs[6] = (unsigned long) &frame->rs_uc; | 211 | regs->regs[6] = (unsigned long) &frame->rs_uc; |
212 | regs->regs[29] = (unsigned long) ka->sa.sa_handler; | 212 | regs->regs[29] = (unsigned long) ksig->ka.sa.sa_handler; |
213 | regs->cp0_epc = (unsigned long) ka->sa.sa_handler; | 213 | regs->cp0_epc = (unsigned long) ksig->ka.sa.sa_handler; |
214 | 214 | ||
215 | return 0; | 215 | return 0; |
216 | |||
217 | give_sigsegv: | ||
218 | force_sigsegv(signr, current); | ||
219 | return -EFAULT; | ||
220 | } | 216 | } |
221 | 217 | ||
222 | static void handle_signal(unsigned long sig, siginfo_t *info, | 218 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
223 | struct k_sigaction *ka, struct pt_regs *regs) | ||
224 | { | 219 | { |
220 | int ret; | ||
221 | |||
225 | if (regs->is_syscall) { | 222 | if (regs->is_syscall) { |
226 | switch (regs->regs[4]) { | 223 | switch (regs->regs[4]) { |
227 | case ERESTART_RESTARTBLOCK: | 224 | case ERESTART_RESTARTBLOCK: |
@@ -229,7 +226,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
229 | regs->regs[4] = EINTR; | 226 | regs->regs[4] = EINTR; |
230 | break; | 227 | break; |
231 | case ERESTARTSYS: | 228 | case ERESTARTSYS: |
232 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 229 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
233 | regs->regs[4] = EINTR; | 230 | regs->regs[4] = EINTR; |
234 | break; | 231 | break; |
235 | } | 232 | } |
@@ -245,17 +242,14 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
245 | /* | 242 | /* |
246 | * Set up the stack frame | 243 | * Set up the stack frame |
247 | */ | 244 | */ |
248 | if (setup_rt_frame(ka, regs, sig, sigmask_to_save(), info) < 0) | 245 | ret = setup_rt_frame(ksig, regs, sigmask_to_save()); |
249 | return; | ||
250 | 246 | ||
251 | signal_delivered(sig, info, ka, regs, 0); | 247 | signal_setup_done(ret, ksig, 0); |
252 | } | 248 | } |
253 | 249 | ||
254 | static void do_signal(struct pt_regs *regs) | 250 | static void do_signal(struct pt_regs *regs) |
255 | { | 251 | { |
256 | struct k_sigaction ka; | 252 | struct ksignal ksig; |
257 | siginfo_t info; | ||
258 | int signr; | ||
259 | 253 | ||
260 | /* | 254 | /* |
261 | * We want the common case to go fast, which is why we may in certain | 255 | * We want the common case to go fast, which is why we may in certain |
@@ -265,10 +259,9 @@ static void do_signal(struct pt_regs *regs) | |||
265 | if (!user_mode(regs)) | 259 | if (!user_mode(regs)) |
266 | return; | 260 | return; |
267 | 261 | ||
268 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 262 | if (get_signal(&ksig)) { |
269 | if (signr > 0) { | ||
270 | /* Actually deliver the signal. */ | 263 | /* Actually deliver the signal. */ |
271 | handle_signal(signr, &info, &ka, regs); | 264 | handle_signal(&ksig, regs); |
272 | return; | 265 | return; |
273 | } | 266 | } |
274 | 267 | ||
diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c index 594cd371aa28..2f002b24fb92 100644 --- a/arch/sh/kernel/signal_32.c +++ b/arch/sh/kernel/signal_32.c | |||
@@ -262,17 +262,17 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) | |||
262 | extern void __kernel_sigreturn(void); | 262 | extern void __kernel_sigreturn(void); |
263 | extern void __kernel_rt_sigreturn(void); | 263 | extern void __kernel_rt_sigreturn(void); |
264 | 264 | ||
265 | static int setup_frame(int sig, struct k_sigaction *ka, | 265 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
266 | sigset_t *set, struct pt_regs *regs) | 266 | struct pt_regs *regs) |
267 | { | 267 | { |
268 | struct sigframe __user *frame; | 268 | struct sigframe __user *frame; |
269 | int err = 0; | 269 | int err = 0, sig = ksig->sig; |
270 | int signal; | 270 | int signal; |
271 | 271 | ||
272 | frame = get_sigframe(ka, regs->regs[15], sizeof(*frame)); | 272 | frame = get_sigframe(&ksig->ka, regs->regs[15], sizeof(*frame)); |
273 | 273 | ||
274 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 274 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
275 | goto give_sigsegv; | 275 | return -EFAULT; |
276 | 276 | ||
277 | signal = current_thread_info()->exec_domain | 277 | signal = current_thread_info()->exec_domain |
278 | && current_thread_info()->exec_domain->signal_invmap | 278 | && current_thread_info()->exec_domain->signal_invmap |
@@ -288,8 +288,8 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
288 | 288 | ||
289 | /* Set up to return from userspace. If provided, use a stub | 289 | /* Set up to return from userspace. If provided, use a stub |
290 | already in userspace. */ | 290 | already in userspace. */ |
291 | if (ka->sa.sa_flags & SA_RESTORER) { | 291 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
292 | regs->pr = (unsigned long) ka->sa.sa_restorer; | 292 | regs->pr = (unsigned long) ksig->ka.sa.sa_restorer; |
293 | #ifdef CONFIG_VSYSCALL | 293 | #ifdef CONFIG_VSYSCALL |
294 | } else if (likely(current->mm->context.vdso)) { | 294 | } else if (likely(current->mm->context.vdso)) { |
295 | regs->pr = VDSO_SYM(&__kernel_sigreturn); | 295 | regs->pr = VDSO_SYM(&__kernel_sigreturn); |
@@ -309,7 +309,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
309 | } | 309 | } |
310 | 310 | ||
311 | if (err) | 311 | if (err) |
312 | goto give_sigsegv; | 312 | return -EFAULT; |
313 | 313 | ||
314 | /* Set up registers for signal handler */ | 314 | /* Set up registers for signal handler */ |
315 | regs->regs[15] = (unsigned long) frame; | 315 | regs->regs[15] = (unsigned long) frame; |
@@ -319,15 +319,15 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
319 | 319 | ||
320 | if (current->personality & FDPIC_FUNCPTRS) { | 320 | if (current->personality & FDPIC_FUNCPTRS) { |
321 | struct fdpic_func_descriptor __user *funcptr = | 321 | struct fdpic_func_descriptor __user *funcptr = |
322 | (struct fdpic_func_descriptor __user *)ka->sa.sa_handler; | 322 | (struct fdpic_func_descriptor __user *)ksig->ka.sa.sa_handler; |
323 | 323 | ||
324 | err |= __get_user(regs->pc, &funcptr->text); | 324 | err |= __get_user(regs->pc, &funcptr->text); |
325 | err |= __get_user(regs->regs[12], &funcptr->GOT); | 325 | err |= __get_user(regs->regs[12], &funcptr->GOT); |
326 | } else | 326 | } else |
327 | regs->pc = (unsigned long)ka->sa.sa_handler; | 327 | regs->pc = (unsigned long)ksig->ka.sa.sa_handler; |
328 | 328 | ||
329 | if (err) | 329 | if (err) |
330 | goto give_sigsegv; | 330 | return -EFAULT; |
331 | 331 | ||
332 | set_fs(USER_DS); | 332 | set_fs(USER_DS); |
333 | 333 | ||
@@ -335,23 +335,19 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
335 | current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); | 335 | current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); |
336 | 336 | ||
337 | return 0; | 337 | return 0; |
338 | |||
339 | give_sigsegv: | ||
340 | force_sigsegv(sig, current); | ||
341 | return -EFAULT; | ||
342 | } | 338 | } |
343 | 339 | ||
344 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 340 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
345 | sigset_t *set, struct pt_regs *regs) | 341 | struct pt_regs *regs) |
346 | { | 342 | { |
347 | struct rt_sigframe __user *frame; | 343 | struct rt_sigframe __user *frame; |
348 | int err = 0; | 344 | int err = 0, sig = ksig->sig; |
349 | int signal; | 345 | int signal; |
350 | 346 | ||
351 | frame = get_sigframe(ka, regs->regs[15], sizeof(*frame)); | 347 | frame = get_sigframe(&ksig->ka, regs->regs[15], sizeof(*frame)); |
352 | 348 | ||
353 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 349 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
354 | goto give_sigsegv; | 350 | return -EFAULT; |
355 | 351 | ||
356 | signal = current_thread_info()->exec_domain | 352 | signal = current_thread_info()->exec_domain |
357 | && current_thread_info()->exec_domain->signal_invmap | 353 | && current_thread_info()->exec_domain->signal_invmap |
@@ -359,7 +355,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
359 | ? current_thread_info()->exec_domain->signal_invmap[sig] | 355 | ? current_thread_info()->exec_domain->signal_invmap[sig] |
360 | : sig; | 356 | : sig; |
361 | 357 | ||
362 | err |= copy_siginfo_to_user(&frame->info, info); | 358 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
363 | 359 | ||
364 | /* Create the ucontext. */ | 360 | /* Create the ucontext. */ |
365 | err |= __put_user(0, &frame->uc.uc_flags); | 361 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -371,8 +367,8 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
371 | 367 | ||
372 | /* Set up to return from userspace. If provided, use a stub | 368 | /* Set up to return from userspace. If provided, use a stub |
373 | already in userspace. */ | 369 | already in userspace. */ |
374 | if (ka->sa.sa_flags & SA_RESTORER) { | 370 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
375 | regs->pr = (unsigned long) ka->sa.sa_restorer; | 371 | regs->pr = (unsigned long) ksig->ka.sa.sa_restorer; |
376 | #ifdef CONFIG_VSYSCALL | 372 | #ifdef CONFIG_VSYSCALL |
377 | } else if (likely(current->mm->context.vdso)) { | 373 | } else if (likely(current->mm->context.vdso)) { |
378 | regs->pr = VDSO_SYM(&__kernel_rt_sigreturn); | 374 | regs->pr = VDSO_SYM(&__kernel_rt_sigreturn); |
@@ -392,7 +388,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
392 | } | 388 | } |
393 | 389 | ||
394 | if (err) | 390 | if (err) |
395 | goto give_sigsegv; | 391 | return -EFAULT; |
396 | 392 | ||
397 | /* Set up registers for signal handler */ | 393 | /* Set up registers for signal handler */ |
398 | regs->regs[15] = (unsigned long) frame; | 394 | regs->regs[15] = (unsigned long) frame; |
@@ -402,15 +398,15 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
402 | 398 | ||
403 | if (current->personality & FDPIC_FUNCPTRS) { | 399 | if (current->personality & FDPIC_FUNCPTRS) { |
404 | struct fdpic_func_descriptor __user *funcptr = | 400 | struct fdpic_func_descriptor __user *funcptr = |
405 | (struct fdpic_func_descriptor __user *)ka->sa.sa_handler; | 401 | (struct fdpic_func_descriptor __user *)ksig->ka.sa.sa_handler; |
406 | 402 | ||
407 | err |= __get_user(regs->pc, &funcptr->text); | 403 | err |= __get_user(regs->pc, &funcptr->text); |
408 | err |= __get_user(regs->regs[12], &funcptr->GOT); | 404 | err |= __get_user(regs->regs[12], &funcptr->GOT); |
409 | } else | 405 | } else |
410 | regs->pc = (unsigned long)ka->sa.sa_handler; | 406 | regs->pc = (unsigned long)ksig->ka.sa.sa_handler; |
411 | 407 | ||
412 | if (err) | 408 | if (err) |
413 | goto give_sigsegv; | 409 | return -EFAULT; |
414 | 410 | ||
415 | set_fs(USER_DS); | 411 | set_fs(USER_DS); |
416 | 412 | ||
@@ -418,10 +414,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
418 | current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); | 414 | current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); |
419 | 415 | ||
420 | return 0; | 416 | return 0; |
421 | |||
422 | give_sigsegv: | ||
423 | force_sigsegv(sig, current); | ||
424 | return -EFAULT; | ||
425 | } | 417 | } |
426 | 418 | ||
427 | static inline void | 419 | static inline void |
@@ -455,22 +447,18 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs, | |||
455 | * OK, we're invoking a handler | 447 | * OK, we're invoking a handler |
456 | */ | 448 | */ |
457 | static void | 449 | static void |
458 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 450 | handle_signal(struct ksignal *ksig, struct pt_regs *regs, unsigned int save_r0) |
459 | struct pt_regs *regs, unsigned int save_r0) | ||
460 | { | 451 | { |
461 | sigset_t *oldset = sigmask_to_save(); | 452 | sigset_t *oldset = sigmask_to_save(); |
462 | int ret; | 453 | int ret; |
463 | 454 | ||
464 | /* Set up the stack frame */ | 455 | /* Set up the stack frame */ |
465 | if (ka->sa.sa_flags & SA_SIGINFO) | 456 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
466 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 457 | ret = setup_rt_frame(ksig, oldset, regs); |
467 | else | 458 | else |
468 | ret = setup_frame(sig, ka, oldset, regs); | 459 | ret = setup_frame(ksig, oldset, regs); |
469 | 460 | ||
470 | if (ret) | 461 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
471 | return; | ||
472 | signal_delivered(sig, info, ka, regs, | ||
473 | test_thread_flag(TIF_SINGLESTEP)); | ||
474 | } | 462 | } |
475 | 463 | ||
476 | /* | 464 | /* |
@@ -484,9 +472,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
484 | */ | 472 | */ |
485 | static void do_signal(struct pt_regs *regs, unsigned int save_r0) | 473 | static void do_signal(struct pt_regs *regs, unsigned int save_r0) |
486 | { | 474 | { |
487 | siginfo_t info; | 475 | struct ksignal ksig; |
488 | int signr; | ||
489 | struct k_sigaction ka; | ||
490 | 476 | ||
491 | /* | 477 | /* |
492 | * We want the common case to go fast, which | 478 | * We want the common case to go fast, which |
@@ -497,12 +483,11 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) | |||
497 | if (!user_mode(regs)) | 483 | if (!user_mode(regs)) |
498 | return; | 484 | return; |
499 | 485 | ||
500 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 486 | if (get_signal(&ksig)) { |
501 | if (signr > 0) { | 487 | handle_syscall_restart(save_r0, regs, &ksig.ka.sa); |
502 | handle_syscall_restart(save_r0, regs, &ka.sa); | ||
503 | 488 | ||
504 | /* Whee! Actually deliver the signal. */ | 489 | /* Whee! Actually deliver the signal. */ |
505 | handle_signal(signr, &ka, &info, regs, save_r0); | 490 | handle_signal(&ksig, regs, save_r0); |
506 | return; | 491 | return; |
507 | } | 492 | } |
508 | 493 | ||
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c index 23d4c71c91af..897abe7b871e 100644 --- a/arch/sh/kernel/signal_64.c +++ b/arch/sh/kernel/signal_64.c | |||
@@ -41,8 +41,7 @@ | |||
41 | #define DEBUG_SIG 0 | 41 | #define DEBUG_SIG 0 |
42 | 42 | ||
43 | static void | 43 | static void |
44 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 44 | handle_signal(struct ksignal *ksig, struct pt_regs *regs); |
45 | struct pt_regs * regs); | ||
46 | 45 | ||
47 | static inline void | 46 | static inline void |
48 | handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) | 47 | handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) |
@@ -82,9 +81,7 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) | |||
82 | */ | 81 | */ |
83 | static void do_signal(struct pt_regs *regs) | 82 | static void do_signal(struct pt_regs *regs) |
84 | { | 83 | { |
85 | siginfo_t info; | 84 | struct ksignal ksig; |
86 | int signr; | ||
87 | struct k_sigaction ka; | ||
88 | 85 | ||
89 | /* | 86 | /* |
90 | * We want the common case to go fast, which | 87 | * We want the common case to go fast, which |
@@ -95,12 +92,11 @@ static void do_signal(struct pt_regs *regs) | |||
95 | if (!user_mode(regs)) | 92 | if (!user_mode(regs)) |
96 | return; | 93 | return; |
97 | 94 | ||
98 | signr = get_signal_to_deliver(&info, &ka, regs, 0); | 95 | if (get_signal(&ksig)) { |
99 | if (signr > 0) { | 96 | handle_syscall_restart(regs, &ksig.ka.sa); |
100 | handle_syscall_restart(regs, &ka.sa); | ||
101 | 97 | ||
102 | /* Whee! Actually deliver the signal. */ | 98 | /* Whee! Actually deliver the signal. */ |
103 | handle_signal(signr, &info, &ka, regs); | 99 | handle_signal(&ksig, regs); |
104 | return; | 100 | return; |
105 | } | 101 | } |
106 | 102 | ||
@@ -378,17 +374,16 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) | |||
378 | void sa_default_restorer(void); /* See comments below */ | 374 | void sa_default_restorer(void); /* See comments below */ |
379 | void sa_default_rt_restorer(void); /* See comments below */ | 375 | void sa_default_rt_restorer(void); /* See comments below */ |
380 | 376 | ||
381 | static int setup_frame(int sig, struct k_sigaction *ka, | 377 | static int setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) |
382 | sigset_t *set, struct pt_regs *regs) | ||
383 | { | 378 | { |
384 | struct sigframe __user *frame; | 379 | struct sigframe __user *frame; |
385 | int err = 0; | 380 | int err = 0, sig = ksig->sig; |
386 | int signal; | 381 | int signal; |
387 | 382 | ||
388 | frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame)); | 383 | frame = get_sigframe(&ksig->ka, regs->regs[REG_SP], sizeof(*frame)); |
389 | 384 | ||
390 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 385 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
391 | goto give_sigsegv; | 386 | return -EFAULT; |
392 | 387 | ||
393 | signal = current_thread_info()->exec_domain | 388 | signal = current_thread_info()->exec_domain |
394 | && current_thread_info()->exec_domain->signal_invmap | 389 | && current_thread_info()->exec_domain->signal_invmap |
@@ -400,7 +395,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
400 | 395 | ||
401 | /* Give up earlier as i386, in case */ | 396 | /* Give up earlier as i386, in case */ |
402 | if (err) | 397 | if (err) |
403 | goto give_sigsegv; | 398 | return -EFAULT; |
404 | 399 | ||
405 | if (_NSIG_WORDS > 1) { | 400 | if (_NSIG_WORDS > 1) { |
406 | err |= __copy_to_user(frame->extramask, &set->sig[1], | 401 | err |= __copy_to_user(frame->extramask, &set->sig[1], |
@@ -408,16 +403,16 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
408 | 403 | ||
409 | /* Give up earlier as i386, in case */ | 404 | /* Give up earlier as i386, in case */ |
410 | if (err) | 405 | if (err) |
411 | goto give_sigsegv; | 406 | return -EFAULT; |
412 | 407 | ||
413 | /* Set up to return from userspace. If provided, use a stub | 408 | /* Set up to return from userspace. If provided, use a stub |
414 | already in userspace. */ | 409 | already in userspace. */ |
415 | if (ka->sa.sa_flags & SA_RESTORER) { | 410 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
416 | /* | 411 | /* |
417 | * On SH5 all edited pointers are subject to NEFF | 412 | * On SH5 all edited pointers are subject to NEFF |
418 | */ | 413 | */ |
419 | DEREF_REG_PR = neff_sign_extend((unsigned long) | 414 | DEREF_REG_PR = neff_sign_extend((unsigned long) |
420 | ka->sa.sa_restorer | 0x1); | 415 | ksig->ka->sa.sa_restorer | 0x1); |
421 | } else { | 416 | } else { |
422 | /* | 417 | /* |
423 | * Different approach on SH5. | 418 | * Different approach on SH5. |
@@ -435,7 +430,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
435 | 430 | ||
436 | if (__copy_to_user(frame->retcode, | 431 | if (__copy_to_user(frame->retcode, |
437 | (void *)((unsigned long)sa_default_restorer & (~1)), 16) != 0) | 432 | (void *)((unsigned long)sa_default_restorer & (~1)), 16) != 0) |
438 | goto give_sigsegv; | 433 | return -EFAULT; |
439 | 434 | ||
440 | /* Cohere the trampoline with the I-cache. */ | 435 | /* Cohere the trampoline with the I-cache. */ |
441 | flush_cache_sigtramp(DEREF_REG_PR-1); | 436 | flush_cache_sigtramp(DEREF_REG_PR-1); |
@@ -460,7 +455,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
460 | regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->sc; | 455 | regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->sc; |
461 | regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->sc; | 456 | regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->sc; |
462 | 457 | ||
463 | regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler); | 458 | regs->pc = neff_sign_extend((unsigned long)ksig->ka.sa.sa_handler); |
464 | 459 | ||
465 | set_fs(USER_DS); | 460 | set_fs(USER_DS); |
466 | 461 | ||
@@ -471,23 +466,19 @@ static int setup_frame(int sig, struct k_sigaction *ka, | |||
471 | DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); | 466 | DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); |
472 | 467 | ||
473 | return 0; | 468 | return 0; |
474 | |||
475 | give_sigsegv: | ||
476 | force_sigsegv(sig, current); | ||
477 | return -EFAULT; | ||
478 | } | 469 | } |
479 | 470 | ||
480 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 471 | static int setup_rt_frame(struct ksignal *kig, sigset_t *set, |
481 | sigset_t *set, struct pt_regs *regs) | 472 | struct pt_regs *regs) |
482 | { | 473 | { |
483 | struct rt_sigframe __user *frame; | 474 | struct rt_sigframe __user *frame; |
484 | int err = 0; | 475 | int err = 0, sig = ksig->sig; |
485 | int signal; | 476 | int signal; |
486 | 477 | ||
487 | frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame)); | 478 | frame = get_sigframe(&ksig->ka, regs->regs[REG_SP], sizeof(*frame)); |
488 | 479 | ||
489 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 480 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
490 | goto give_sigsegv; | 481 | return -EFAULT; |
491 | 482 | ||
492 | signal = current_thread_info()->exec_domain | 483 | signal = current_thread_info()->exec_domain |
493 | && current_thread_info()->exec_domain->signal_invmap | 484 | && current_thread_info()->exec_domain->signal_invmap |
@@ -497,11 +488,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
497 | 488 | ||
498 | err |= __put_user(&frame->info, &frame->pinfo); | 489 | err |= __put_user(&frame->info, &frame->pinfo); |
499 | err |= __put_user(&frame->uc, &frame->puc); | 490 | err |= __put_user(&frame->uc, &frame->puc); |
500 | err |= copy_siginfo_to_user(&frame->info, info); | 491 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
501 | 492 | ||
502 | /* Give up earlier as i386, in case */ | 493 | /* Give up earlier as i386, in case */ |
503 | if (err) | 494 | if (err) |
504 | goto give_sigsegv; | 495 | return -EFAULT; |
505 | 496 | ||
506 | /* Create the ucontext. */ | 497 | /* Create the ucontext. */ |
507 | err |= __put_user(0, &frame->uc.uc_flags); | 498 | err |= __put_user(0, &frame->uc.uc_flags); |
@@ -513,16 +504,16 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
513 | 504 | ||
514 | /* Give up earlier as i386, in case */ | 505 | /* Give up earlier as i386, in case */ |
515 | if (err) | 506 | if (err) |
516 | goto give_sigsegv; | 507 | return -EFAULT; |
517 | 508 | ||
518 | /* Set up to return from userspace. If provided, use a stub | 509 | /* Set up to return from userspace. If provided, use a stub |
519 | already in userspace. */ | 510 | already in userspace. */ |
520 | if (ka->sa.sa_flags & SA_RESTORER) { | 511 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
521 | /* | 512 | /* |
522 | * On SH5 all edited pointers are subject to NEFF | 513 | * On SH5 all edited pointers are subject to NEFF |
523 | */ | 514 | */ |
524 | DEREF_REG_PR = neff_sign_extend((unsigned long) | 515 | DEREF_REG_PR = neff_sign_extend((unsigned long) |
525 | ka->sa.sa_restorer | 0x1); | 516 | ksig->ka.sa.sa_restorer | 0x1); |
526 | } else { | 517 | } else { |
527 | /* | 518 | /* |
528 | * Different approach on SH5. | 519 | * Different approach on SH5. |
@@ -540,7 +531,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
540 | 531 | ||
541 | if (__copy_to_user(frame->retcode, | 532 | if (__copy_to_user(frame->retcode, |
542 | (void *)((unsigned long)sa_default_rt_restorer & (~1)), 16) != 0) | 533 | (void *)((unsigned long)sa_default_rt_restorer & (~1)), 16) != 0) |
543 | goto give_sigsegv; | 534 | return -EFAULT; |
544 | 535 | ||
545 | /* Cohere the trampoline with the I-cache. */ | 536 | /* Cohere the trampoline with the I-cache. */ |
546 | flush_icache_range(DEREF_REG_PR-1, DEREF_REG_PR-1+15); | 537 | flush_icache_range(DEREF_REG_PR-1, DEREF_REG_PR-1+15); |
@@ -554,7 +545,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
554 | regs->regs[REG_ARG1] = signal; /* Arg for signal handler */ | 545 | regs->regs[REG_ARG1] = signal; /* Arg for signal handler */ |
555 | regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->info; | 546 | regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->info; |
556 | regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->uc.uc_mcontext; | 547 | regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->uc.uc_mcontext; |
557 | regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler); | 548 | regs->pc = neff_sign_extend((unsigned long)ksig->ka.sa.sa_handler); |
558 | 549 | ||
559 | set_fs(USER_DS); | 550 | set_fs(USER_DS); |
560 | 551 | ||
@@ -564,33 +555,24 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
564 | DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); | 555 | DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); |
565 | 556 | ||
566 | return 0; | 557 | return 0; |
567 | |||
568 | give_sigsegv: | ||
569 | force_sigsegv(sig, current); | ||
570 | return -EFAULT; | ||
571 | } | 558 | } |
572 | 559 | ||
573 | /* | 560 | /* |
574 | * OK, we're invoking a handler | 561 | * OK, we're invoking a handler |
575 | */ | 562 | */ |
576 | static void | 563 | static void |
577 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 564 | handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
578 | struct pt_regs * regs) | ||
579 | { | 565 | { |
580 | sigset_t *oldset = sigmask_to_save(); | 566 | sigset_t *oldset = sigmask_to_save(); |
581 | int ret; | 567 | int ret; |
582 | 568 | ||
583 | /* Set up the stack frame */ | 569 | /* Set up the stack frame */ |
584 | if (ka->sa.sa_flags & SA_SIGINFO) | 570 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
585 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 571 | ret = setup_rt_frame(ksig, oldset, regs); |
586 | else | 572 | else |
587 | ret = setup_frame(sig, ka, oldset, regs); | 573 | ret = setup_frame(ksig, oldset, regs); |
588 | |||
589 | if (ret) | ||
590 | return; | ||
591 | 574 | ||
592 | signal_delivered(sig, info, ka, regs, | 575 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
593 | test_thread_flag(TIF_SINGLESTEP)); | ||
594 | } | 576 | } |
595 | 577 | ||
596 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) | 578 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) |
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h index ffd4493efc78..c14e36f008c8 100644 --- a/arch/tile/include/asm/compat.h +++ b/arch/tile/include/asm/compat.h | |||
@@ -267,8 +267,7 @@ static inline int is_compat_task(void) | |||
267 | return current_thread_info()->status & TS_COMPAT; | 267 | return current_thread_info()->status & TS_COMPAT; |
268 | } | 268 | } |
269 | 269 | ||
270 | extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka, | 270 | extern int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
271 | siginfo_t *info, sigset_t *set, | ||
272 | struct pt_regs *regs); | 271 | struct pt_regs *regs); |
273 | 272 | ||
274 | /* Compat syscalls. */ | 273 | /* Compat syscalls. */ |
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c index 19c04b5ce408..8c5abf2e4794 100644 --- a/arch/tile/kernel/compat_signal.c +++ b/arch/tile/kernel/compat_signal.c | |||
@@ -190,18 +190,18 @@ static inline void __user *compat_get_sigframe(struct k_sigaction *ka, | |||
190 | return (void __user *) sp; | 190 | return (void __user *) sp; |
191 | } | 191 | } |
192 | 192 | ||
193 | int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 193 | int compat_setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
194 | sigset_t *set, struct pt_regs *regs) | 194 | struct pt_regs *regs) |
195 | { | 195 | { |
196 | unsigned long restorer; | 196 | unsigned long restorer; |
197 | struct compat_rt_sigframe __user *frame; | 197 | struct compat_rt_sigframe __user *frame; |
198 | int err = 0; | 198 | int err = 0, sig = ksig->sig; |
199 | int usig; | 199 | int usig; |
200 | 200 | ||
201 | frame = compat_get_sigframe(ka, regs, sizeof(*frame)); | 201 | frame = compat_get_sigframe(&ksig->ka, regs, sizeof(*frame)); |
202 | 202 | ||
203 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 203 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
204 | goto give_sigsegv; | 204 | goto err; |
205 | 205 | ||
206 | usig = current_thread_info()->exec_domain | 206 | usig = current_thread_info()->exec_domain |
207 | && current_thread_info()->exec_domain->signal_invmap | 207 | && current_thread_info()->exec_domain->signal_invmap |
@@ -210,12 +210,12 @@ int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
210 | : sig; | 210 | : sig; |
211 | 211 | ||
212 | /* Always write at least the signal number for the stack backtracer. */ | 212 | /* Always write at least the signal number for the stack backtracer. */ |
213 | if (ka->sa.sa_flags & SA_SIGINFO) { | 213 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
214 | /* At sigreturn time, restore the callee-save registers too. */ | 214 | /* At sigreturn time, restore the callee-save registers too. */ |
215 | err |= copy_siginfo_to_user32(&frame->info, info); | 215 | err |= copy_siginfo_to_user32(&frame->info, &ksig->info); |
216 | regs->flags |= PT_FLAGS_RESTORE_REGS; | 216 | regs->flags |= PT_FLAGS_RESTORE_REGS; |
217 | } else { | 217 | } else { |
218 | err |= __put_user(info->si_signo, &frame->info.si_signo); | 218 | err |= __put_user(ksig->info.si_signo, &frame->info.si_signo); |
219 | } | 219 | } |
220 | 220 | ||
221 | /* Create the ucontext. */ | 221 | /* Create the ucontext. */ |
@@ -226,11 +226,11 @@ int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
226 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs); | 226 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs); |
227 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 227 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
228 | if (err) | 228 | if (err) |
229 | goto give_sigsegv; | 229 | goto err; |
230 | 230 | ||
231 | restorer = VDSO_SYM(&__vdso_rt_sigreturn); | 231 | restorer = VDSO_SYM(&__vdso_rt_sigreturn); |
232 | if (ka->sa.sa_flags & SA_RESTORER) | 232 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
233 | restorer = ptr_to_compat_reg(ka->sa.sa_restorer); | 233 | restorer = ptr_to_compat_reg(ksig->ka.sa.sa_restorer); |
234 | 234 | ||
235 | /* | 235 | /* |
236 | * Set up registers for signal handler. | 236 | * Set up registers for signal handler. |
@@ -239,7 +239,7 @@ int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
239 | * We always pass siginfo and mcontext, regardless of SA_SIGINFO, | 239 | * We always pass siginfo and mcontext, regardless of SA_SIGINFO, |
240 | * since some things rely on this (e.g. glibc's debug/segfault.c). | 240 | * since some things rely on this (e.g. glibc's debug/segfault.c). |
241 | */ | 241 | */ |
242 | regs->pc = ptr_to_compat_reg(ka->sa.sa_handler); | 242 | regs->pc = ptr_to_compat_reg(ksig->ka.sa.sa_handler); |
243 | regs->ex1 = PL_ICS_EX1(USER_PL, 1); /* set crit sec in handler */ | 243 | regs->ex1 = PL_ICS_EX1(USER_PL, 1); /* set crit sec in handler */ |
244 | regs->sp = ptr_to_compat_reg(frame); | 244 | regs->sp = ptr_to_compat_reg(frame); |
245 | regs->lr = restorer; | 245 | regs->lr = restorer; |
@@ -249,7 +249,8 @@ int compat_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
249 | regs->flags |= PT_FLAGS_CALLER_SAVES; | 249 | regs->flags |= PT_FLAGS_CALLER_SAVES; |
250 | return 0; | 250 | return 0; |
251 | 251 | ||
252 | give_sigsegv: | 252 | err: |
253 | signal_fault("bad setup frame", regs, frame, sig); | 253 | trace_unhandled_signal("bad sigreturn frame", regs, |
254 | (unsigned long)frame, SIGSEGV); | ||
254 | return -EFAULT; | 255 | return -EFAULT; |
255 | } | 256 | } |
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c index d1d026f01267..7c2fecc52177 100644 --- a/arch/tile/kernel/signal.c +++ b/arch/tile/kernel/signal.c | |||
@@ -153,18 +153,18 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, | |||
153 | return (void __user *) sp; | 153 | return (void __user *) sp; |
154 | } | 154 | } |
155 | 155 | ||
156 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 156 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
157 | sigset_t *set, struct pt_regs *regs) | 157 | struct pt_regs *regs) |
158 | { | 158 | { |
159 | unsigned long restorer; | 159 | unsigned long restorer; |
160 | struct rt_sigframe __user *frame; | 160 | struct rt_sigframe __user *frame; |
161 | int err = 0; | 161 | int err = 0, sig = ksig->sig; |
162 | int usig; | 162 | int usig; |
163 | 163 | ||
164 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 164 | frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); |
165 | 165 | ||
166 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 166 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
167 | goto give_sigsegv; | 167 | goto err; |
168 | 168 | ||
169 | usig = current_thread_info()->exec_domain | 169 | usig = current_thread_info()->exec_domain |
170 | && current_thread_info()->exec_domain->signal_invmap | 170 | && current_thread_info()->exec_domain->signal_invmap |
@@ -173,12 +173,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
173 | : sig; | 173 | : sig; |
174 | 174 | ||
175 | /* Always write at least the signal number for the stack backtracer. */ | 175 | /* Always write at least the signal number for the stack backtracer. */ |
176 | if (ka->sa.sa_flags & SA_SIGINFO) { | 176 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
177 | /* At sigreturn time, restore the callee-save registers too. */ | 177 | /* At sigreturn time, restore the callee-save registers too. */ |
178 | err |= copy_siginfo_to_user(&frame->info, info); | 178 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
179 | regs->flags |= PT_FLAGS_RESTORE_REGS; | 179 | regs->flags |= PT_FLAGS_RESTORE_REGS; |
180 | } else { | 180 | } else { |
181 | err |= __put_user(info->si_signo, &frame->info.si_signo); | 181 | err |= __put_user(ksig->info.si_signo, &frame->info.si_signo); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* Create the ucontext. */ | 184 | /* Create the ucontext. */ |
@@ -189,11 +189,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
189 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs); | 189 | err |= setup_sigcontext(&frame->uc.uc_mcontext, regs); |
190 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 190 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
191 | if (err) | 191 | if (err) |
192 | goto give_sigsegv; | 192 | goto err; |
193 | 193 | ||
194 | restorer = VDSO_SYM(&__vdso_rt_sigreturn); | 194 | restorer = VDSO_SYM(&__vdso_rt_sigreturn); |
195 | if (ka->sa.sa_flags & SA_RESTORER) | 195 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
196 | restorer = (unsigned long) ka->sa.sa_restorer; | 196 | restorer = (unsigned long) ksig->ka.sa.sa_restorer; |
197 | 197 | ||
198 | /* | 198 | /* |
199 | * Set up registers for signal handler. | 199 | * Set up registers for signal handler. |
@@ -202,7 +202,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
202 | * We always pass siginfo and mcontext, regardless of SA_SIGINFO, | 202 | * We always pass siginfo and mcontext, regardless of SA_SIGINFO, |
203 | * since some things rely on this (e.g. glibc's debug/segfault.c). | 203 | * since some things rely on this (e.g. glibc's debug/segfault.c). |
204 | */ | 204 | */ |
205 | regs->pc = (unsigned long) ka->sa.sa_handler; | 205 | regs->pc = (unsigned long) ksig->ka.sa.sa_handler; |
206 | regs->ex1 = PL_ICS_EX1(USER_PL, 1); /* set crit sec in handler */ | 206 | regs->ex1 = PL_ICS_EX1(USER_PL, 1); /* set crit sec in handler */ |
207 | regs->sp = (unsigned long) frame; | 207 | regs->sp = (unsigned long) frame; |
208 | regs->lr = restorer; | 208 | regs->lr = restorer; |
@@ -212,8 +212,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
212 | regs->flags |= PT_FLAGS_CALLER_SAVES; | 212 | regs->flags |= PT_FLAGS_CALLER_SAVES; |
213 | return 0; | 213 | return 0; |
214 | 214 | ||
215 | give_sigsegv: | 215 | err: |
216 | signal_fault("bad setup frame", regs, frame, sig); | 216 | trace_unhandled_signal("bad sigreturn frame", regs, |
217 | (unsigned long)frame, SIGSEGV); | ||
217 | return -EFAULT; | 218 | return -EFAULT; |
218 | } | 219 | } |
219 | 220 | ||
@@ -221,9 +222,7 @@ give_sigsegv: | |||
221 | * OK, we're invoking a handler | 222 | * OK, we're invoking a handler |
222 | */ | 223 | */ |
223 | 224 | ||
224 | static void handle_signal(unsigned long sig, siginfo_t *info, | 225 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
225 | struct k_sigaction *ka, | ||
226 | struct pt_regs *regs) | ||
227 | { | 226 | { |
228 | sigset_t *oldset = sigmask_to_save(); | 227 | sigset_t *oldset = sigmask_to_save(); |
229 | int ret; | 228 | int ret; |
@@ -238,7 +237,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
238 | break; | 237 | break; |
239 | 238 | ||
240 | case -ERESTARTSYS: | 239 | case -ERESTARTSYS: |
241 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 240 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
242 | regs->regs[0] = -EINTR; | 241 | regs->regs[0] = -EINTR; |
243 | break; | 242 | break; |
244 | } | 243 | } |
@@ -254,14 +253,12 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
254 | /* Set up the stack frame */ | 253 | /* Set up the stack frame */ |
255 | #ifdef CONFIG_COMPAT | 254 | #ifdef CONFIG_COMPAT |
256 | if (is_compat_task()) | 255 | if (is_compat_task()) |
257 | ret = compat_setup_rt_frame(sig, ka, info, oldset, regs); | 256 | ret = compat_setup_rt_frame(ksig, oldset, regs); |
258 | else | 257 | else |
259 | #endif | 258 | #endif |
260 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 259 | ret = setup_rt_frame(ksig, oldset, regs); |
261 | if (ret) | 260 | |
262 | return; | 261 | signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); |
263 | signal_delivered(sig, info, ka, regs, | ||
264 | test_thread_flag(TIF_SINGLESTEP)); | ||
265 | } | 262 | } |
266 | 263 | ||
267 | /* | 264 | /* |
@@ -271,9 +268,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, | |||
271 | */ | 268 | */ |
272 | void do_signal(struct pt_regs *regs) | 269 | void do_signal(struct pt_regs *regs) |
273 | { | 270 | { |
274 | siginfo_t info; | 271 | struct ksignal ksig; |
275 | int signr; | ||
276 | struct k_sigaction ka; | ||
277 | 272 | ||
278 | /* | 273 | /* |
279 | * i386 will check if we're coming from kernel mode and bail out | 274 | * i386 will check if we're coming from kernel mode and bail out |
@@ -282,10 +277,9 @@ void do_signal(struct pt_regs *regs) | |||
282 | * helpful, we can reinstate the check on "!user_mode(regs)". | 277 | * helpful, we can reinstate the check on "!user_mode(regs)". |
283 | */ | 278 | */ |
284 | 279 | ||
285 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 280 | if (get_signal(&ksig)) { |
286 | if (signr > 0) { | ||
287 | /* Whee! Actually deliver the signal. */ | 281 | /* Whee! Actually deliver the signal. */ |
288 | handle_signal(signr, &info, &ka, regs); | 282 | handle_signal(&ksig, regs); |
289 | goto done; | 283 | goto done; |
290 | } | 284 | } |
291 | 285 | ||
diff --git a/arch/um/include/shared/frame_kern.h b/arch/um/include/shared/frame_kern.h index f2ca5702a4e2..a5cde5c433b4 100644 --- a/arch/um/include/shared/frame_kern.h +++ b/arch/um/include/shared/frame_kern.h | |||
@@ -6,14 +6,10 @@ | |||
6 | #ifndef __FRAME_KERN_H_ | 6 | #ifndef __FRAME_KERN_H_ |
7 | #define __FRAME_KERN_H_ | 7 | #define __FRAME_KERN_H_ |
8 | 8 | ||
9 | extern int setup_signal_stack_sc(unsigned long stack_top, int sig, | 9 | extern int setup_signal_stack_sc(unsigned long stack_top, struct ksignal *ksig, |
10 | struct k_sigaction *ka, | 10 | struct pt_regs *regs, sigset_t *mask); |
11 | struct pt_regs *regs, | 11 | extern int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig, |
12 | sigset_t *mask); | 12 | struct pt_regs *regs, sigset_t *mask); |
13 | extern int setup_signal_stack_si(unsigned long stack_top, int sig, | ||
14 | struct k_sigaction *ka, | ||
15 | struct pt_regs *regs, struct siginfo *info, | ||
16 | sigset_t *mask); | ||
17 | 13 | ||
18 | #endif | 14 | #endif |
19 | 15 | ||
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c index f57e02e7910f..4f60e4aad790 100644 --- a/arch/um/kernel/signal.c +++ b/arch/um/kernel/signal.c | |||
@@ -18,8 +18,7 @@ EXPORT_SYMBOL(unblock_signals); | |||
18 | /* | 18 | /* |
19 | * OK, we're invoking a handler | 19 | * OK, we're invoking a handler |
20 | */ | 20 | */ |
21 | static void handle_signal(struct pt_regs *regs, unsigned long signr, | 21 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) |
22 | struct k_sigaction *ka, struct siginfo *info) | ||
23 | { | 22 | { |
24 | sigset_t *oldset = sigmask_to_save(); | 23 | sigset_t *oldset = sigmask_to_save(); |
25 | int singlestep = 0; | 24 | int singlestep = 0; |
@@ -39,7 +38,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr, | |||
39 | break; | 38 | break; |
40 | 39 | ||
41 | case -ERESTARTSYS: | 40 | case -ERESTARTSYS: |
42 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 41 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
43 | PT_REGS_SYSCALL_RET(regs) = -EINTR; | 42 | PT_REGS_SYSCALL_RET(regs) = -EINTR; |
44 | break; | 43 | break; |
45 | } | 44 | } |
@@ -52,32 +51,28 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr, | |||
52 | } | 51 | } |
53 | 52 | ||
54 | sp = PT_REGS_SP(regs); | 53 | sp = PT_REGS_SP(regs); |
55 | if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0)) | 54 | if ((ksig->ka.sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0)) |
56 | sp = current->sas_ss_sp + current->sas_ss_size; | 55 | sp = current->sas_ss_sp + current->sas_ss_size; |
57 | 56 | ||
58 | #ifdef CONFIG_ARCH_HAS_SC_SIGNALS | 57 | #ifdef CONFIG_ARCH_HAS_SC_SIGNALS |
59 | if (!(ka->sa.sa_flags & SA_SIGINFO)) | 58 | if (!(ksig->ka.sa.sa_flags & SA_SIGINFO)) |
60 | err = setup_signal_stack_sc(sp, signr, ka, regs, oldset); | 59 | err = setup_signal_stack_sc(sp, ksig, regs, oldset); |
61 | else | 60 | else |
62 | #endif | 61 | #endif |
63 | err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset); | 62 | err = setup_signal_stack_si(sp, ksig, regs, oldset); |
64 | 63 | ||
65 | if (err) | 64 | signal_setup_done(err, ksig, singlestep); |
66 | force_sigsegv(signr, current); | ||
67 | else | ||
68 | signal_delivered(signr, info, ka, regs, singlestep); | ||
69 | } | 65 | } |
70 | 66 | ||
71 | static int kern_do_signal(struct pt_regs *regs) | 67 | static int kern_do_signal(struct pt_regs *regs) |
72 | { | 68 | { |
73 | struct k_sigaction ka_copy; | 69 | struct ksignal ksig; |
74 | struct siginfo info; | 70 | int handled_sig = 0; |
75 | int sig, handled_sig = 0; | ||
76 | 71 | ||
77 | while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { | 72 | while (get_signal(&ksig)) { |
78 | handled_sig = 1; | 73 | handled_sig = 1; |
79 | /* Whee! Actually deliver the signal. */ | 74 | /* Whee! Actually deliver the signal. */ |
80 | handle_signal(regs, sig, &ka_copy, &info); | 75 | handle_signal(&ksig, regs); |
81 | } | 76 | } |
82 | 77 | ||
83 | /* Did we come from a system call? */ | 78 | /* Did we come from a system call? */ |
diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c index 6905f0ebdc77..780d77388dec 100644 --- a/arch/unicore32/kernel/signal.c +++ b/arch/unicore32/kernel/signal.c | |||
@@ -238,10 +238,10 @@ static int setup_return(struct pt_regs *regs, struct k_sigaction *ka, | |||
238 | return 0; | 238 | return 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | static int setup_frame(int usig, struct k_sigaction *ka, | 241 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
242 | sigset_t *set, struct pt_regs *regs) | 242 | struct pt_regs *regs) |
243 | { | 243 | { |
244 | struct sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame)); | 244 | struct sigframe __user *frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); |
245 | int err = 0; | 245 | int err = 0; |
246 | 246 | ||
247 | if (!frame) | 247 | if (!frame) |
@@ -254,29 +254,29 @@ static int setup_frame(int usig, struct k_sigaction *ka, | |||
254 | 254 | ||
255 | err |= setup_sigframe(frame, regs, set); | 255 | err |= setup_sigframe(frame, regs, set); |
256 | if (err == 0) | 256 | if (err == 0) |
257 | err |= setup_return(regs, ka, frame->retcode, frame, usig); | 257 | err |= setup_return(regs, &ksig->ka, frame->retcode, frame, usig); |
258 | 258 | ||
259 | return err; | 259 | return err; |
260 | } | 260 | } |
261 | 261 | ||
262 | static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, | 262 | static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, |
263 | sigset_t *set, struct pt_regs *regs) | 263 | struct pt_regs *regs) |
264 | { | 264 | { |
265 | struct rt_sigframe __user *frame = | 265 | struct rt_sigframe __user *frame = |
266 | get_sigframe(ka, regs, sizeof(*frame)); | 266 | get_sigframe(&ksig->ka, regs, sizeof(*frame)); |
267 | int err = 0; | 267 | int err = 0; |
268 | 268 | ||
269 | if (!frame) | 269 | if (!frame) |
270 | return 1; | 270 | return 1; |
271 | 271 | ||
272 | err |= copy_siginfo_to_user(&frame->info, info); | 272 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
273 | 273 | ||
274 | err |= __put_user(0, &frame->sig.uc.uc_flags); | 274 | err |= __put_user(0, &frame->sig.uc.uc_flags); |
275 | err |= __put_user(NULL, &frame->sig.uc.uc_link); | 275 | err |= __put_user(NULL, &frame->sig.uc.uc_link); |
276 | err |= __save_altstack(&frame->sig.uc.uc_stack, regs->UCreg_sp); | 276 | err |= __save_altstack(&frame->sig.uc.uc_stack, regs->UCreg_sp); |
277 | err |= setup_sigframe(&frame->sig, regs, set); | 277 | err |= setup_sigframe(&frame->sig, regs, set); |
278 | if (err == 0) | 278 | if (err == 0) |
279 | err |= setup_return(regs, ka, frame->sig.retcode, frame, usig); | 279 | err |= setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig); |
280 | 280 | ||
281 | if (err == 0) { | 281 | if (err == 0) { |
282 | /* | 282 | /* |
@@ -299,13 +299,13 @@ static inline void setup_syscall_restart(struct pt_regs *regs) | |||
299 | /* | 299 | /* |
300 | * OK, we're invoking a handler | 300 | * OK, we're invoking a handler |
301 | */ | 301 | */ |
302 | static void handle_signal(unsigned long sig, struct k_sigaction *ka, | 302 | static void handle_signal(struct ksignal *ksig, struct pt_regs *regs, |
303 | siginfo_t *info, struct pt_regs *regs, int syscall) | 303 | int syscall) |
304 | { | 304 | { |
305 | struct thread_info *thread = current_thread_info(); | 305 | struct thread_info *thread = current_thread_info(); |
306 | struct task_struct *tsk = current; | 306 | struct task_struct *tsk = current; |
307 | sigset_t *oldset = sigmask_to_save(); | 307 | sigset_t *oldset = sigmask_to_save(); |
308 | int usig = sig; | 308 | int usig = ksig->sig; |
309 | int ret; | 309 | int ret; |
310 | 310 | ||
311 | /* | 311 | /* |
@@ -318,7 +318,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
318 | regs->UCreg_00 = -EINTR; | 318 | regs->UCreg_00 = -EINTR; |
319 | break; | 319 | break; |
320 | case -ERESTARTSYS: | 320 | case -ERESTARTSYS: |
321 | if (!(ka->sa.sa_flags & SA_RESTART)) { | 321 | if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { |
322 | regs->UCreg_00 = -EINTR; | 322 | regs->UCreg_00 = -EINTR; |
323 | break; | 323 | break; |
324 | } | 324 | } |
@@ -338,22 +338,17 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
338 | /* | 338 | /* |
339 | * Set up the stack frame | 339 | * Set up the stack frame |
340 | */ | 340 | */ |
341 | if (ka->sa.sa_flags & SA_SIGINFO) | 341 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) |
342 | ret = setup_rt_frame(usig, ka, info, oldset, regs); | 342 | ret = setup_rt_frame(ksig, oldset, regs); |
343 | else | 343 | else |
344 | ret = setup_frame(usig, ka, oldset, regs); | 344 | ret = setup_frame(ksig, oldset, regs); |
345 | 345 | ||
346 | /* | 346 | /* |
347 | * Check that the resulting registers are actually sane. | 347 | * Check that the resulting registers are actually sane. |
348 | */ | 348 | */ |
349 | ret |= !valid_user_regs(regs); | 349 | ret |= !valid_user_regs(regs); |
350 | 350 | ||
351 | if (ret != 0) { | 351 | signal_setup_done(ret, ksig, 0); |
352 | force_sigsegv(sig, tsk); | ||
353 | return; | ||
354 | } | ||
355 | |||
356 | signal_delivered(sig, info, ka, regs, 0); | ||
357 | } | 352 | } |
358 | 353 | ||
359 | /* | 354 | /* |
@@ -367,9 +362,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
367 | */ | 362 | */ |
368 | static void do_signal(struct pt_regs *regs, int syscall) | 363 | static void do_signal(struct pt_regs *regs, int syscall) |
369 | { | 364 | { |
370 | struct k_sigaction ka; | 365 | struct ksignal ksig; |
371 | siginfo_t info; | ||
372 | int signr; | ||
373 | 366 | ||
374 | /* | 367 | /* |
375 | * We want the common case to go fast, which | 368 | * We want the common case to go fast, which |
@@ -380,9 +373,8 @@ static void do_signal(struct pt_regs *regs, int syscall) | |||
380 | if (!user_mode(regs)) | 373 | if (!user_mode(regs)) |
381 | return; | 374 | return; |
382 | 375 | ||
383 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 376 | if (get_signsl(&ksig)) { |
384 | if (signr > 0) { | 377 | handle_signal(&ksig, regs, syscall); |
385 | handle_signal(signr, &ka, &info, regs, syscall); | ||
386 | return; | 378 | return; |
387 | } | 379 | } |
388 | 380 | ||
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c index 5e04a1c899fa..79d824551c1a 100644 --- a/arch/x86/um/signal.c +++ b/arch/x86/um/signal.c | |||
@@ -370,13 +370,12 @@ struct rt_sigframe | |||
370 | char retcode[8]; | 370 | char retcode[8]; |
371 | }; | 371 | }; |
372 | 372 | ||
373 | int setup_signal_stack_sc(unsigned long stack_top, int sig, | 373 | int setup_signal_stack_sc(unsigned long stack_top, struct ksignal *ksig, |
374 | struct k_sigaction *ka, struct pt_regs *regs, | 374 | struct pt_regs *regs, sigset_t *mask) |
375 | sigset_t *mask) | ||
376 | { | 375 | { |
377 | struct sigframe __user *frame; | 376 | struct sigframe __user *frame; |
378 | void __user *restorer; | 377 | void __user *restorer; |
379 | int err = 0; | 378 | int err = 0, sig = ksig->sig; |
380 | 379 | ||
381 | /* This is the same calculation as i386 - ((sp + 4) & 15) == 0 */ | 380 | /* This is the same calculation as i386 - ((sp + 4) & 15) == 0 */ |
382 | stack_top = ((stack_top + 4) & -16UL) - 4; | 381 | stack_top = ((stack_top + 4) & -16UL) - 4; |
@@ -385,8 +384,8 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig, | |||
385 | return 1; | 384 | return 1; |
386 | 385 | ||
387 | restorer = frame->retcode; | 386 | restorer = frame->retcode; |
388 | if (ka->sa.sa_flags & SA_RESTORER) | 387 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
389 | restorer = ka->sa.sa_restorer; | 388 | restorer = ksig->ka.sa.sa_restorer; |
390 | 389 | ||
391 | err |= __put_user(restorer, &frame->pretcode); | 390 | err |= __put_user(restorer, &frame->pretcode); |
392 | err |= __put_user(sig, &frame->sig); | 391 | err |= __put_user(sig, &frame->sig); |
@@ -410,20 +409,19 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig, | |||
410 | return err; | 409 | return err; |
411 | 410 | ||
412 | PT_REGS_SP(regs) = (unsigned long) frame; | 411 | PT_REGS_SP(regs) = (unsigned long) frame; |
413 | PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; | 412 | PT_REGS_IP(regs) = (unsigned long) ksig->ka.sa.sa_handler; |
414 | PT_REGS_AX(regs) = (unsigned long) sig; | 413 | PT_REGS_AX(regs) = (unsigned long) sig; |
415 | PT_REGS_DX(regs) = (unsigned long) 0; | 414 | PT_REGS_DX(regs) = (unsigned long) 0; |
416 | PT_REGS_CX(regs) = (unsigned long) 0; | 415 | PT_REGS_CX(regs) = (unsigned long) 0; |
417 | return 0; | 416 | return 0; |
418 | } | 417 | } |
419 | 418 | ||
420 | int setup_signal_stack_si(unsigned long stack_top, int sig, | 419 | int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig, |
421 | struct k_sigaction *ka, struct pt_regs *regs, | 420 | struct pt_regs *regs, sigset_t *mask) |
422 | siginfo_t *info, sigset_t *mask) | ||
423 | { | 421 | { |
424 | struct rt_sigframe __user *frame; | 422 | struct rt_sigframe __user *frame; |
425 | void __user *restorer; | 423 | void __user *restorer; |
426 | int err = 0; | 424 | int err = 0, sig = ksig->sig; |
427 | 425 | ||
428 | stack_top &= -8UL; | 426 | stack_top &= -8UL; |
429 | frame = (struct rt_sigframe __user *) stack_top - 1; | 427 | frame = (struct rt_sigframe __user *) stack_top - 1; |
@@ -431,14 +429,14 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
431 | return 1; | 429 | return 1; |
432 | 430 | ||
433 | restorer = frame->retcode; | 431 | restorer = frame->retcode; |
434 | if (ka->sa.sa_flags & SA_RESTORER) | 432 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
435 | restorer = ka->sa.sa_restorer; | 433 | restorer = ksig->ka.sa.sa_restorer; |
436 | 434 | ||
437 | err |= __put_user(restorer, &frame->pretcode); | 435 | err |= __put_user(restorer, &frame->pretcode); |
438 | err |= __put_user(sig, &frame->sig); | 436 | err |= __put_user(sig, &frame->sig); |
439 | err |= __put_user(&frame->info, &frame->pinfo); | 437 | err |= __put_user(&frame->info, &frame->pinfo); |
440 | err |= __put_user(&frame->uc, &frame->puc); | 438 | err |= __put_user(&frame->uc, &frame->puc); |
441 | err |= copy_siginfo_to_user(&frame->info, info); | 439 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
442 | err |= copy_ucontext_to_user(&frame->uc, &frame->fpstate, mask, | 440 | err |= copy_ucontext_to_user(&frame->uc, &frame->fpstate, mask, |
443 | PT_REGS_SP(regs)); | 441 | PT_REGS_SP(regs)); |
444 | 442 | ||
@@ -457,7 +455,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
457 | return err; | 455 | return err; |
458 | 456 | ||
459 | PT_REGS_SP(regs) = (unsigned long) frame; | 457 | PT_REGS_SP(regs) = (unsigned long) frame; |
460 | PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; | 458 | PT_REGS_IP(regs) = (unsigned long) ksig->ka.sa.sa_handler; |
461 | PT_REGS_AX(regs) = (unsigned long) sig; | 459 | PT_REGS_AX(regs) = (unsigned long) sig; |
462 | PT_REGS_DX(regs) = (unsigned long) &frame->info; | 460 | PT_REGS_DX(regs) = (unsigned long) &frame->info; |
463 | PT_REGS_CX(regs) = (unsigned long) &frame->uc; | 461 | PT_REGS_CX(regs) = (unsigned long) &frame->uc; |
@@ -502,12 +500,11 @@ struct rt_sigframe | |||
502 | struct _fpstate fpstate; | 500 | struct _fpstate fpstate; |
503 | }; | 501 | }; |
504 | 502 | ||
505 | int setup_signal_stack_si(unsigned long stack_top, int sig, | 503 | int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig, |
506 | struct k_sigaction *ka, struct pt_regs * regs, | 504 | struct pt_regs *regs, sigset_t *set) |
507 | siginfo_t *info, sigset_t *set) | ||
508 | { | 505 | { |
509 | struct rt_sigframe __user *frame; | 506 | struct rt_sigframe __user *frame; |
510 | int err = 0; | 507 | int err = 0, sig = ksig->sig; |
511 | 508 | ||
512 | frame = (struct rt_sigframe __user *) | 509 | frame = (struct rt_sigframe __user *) |
513 | round_down(stack_top - sizeof(struct rt_sigframe), 16); | 510 | round_down(stack_top - sizeof(struct rt_sigframe), 16); |
@@ -517,8 +514,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
517 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 514 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
518 | goto out; | 515 | goto out; |
519 | 516 | ||
520 | if (ka->sa.sa_flags & SA_SIGINFO) { | 517 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
521 | err |= copy_siginfo_to_user(&frame->info, info); | 518 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
522 | if (err) | 519 | if (err) |
523 | goto out; | 520 | goto out; |
524 | } | 521 | } |
@@ -543,8 +540,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
543 | * already in userspace. | 540 | * already in userspace. |
544 | */ | 541 | */ |
545 | /* x86-64 should always use SA_RESTORER. */ | 542 | /* x86-64 should always use SA_RESTORER. */ |
546 | if (ka->sa.sa_flags & SA_RESTORER) | 543 | if (ksig->ka.sa.sa_flags & SA_RESTORER) |
547 | err |= __put_user(ka->sa.sa_restorer, &frame->pretcode); | 544 | err |= __put_user(ksig->ka.sa.sa_restorer, &frame->pretcode); |
548 | else | 545 | else |
549 | /* could use a vstub here */ | 546 | /* could use a vstub here */ |
550 | return err; | 547 | return err; |
@@ -570,7 +567,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
570 | */ | 567 | */ |
571 | PT_REGS_SI(regs) = (unsigned long) &frame->info; | 568 | PT_REGS_SI(regs) = (unsigned long) &frame->info; |
572 | PT_REGS_DX(regs) = (unsigned long) &frame->uc; | 569 | PT_REGS_DX(regs) = (unsigned long) &frame->uc; |
573 | PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; | 570 | PT_REGS_IP(regs) = (unsigned long) ksig->ka.sa.sa_handler; |
574 | out: | 571 | out: |
575 | return err; | 572 | return err; |
576 | } | 573 | } |
diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c index 98b67d5f1514..4612321c73cc 100644 --- a/arch/xtensa/kernel/signal.c +++ b/arch/xtensa/kernel/signal.c | |||
@@ -331,17 +331,17 @@ gen_return_code(unsigned char *codemem) | |||
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 334 | static int setup_frame(struct ksignal *ksig, sigset_t *set, |
335 | sigset_t *set, struct pt_regs *regs) | 335 | struct pt_regs *regs) |
336 | { | 336 | { |
337 | struct rt_sigframe *frame; | 337 | struct rt_sigframe *frame; |
338 | int err = 0; | 338 | int err = 0, sig = ksig->sig; |
339 | int signal; | 339 | int signal; |
340 | unsigned long sp, ra, tp; | 340 | unsigned long sp, ra, tp; |
341 | 341 | ||
342 | sp = regs->areg[1]; | 342 | sp = regs->areg[1]; |
343 | 343 | ||
344 | if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && sas_ss_flags(sp) == 0) { | 344 | if ((ksig->ka.sa.sa_flags & SA_ONSTACK) != 0 && sas_ss_flags(sp) == 0) { |
345 | sp = current->sas_ss_sp + current->sas_ss_size; | 345 | sp = current->sas_ss_sp + current->sas_ss_size; |
346 | } | 346 | } |
347 | 347 | ||
@@ -351,7 +351,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
351 | panic ("Double exception sys_sigreturn\n"); | 351 | panic ("Double exception sys_sigreturn\n"); |
352 | 352 | ||
353 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) { | 353 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) { |
354 | goto give_sigsegv; | 354 | return -EFAULT; |
355 | } | 355 | } |
356 | 356 | ||
357 | signal = current_thread_info()->exec_domain | 357 | signal = current_thread_info()->exec_domain |
@@ -360,8 +360,8 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
360 | ? current_thread_info()->exec_domain->signal_invmap[sig] | 360 | ? current_thread_info()->exec_domain->signal_invmap[sig] |
361 | : sig; | 361 | : sig; |
362 | 362 | ||
363 | if (ka->sa.sa_flags & SA_SIGINFO) { | 363 | if (ksig->ka.sa.sa_flags & SA_SIGINFO) { |
364 | err |= copy_siginfo_to_user(&frame->info, info); | 364 | err |= copy_siginfo_to_user(&frame->info, &ksig->info); |
365 | } | 365 | } |
366 | 366 | ||
367 | /* Create the user context. */ | 367 | /* Create the user context. */ |
@@ -372,8 +372,8 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
372 | err |= setup_sigcontext(frame, regs); | 372 | err |= setup_sigcontext(frame, regs); |
373 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 373 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
374 | 374 | ||
375 | if (ka->sa.sa_flags & SA_RESTORER) { | 375 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
376 | ra = (unsigned long)ka->sa.sa_restorer; | 376 | ra = (unsigned long)ksig->ka.sa.sa_restorer; |
377 | } else { | 377 | } else { |
378 | 378 | ||
379 | /* Create sys_rt_sigreturn syscall in stack frame */ | 379 | /* Create sys_rt_sigreturn syscall in stack frame */ |
@@ -381,7 +381,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
381 | err |= gen_return_code(frame->retcode); | 381 | err |= gen_return_code(frame->retcode); |
382 | 382 | ||
383 | if (err) { | 383 | if (err) { |
384 | goto give_sigsegv; | 384 | return -EFAULT; |
385 | } | 385 | } |
386 | ra = (unsigned long) frame->retcode; | 386 | ra = (unsigned long) frame->retcode; |
387 | } | 387 | } |
@@ -393,7 +393,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
393 | 393 | ||
394 | /* Set up registers for signal handler; preserve the threadptr */ | 394 | /* Set up registers for signal handler; preserve the threadptr */ |
395 | tp = regs->threadptr; | 395 | tp = regs->threadptr; |
396 | start_thread(regs, (unsigned long) ka->sa.sa_handler, | 396 | start_thread(regs, (unsigned long) ksig->ka.sa.sa_handler, |
397 | (unsigned long) frame); | 397 | (unsigned long) frame); |
398 | 398 | ||
399 | /* Set up a stack frame for a call4 | 399 | /* Set up a stack frame for a call4 |
@@ -416,10 +416,6 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
416 | #endif | 416 | #endif |
417 | 417 | ||
418 | return 0; | 418 | return 0; |
419 | |||
420 | give_sigsegv: | ||
421 | force_sigsegv(sig, current); | ||
422 | return -EFAULT; | ||
423 | } | 419 | } |
424 | 420 | ||
425 | /* | 421 | /* |
@@ -433,15 +429,11 @@ give_sigsegv: | |||
433 | */ | 429 | */ |
434 | static void do_signal(struct pt_regs *regs) | 430 | static void do_signal(struct pt_regs *regs) |
435 | { | 431 | { |
436 | siginfo_t info; | 432 | struct ksignal ksig; |
437 | int signr; | ||
438 | struct k_sigaction ka; | ||
439 | 433 | ||
440 | task_pt_regs(current)->icountlevel = 0; | 434 | task_pt_regs(current)->icountlevel = 0; |
441 | 435 | ||
442 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 436 | if (get_signal(&ksig)) { |
443 | |||
444 | if (signr > 0) { | ||
445 | int ret; | 437 | int ret; |
446 | 438 | ||
447 | /* Are we from a system call? */ | 439 | /* Are we from a system call? */ |
@@ -457,7 +449,7 @@ static void do_signal(struct pt_regs *regs) | |||
457 | break; | 449 | break; |
458 | 450 | ||
459 | case -ERESTARTSYS: | 451 | case -ERESTARTSYS: |
460 | if (!(ka.sa.sa_flags & SA_RESTART)) { | 452 | if (!(ksig.ka.sa.sa_flags & SA_RESTART)) { |
461 | regs->areg[2] = -EINTR; | 453 | regs->areg[2] = -EINTR; |
462 | break; | 454 | break; |
463 | } | 455 | } |
@@ -476,11 +468,8 @@ static void do_signal(struct pt_regs *regs) | |||
476 | 468 | ||
477 | /* Whee! Actually deliver the signal. */ | 469 | /* Whee! Actually deliver the signal. */ |
478 | /* Set up the stack frame */ | 470 | /* Set up the stack frame */ |
479 | ret = setup_frame(signr, &ka, &info, sigmask_to_save(), regs); | 471 | ret = setup_frame(&ksig, sigmask_to_save(), regs); |
480 | if (ret) | 472 | signal_setup_done(ret, &ksig, 0); |
481 | return; | ||
482 | |||
483 | signal_delivered(signr, &info, &ka, regs, 0); | ||
484 | if (current->ptrace & PT_SINGLESTEP) | 473 | if (current->ptrace & PT_SINGLESTEP) |
485 | task_pt_regs(current)->icountlevel = 1; | 474 | task_pt_regs(current)->icountlevel = 1; |
486 | 475 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index db2f6474e95e..857ba40426ba 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2360,8 +2360,10 @@ static inline int on_sig_stack(unsigned long sp) | |||
2360 | 2360 | ||
2361 | static inline int sas_ss_flags(unsigned long sp) | 2361 | static inline int sas_ss_flags(unsigned long sp) |
2362 | { | 2362 | { |
2363 | return (current->sas_ss_size == 0 ? SS_DISABLE | 2363 | if (!current->sas_ss_size) |
2364 | : on_sig_stack(sp) ? SS_ONSTACK : 0); | 2364 | return SS_DISABLE; |
2365 | |||
2366 | return on_sig_stack(sp) ? SS_ONSTACK : 0; | ||
2365 | } | 2367 | } |
2366 | 2368 | ||
2367 | static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig) | 2369 | static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig) |
diff --git a/include/linux/signal.h b/include/linux/signal.h index c9e65360c49a..750196fcc0a5 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h | |||
@@ -280,9 +280,8 @@ struct ksignal { | |||
280 | int sig; | 280 | int sig; |
281 | }; | 281 | }; |
282 | 282 | ||
283 | extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); | 283 | extern int get_signal(struct ksignal *ksig); |
284 | extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); | 284 | extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); |
285 | extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping); | ||
286 | extern void exit_signals(struct task_struct *tsk); | 285 | extern void exit_signals(struct task_struct *tsk); |
287 | extern void kernel_sigaction(int, __sighandler_t); | 286 | extern void kernel_sigaction(int, __sighandler_t); |
288 | 287 | ||
@@ -301,18 +300,6 @@ static inline void disallow_signal(int sig) | |||
301 | kernel_sigaction(sig, SIG_IGN); | 300 | kernel_sigaction(sig, SIG_IGN); |
302 | } | 301 | } |
303 | 302 | ||
304 | /* | ||
305 | * Eventually that'll replace get_signal_to_deliver(); macro for now, | ||
306 | * to avoid nastiness with include order. | ||
307 | */ | ||
308 | #define get_signal(ksig) \ | ||
309 | ({ \ | ||
310 | struct ksignal *p = (ksig); \ | ||
311 | p->sig = get_signal_to_deliver(&p->info, &p->ka, \ | ||
312 | signal_pt_regs(), NULL);\ | ||
313 | p->sig > 0; \ | ||
314 | }) | ||
315 | |||
316 | extern struct kmem_cache *sighand_cachep; | 303 | extern struct kmem_cache *sighand_cachep; |
317 | 304 | ||
318 | int unhandled_signal(struct task_struct *tsk, int sig); | 305 | int unhandled_signal(struct task_struct *tsk, int sig); |
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 6f8ab7da27c4..84d497297c5f 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h | |||
@@ -133,10 +133,6 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) | |||
133 | 133 | ||
134 | /** | 134 | /** |
135 | * tracehook_signal_handler - signal handler setup is complete | 135 | * tracehook_signal_handler - signal handler setup is complete |
136 | * @sig: number of signal being delivered | ||
137 | * @info: siginfo_t of signal being delivered | ||
138 | * @ka: sigaction setting that chose the handler | ||
139 | * @regs: user register state | ||
140 | * @stepping: nonzero if debugger single-step or block-step in use | 136 | * @stepping: nonzero if debugger single-step or block-step in use |
141 | * | 137 | * |
142 | * Called by the arch code after a signal handler has been set up. | 138 | * Called by the arch code after a signal handler has been set up. |
@@ -146,9 +142,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step) | |||
146 | * Called without locks, shortly before returning to user mode | 142 | * Called without locks, shortly before returning to user mode |
147 | * (or handling more signals). | 143 | * (or handling more signals). |
148 | */ | 144 | */ |
149 | static inline void tracehook_signal_handler(int sig, siginfo_t *info, | 145 | static inline void tracehook_signal_handler(int stepping) |
150 | const struct k_sigaction *ka, | ||
151 | struct pt_regs *regs, int stepping) | ||
152 | { | 146 | { |
153 | if (stepping) | 147 | if (stepping) |
154 | ptrace_notify(SIGTRAP); | 148 | ptrace_notify(SIGTRAP); |
diff --git a/kernel/signal.c b/kernel/signal.c index 40b76e351e64..8f0876f9f6dd 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2170,8 +2170,7 @@ static int ptrace_signal(int signr, siginfo_t *info) | |||
2170 | return signr; | 2170 | return signr; |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, | 2173 | int get_signal(struct ksignal *ksig) |
2174 | struct pt_regs *regs, void *cookie) | ||
2175 | { | 2174 | { |
2176 | struct sighand_struct *sighand = current->sighand; | 2175 | struct sighand_struct *sighand = current->sighand; |
2177 | struct signal_struct *signal = current->signal; | 2176 | struct signal_struct *signal = current->signal; |
@@ -2241,13 +2240,13 @@ relock: | |||
2241 | goto relock; | 2240 | goto relock; |
2242 | } | 2241 | } |
2243 | 2242 | ||
2244 | signr = dequeue_signal(current, ¤t->blocked, info); | 2243 | signr = dequeue_signal(current, ¤t->blocked, &ksig->info); |
2245 | 2244 | ||
2246 | if (!signr) | 2245 | if (!signr) |
2247 | break; /* will return 0 */ | 2246 | break; /* will return 0 */ |
2248 | 2247 | ||
2249 | if (unlikely(current->ptrace) && signr != SIGKILL) { | 2248 | if (unlikely(current->ptrace) && signr != SIGKILL) { |
2250 | signr = ptrace_signal(signr, info); | 2249 | signr = ptrace_signal(signr, &ksig->info); |
2251 | if (!signr) | 2250 | if (!signr) |
2252 | continue; | 2251 | continue; |
2253 | } | 2252 | } |
@@ -2255,13 +2254,13 @@ relock: | |||
2255 | ka = &sighand->action[signr-1]; | 2254 | ka = &sighand->action[signr-1]; |
2256 | 2255 | ||
2257 | /* Trace actually delivered signals. */ | 2256 | /* Trace actually delivered signals. */ |
2258 | trace_signal_deliver(signr, info, ka); | 2257 | trace_signal_deliver(signr, &ksig->info, ka); |
2259 | 2258 | ||
2260 | if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ | 2259 | if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ |
2261 | continue; | 2260 | continue; |
2262 | if (ka->sa.sa_handler != SIG_DFL) { | 2261 | if (ka->sa.sa_handler != SIG_DFL) { |
2263 | /* Run the handler. */ | 2262 | /* Run the handler. */ |
2264 | *return_ka = *ka; | 2263 | ksig->ka = *ka; |
2265 | 2264 | ||
2266 | if (ka->sa.sa_flags & SA_ONESHOT) | 2265 | if (ka->sa.sa_flags & SA_ONESHOT) |
2267 | ka->sa.sa_handler = SIG_DFL; | 2266 | ka->sa.sa_handler = SIG_DFL; |
@@ -2311,7 +2310,7 @@ relock: | |||
2311 | spin_lock_irq(&sighand->siglock); | 2310 | spin_lock_irq(&sighand->siglock); |
2312 | } | 2311 | } |
2313 | 2312 | ||
2314 | if (likely(do_signal_stop(info->si_signo))) { | 2313 | if (likely(do_signal_stop(ksig->info.si_signo))) { |
2315 | /* It released the siglock. */ | 2314 | /* It released the siglock. */ |
2316 | goto relock; | 2315 | goto relock; |
2317 | } | 2316 | } |
@@ -2332,7 +2331,7 @@ relock: | |||
2332 | 2331 | ||
2333 | if (sig_kernel_coredump(signr)) { | 2332 | if (sig_kernel_coredump(signr)) { |
2334 | if (print_fatal_signals) | 2333 | if (print_fatal_signals) |
2335 | print_fatal_signal(info->si_signo); | 2334 | print_fatal_signal(ksig->info.si_signo); |
2336 | proc_coredump_connector(current); | 2335 | proc_coredump_connector(current); |
2337 | /* | 2336 | /* |
2338 | * If it was able to dump core, this kills all | 2337 | * If it was able to dump core, this kills all |
@@ -2342,34 +2341,32 @@ relock: | |||
2342 | * first and our do_group_exit call below will use | 2341 | * first and our do_group_exit call below will use |
2343 | * that value and ignore the one we pass it. | 2342 | * that value and ignore the one we pass it. |
2344 | */ | 2343 | */ |
2345 | do_coredump(info); | 2344 | do_coredump(&ksig->info); |
2346 | } | 2345 | } |
2347 | 2346 | ||
2348 | /* | 2347 | /* |
2349 | * Death signals, no core dump. | 2348 | * Death signals, no core dump. |
2350 | */ | 2349 | */ |
2351 | do_group_exit(info->si_signo); | 2350 | do_group_exit(ksig->info.si_signo); |
2352 | /* NOTREACHED */ | 2351 | /* NOTREACHED */ |
2353 | } | 2352 | } |
2354 | spin_unlock_irq(&sighand->siglock); | 2353 | spin_unlock_irq(&sighand->siglock); |
2355 | return signr; | 2354 | |
2355 | ksig->sig = signr; | ||
2356 | return ksig->sig > 0; | ||
2356 | } | 2357 | } |
2357 | 2358 | ||
2358 | /** | 2359 | /** |
2359 | * signal_delivered - | 2360 | * signal_delivered - |
2360 | * @sig: number of signal being delivered | 2361 | * @ksig: kernel signal struct |
2361 | * @info: siginfo_t of signal being delivered | ||
2362 | * @ka: sigaction setting that chose the handler | ||
2363 | * @regs: user register state | ||
2364 | * @stepping: nonzero if debugger single-step or block-step in use | 2362 | * @stepping: nonzero if debugger single-step or block-step in use |
2365 | * | 2363 | * |
2366 | * This function should be called when a signal has successfully been | 2364 | * This function should be called when a signal has successfully been |
2367 | * delivered. It updates the blocked signals accordingly (@ka->sa.sa_mask | 2365 | * delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask |
2368 | * is always blocked, and the signal itself is blocked unless %SA_NODEFER | 2366 | * is always blocked, and the signal itself is blocked unless %SA_NODEFER |
2369 | * is set in @ka->sa.sa_flags. Tracing is notified. | 2367 | * is set in @ksig->ka.sa.sa_flags. Tracing is notified. |
2370 | */ | 2368 | */ |
2371 | void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, | 2369 | static void signal_delivered(struct ksignal *ksig, int stepping) |
2372 | struct pt_regs *regs, int stepping) | ||
2373 | { | 2370 | { |
2374 | sigset_t blocked; | 2371 | sigset_t blocked; |
2375 | 2372 | ||
@@ -2379,11 +2376,11 @@ void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
2379 | simply clear the restore sigmask flag. */ | 2376 | simply clear the restore sigmask flag. */ |
2380 | clear_restore_sigmask(); | 2377 | clear_restore_sigmask(); |
2381 | 2378 | ||
2382 | sigorsets(&blocked, ¤t->blocked, &ka->sa.sa_mask); | 2379 | sigorsets(&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask); |
2383 | if (!(ka->sa.sa_flags & SA_NODEFER)) | 2380 | if (!(ksig->ka.sa.sa_flags & SA_NODEFER)) |
2384 | sigaddset(&blocked, sig); | 2381 | sigaddset(&blocked, ksig->sig); |
2385 | set_current_blocked(&blocked); | 2382 | set_current_blocked(&blocked); |
2386 | tracehook_signal_handler(sig, info, ka, regs, stepping); | 2383 | tracehook_signal_handler(stepping); |
2387 | } | 2384 | } |
2388 | 2385 | ||
2389 | void signal_setup_done(int failed, struct ksignal *ksig, int stepping) | 2386 | void signal_setup_done(int failed, struct ksignal *ksig, int stepping) |
@@ -2391,8 +2388,7 @@ void signal_setup_done(int failed, struct ksignal *ksig, int stepping) | |||
2391 | if (failed) | 2388 | if (failed) |
2392 | force_sigsegv(ksig->sig, current); | 2389 | force_sigsegv(ksig->sig, current); |
2393 | else | 2390 | else |
2394 | signal_delivered(ksig->sig, &ksig->info, &ksig->ka, | 2391 | signal_delivered(ksig, stepping); |
2395 | signal_pt_regs(), stepping); | ||
2396 | } | 2392 | } |
2397 | 2393 | ||
2398 | /* | 2394 | /* |