Skip to content

Commit e239074

Browse files
author
Al Viro
committed
x86: ia32_setup_frame(): consolidate uaccess areas
Currently we have user_access block, followed by __put_user(), deciding what the restorer will be and finally a put_user_try block. Moving the calculation of restorer first allows the rest (actual copyout work) to coalesce into a single user_access block. Signed-off-by: Al Viro <[email protected]>
1 parent 44a1d99 commit e239074

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

arch/x86/ia32/ia32_signal.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
236236
{
237237
struct sigframe_ia32 __user *frame;
238238
void __user *restorer;
239-
int err = 0;
240239
void __user *fp = NULL;
241240

242241
/* copy_to_user optimizes that into a single 8 byte store */
@@ -252,21 +251,6 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
252251

253252
frame = get_sigframe(ksig, regs, sizeof(*frame), &fp);
254253

255-
if (!access_ok(frame, sizeof(*frame)))
256-
return -EFAULT;
257-
258-
if (__put_user(sig, &frame->sig))
259-
return -EFAULT;
260-
261-
if (!user_access_begin(&frame->sc, sizeof(struct sigcontext_32)))
262-
return -EFAULT;
263-
264-
unsafe_put_sigcontext32(&frame->sc, fp, regs, set, Efault);
265-
user_access_end();
266-
267-
if (__put_user(set->sig[1], &frame->extramask[0]))
268-
return -EFAULT;
269-
270254
if (ksig->ka.sa.sa_flags & SA_RESTORER) {
271255
restorer = ksig->ka.sa.sa_restorer;
272256
} else {
@@ -278,19 +262,20 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
278262
restorer = &frame->retcode;
279263
}
280264

281-
put_user_try {
282-
put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
283-
284-
/*
285-
* These are actually not used anymore, but left because some
286-
* gdb versions depend on them as a marker.
287-
*/
288-
put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
289-
} put_user_catch(err);
290-
291-
if (err)
265+
if (!user_access_begin(frame, sizeof(*frame)))
292266
return -EFAULT;
293267

268+
unsafe_put_user(sig, &frame->sig, Efault);
269+
unsafe_put_sigcontext32(&frame->sc, fp, regs, set, Efault);
270+
unsafe_put_user(set->sig[1], &frame->extramask[0], Efault);
271+
unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
272+
/*
273+
* These are actually not used anymore, but left because some
274+
* gdb versions depend on them as a marker.
275+
*/
276+
unsafe_put_user(*((u64 *)&code), (u64 __user *)frame->retcode, Efault);
277+
user_access_end();
278+
294279
/* Set up registers for signal handler */
295280
regs->sp = (unsigned long) frame;
296281
regs->ip = (unsigned long) ksig->ka.sa.sa_handler;

0 commit comments

Comments
 (0)