qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@linaro.org>
Subject: [Qemu-devel] [PATCH v2 08/13] signal/all/do_sigreturn - remove __get_user checks
Date: Fri,  6 Jun 2014 12:46:52 +0300	[thread overview]
Message-ID: <1402048017-30604-9-git-send-email-riku.voipio@linaro.org> (raw)

From: Riku Voipio <riku.voipio@linaro.org>

Remove "if(__get_user" checks and their related error paths
for all architecture's do_sigreturn. Remove the unlock_user_struct
when the only way to end up there is from failed lock_user_struct.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/signal.c | 62 +++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 42 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 56d6e29..8edf1f9 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1094,13 +1094,11 @@ long do_sigreturn(CPUX86State *env)
     fprintf(stderr, "do_sigreturn\n");
 #endif
     if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
-        goto badframe;
+        goto sigsegv;
     /* set blocked signals */
-    if (__get_user(target_set.sig[0], &frame->sc.oldmask))
-        goto badframe;
+    __get_user(target_set.sig[0], &frame->sc.oldmask);
     for(i = 1; i < TARGET_NSIG_WORDS; i++) {
-        if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
-            goto badframe;
+        __get_user(target_set.sig[i], &frame->extramask[i - 1]);
     }
 
     target_to_host_sigset_internal(&set, &target_set);
@@ -1114,6 +1112,7 @@ long do_sigreturn(CPUX86State *env)
 
 badframe:
     unlock_user_struct(frame, frame_addr, 0);
+sigsegv:
     force_sig(TARGET_SIGSEGV);
     return 0;
 }
@@ -1885,12 +1884,10 @@ static long do_sigreturn_v1(CPUARMState *env)
 	if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
                 goto badframe;
 
-	if (__get_user(set.sig[0], &frame->sc.oldmask))
-            goto badframe;
-        for(i = 1; i < TARGET_NSIG_WORDS; i++) {
-            if (__get_user(set.sig[i], &frame->extramask[i - 1]))
-                goto badframe;
-        }
+    __get_user(set.sig[0], &frame->sc.oldmask);
+    for(i = 1; i < TARGET_NSIG_WORDS; i++) {
+        __get_user(set.sig[i], &frame->extramask[i - 1]);
+    }
 
         target_to_host_sigset_internal(&host_set, &set);
         do_sigprocmask(SIG_SETMASK, &host_set, NULL);
@@ -1906,7 +1903,6 @@ static long do_sigreturn_v1(CPUARMState *env)
         return env->regs[0];
 
 badframe:
-	unlock_user_struct(frame, frame_addr, 0);
         force_sig(TARGET_SIGSEGV /* , current */);
 	return 0;
 }
@@ -2971,8 +2967,7 @@ long do_sigreturn(CPUMIPSState *regs)
    	goto badframe;
 
     for(i = 0; i < TARGET_NSIG_WORDS; i++) {
-   	if(__get_user(target_set.sig[i], &frame->sf_mask.sig[i]))
-	    goto badframe;
+        __get_user(target_set.sig[i], &frame->sf_mask.sig[i]);
     }
 
     target_to_host_sigset_internal(&blocked, &target_set);
@@ -3613,11 +3608,9 @@ long do_sigreturn(CPUMBState *env)
         goto badframe;
 
     /* Restore blocked signals */
-    if (__get_user(target_set.sig[0], &frame->uc.tuc_mcontext.oldmask))
-        goto badframe;
+    __get_user(target_set.sig[0], &frame->uc.tuc_mcontext.oldmask);
     for(i = 1; i < TARGET_NSIG_WORDS; i++) {
-        if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
-            goto badframe;
+       __get_user(target_set.sig[i], &frame->extramask[i - 1]);
     }
     target_to_host_sigset_internal(&set, &target_set);
     do_sigprocmask(SIG_SETMASK, &set, NULL);
@@ -3630,7 +3623,6 @@ long do_sigreturn(CPUMBState *env)
     unlock_user_struct(frame, frame_addr, 0);
     return env->regs[10];
   badframe:
-    unlock_user_struct(frame, frame_addr, 0);
     force_sig(TARGET_SIGSEGV);
 }
 
@@ -3788,11 +3780,9 @@ long do_sigreturn(CPUCRISState *env)
 		goto badframe;
 
 	/* Restore blocked signals */
-	if (__get_user(target_set.sig[0], &frame->sc.oldmask))
-		goto badframe;
+    __get_user(target_set.sig[0], &frame->sc.oldmask);
 	for(i = 1; i < TARGET_NSIG_WORDS; i++) {
-		if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
-			goto badframe;
+        __get_user(target_set.sig[i], &frame->extramask[i - 1]);
 	}
 	target_to_host_sigset_internal(&set, &target_set);
         do_sigprocmask(SIG_SETMASK, &set, NULL);
@@ -3801,7 +3791,6 @@ long do_sigreturn(CPUCRISState *env)
 	unlock_user_struct(frame, frame_addr, 0);
 	return env->regs[10];
   badframe:
-	unlock_user_struct(frame, frame_addr, 0);
 	force_sig(TARGET_SIGSEGV);
 }
 
@@ -4309,9 +4298,7 @@ long do_sigreturn(CPUS390XState *env)
     if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
         goto badframe;
     }
-    if (__get_user(target_set.sig[0], &frame->sc.oldmask[0])) {
-        goto badframe;
-    }
+    __get_user(target_set.sig[0], &frame->sc.oldmask[0]);
 
     target_to_host_sigset_internal(&set, &target_set);
     do_sigprocmask(SIG_SETMASK, &set, NULL); /* ~_BLOCKABLE? */
@@ -4324,7 +4311,6 @@ long do_sigreturn(CPUS390XState *env)
     return env->regs[2];
 
 badframe:
-    unlock_user_struct(frame, frame_addr, 0);
     force_sig(TARGET_SIGSEGV);
     return 0;
 }
@@ -4865,15 +4851,13 @@ long do_sigreturn(CPUPPCState *env)
 #if defined(TARGET_PPC64)
     set.sig[0] = sc->oldmask + ((long)(sc->_unused[3]) << 32);
 #else
-    if(__get_user(set.sig[0], &sc->oldmask) ||
-       __get_user(set.sig[1], &sc->_unused[3]))
-       goto sigsegv;
+    __get_user(set.sig[0], &sc->oldmask);
+    __get_user(set.sig[1], &sc->_unused[3]);
 #endif
     target_to_host_sigset_internal(&blocked, &set);
     do_sigprocmask(SIG_SETMASK, &blocked, NULL);
 
-    if (__get_user(sr_addr, &sc->regs))
-        goto sigsegv;
+    __get_user(sr_addr, &sc->regs);
     if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1))
         goto sigsegv;
     if (restore_user_regs(env, sr, 1))
@@ -5268,12 +5252,10 @@ long do_sigreturn(CPUM68KState *env)
 
     /* set blocked signals */
 
-    if (__get_user(target_set.sig[0], &frame->sc.sc_mask))
-        goto badframe;
+    __get_user(target_set.sig[0], &frame->sc.sc_mask);
 
     for(i = 1; i < TARGET_NSIG_WORDS; i++) {
-        if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
-            goto badframe;
+        __get_user(target_set.sig[i], &frame->extramask[i - 1]);
     }
 
     target_to_host_sigset_internal(&set, &target_set);
@@ -5287,7 +5269,6 @@ long do_sigreturn(CPUM68KState *env)
     return d0;
 
 badframe:
-    unlock_user_struct(frame, frame_addr, 0);
     force_sig(TARGET_SIGSEGV);
     return 0;
 }
@@ -5542,9 +5523,7 @@ long do_sigreturn(CPUAlphaState *env)
     }
 
     target_sigemptyset(&target_set);
-    if (__get_user(target_set.sig[0], &sc->sc_mask)) {
-        goto badframe;
-    }
+    __get_user(target_set.sig[0], &sc->sc_mask);
 
     target_to_host_sigset_internal(&set, &target_set);
     do_sigprocmask(SIG_SETMASK, &set, NULL);
@@ -5554,7 +5533,6 @@ long do_sigreturn(CPUAlphaState *env)
     return env->ir[IR_V0];
 
  badframe:
-    unlock_user_struct(sc, sc_addr, 0);
     force_sig(TARGET_SIGSEGV);
 }
 
-- 
2.0.0.rc2

             reply	other threads:[~2014-06-06  9:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06  9:46 riku.voipio [this message]
2014-06-07 21:34 ` [Qemu-devel] [PATCH v2 08/13] signal/all/do_sigreturn - remove __get_user checks Peter Maydell
2014-06-09 12:15   ` [Qemu-devel] [PATCH v3] " riku.voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402048017-30604-9-git-send-email-riku.voipio@linaro.org \
    --to=riku.voipio@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).