From patchwork Wed Apr 23 13:11:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 28885 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 31A6A2057C for ; Wed, 23 Apr 2014 13:14:46 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf3829857yha.3 for ; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=SyHfWhi4YJBhysApA5Skqn5o9Mx+bPgq00x1MqLeofg=; b=dxI9fA+E9NFKG1XPv5VqaMxc9h1cCpTV4rjNV7mZ94+mnUdcjgsMV6pO5A4V/ovpmk V4jLWiVr3JeZnvhX+5Tck5wC1yRh2jD/ovAxKms97QHWWHUmXg5Zno6RKQb8uNRg6A0h FWv3U57/4YDwMVdyaL4pUwPgnYgiiMoPrS5EvDscM53zYHs0Bc+MshidY23MoptWSPLs XWzeheM28LpnRDNOISVrbEqcVkAPzlTojOwyHoxIXGuDpNjYud3Yd2O8zsZEs+KALJGO /2TU/BkrkU3HNkgMVQKu/LNlK0qPevHio90jSSvrzIytiEQXlp6xM6bXpRUP1HMT1etR hs4A== X-Gm-Message-State: ALoCoQnQP8NVg43u3xLDqQ6DxIIab3AkeftNfdrSh3z67PmxQQjaRMaR/cl1KcxljLpZqoacZatE X-Received: by 10.58.18.200 with SMTP id y8mr24516407ved.20.1398258885826; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.133 with SMTP id t5ls555933qgt.43.gmail; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) X-Received: by 10.220.92.193 with SMTP id s1mr210661vcm.34.1398258885662; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id sn5si155863vdc.155.2014.04.23.06.14.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 06:14:45 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so1083822veb.18 for ; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) X-Received: by 10.53.1.69 with SMTP id be5mr12033137vdd.27.1398258885528; Wed, 23 Apr 2014 06:14:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp103061vcb; Wed, 23 Apr 2014 06:14:44 -0700 (PDT) X-Received: by 10.140.30.99 with SMTP id c90mr32379139qgc.13.1398258883687; Wed, 23 Apr 2014 06:14:43 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j6si418253qan.170.2014.04.23.06.14.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Apr 2014 06:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:60882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcx0d-0000gI-5E for patch@linaro.org; Wed, 23 Apr 2014 09:14:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcwyE-0001ko-Mw for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wcwy8-0001Je-LN for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:14 -0400 Received: from afflict.kos.to ([92.243.29.197]:42804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcwy8-0001Ij-AW for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:12:08 -0400 Received: from localhost.localdomain (afflict [92.243.29.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 10FC5264D6 for ; Wed, 23 Apr 2014 15:12:06 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 23 Apr 2014 16:11:59 +0300 Message-Id: <29d04f625529a93f1ab43554cbbbde8874375830.1398257165.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Subject: [Qemu-devel] [PATCH 08/13] do_sigreturn - remove __get_user checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio 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 --- 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 9118597..2c717b8 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; } @@ -1886,12 +1885,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); @@ -1907,7 +1904,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; } @@ -3004,8 +3000,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); @@ -3646,11 +3641,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); @@ -3663,7 +3656,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); } @@ -3821,11 +3813,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); @@ -3834,7 +3824,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); } @@ -4342,9 +4331,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? */ @@ -4357,7 +4344,6 @@ long do_sigreturn(CPUS390XState *env) return env->regs[2]; badframe: - unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } @@ -4898,15 +4884,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)) @@ -5301,12 +5285,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); @@ -5320,7 +5302,6 @@ long do_sigreturn(CPUM68KState *env) return d0; badframe: - unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } @@ -5575,9 +5556,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); @@ -5587,7 +5566,6 @@ long do_sigreturn(CPUAlphaState *env) return env->ir[IR_V0]; badframe: - unlock_user_struct(sc, sc_addr, 0); force_sig(TARGET_SIGSEGV); }