From patchwork Mon Jun 9 12:46:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 31553 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 35E7E21330 for ; Mon, 9 Jun 2014 12:51:58 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id us18sf14214155veb.6 for ; Mon, 09 Jun 2014 05:51:58 -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:cc: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=/a5p5vpvREJdyeh35pAJujg58H5PBJoHWMcJGzqnOHQ=; b=bl8/QScxtP25UYC9K3pKAHKf3VRNGFI6YZG/pDWeNZnq+/+Ylr51gKLsqMuUXE51Ke XIcXCd93nH7K5PVs6Hqpyfdk/dV2ISrAxZ43yncsnaDaJ7BljihthGw2E4FsCgB8NGzc teaU/a3mZmKBcHeRzZ07m7WGhG22zbEYW0709f2vKbrBJAB2qJUGY5Ccjqkl7khbtBJG /yXdN7W42c+PV5q7Nizwfz9THIh2Hq1YTJUcPCGl0CsziV6EtEM4vvEx3qly4u7NTLyd sGgn5Dtiju1DIm1ILsy7WJFSJjNsB7goonC2l+XUBWD06/ZTgbSNG2g2c7KdRrHz8z2p 0ZDQ== X-Gm-Message-State: ALoCoQmb96U29BwOmbxaeiwgi2KvMmZoTkqwmDMXb0nqIGi+ncoMyCY5FML6N5l0Sdz8kyz+KYhS X-Received: by 10.58.218.232 with SMTP id pj8mr2183064vec.3.1402318318036; Mon, 09 Jun 2014 05:51:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.1 with SMTP id p1ls1546019qga.97.gmail; Mon, 09 Jun 2014 05:51:57 -0700 (PDT) X-Received: by 10.52.93.201 with SMTP id cw9mr428117vdb.80.1402318317788; Mon, 09 Jun 2014 05:51:57 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id d9si10564489vcq.66.2014.06.09.05.51.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Jun 2014 05:51:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id ij19so703579vcb.36 for ; Mon, 09 Jun 2014 05:51:57 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr26143704vcb.0.1402318317706; Mon, 09 Jun 2014 05:51:57 -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.221.54.6 with SMTP id vs6csp143531vcb; Mon, 9 Jun 2014 05:51:57 -0700 (PDT) X-Received: by 10.140.86.99 with SMTP id o90mr30416605qgd.14.1402318316740; Mon, 09 Jun 2014 05:51:56 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j7si23535977qaa.114.2014.06.09.05.51.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 09 Jun 2014 05:51:56 -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]:60880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wtz3M-00042D-9R for patch@linaro.org; Mon, 09 Jun 2014 08:51:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtyyU-0005cR-0F for qemu-devel@nongnu.org; Mon, 09 Jun 2014 08:46:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WtyyN-0007hV-5w for qemu-devel@nongnu.org; Mon, 09 Jun 2014 08:46:53 -0400 Received: from afflict.kos.to ([92.243.29.197]:40156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtyyM-0007gb-R3 for qemu-devel@nongnu.org; Mon, 09 Jun 2014 08:46:47 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id C90D52654D; Mon, 9 Jun 2014 14:46:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 9 Jun 2014 15:46:33 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: peter.maydell@linaro.org, Riku Voipio Subject: [Qemu-devel] [PULL 08/18] signal/all/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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) 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. v3: remove unneccesary sigsegv label as suggested by Peter Signed-off-by: Riku Voipio Reviewed-by: Peter Maydell --- linux-user/signal.c | 59 ++++++++++++++++------------------------------------- 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 4a8d1d2..8a9e119 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1096,11 +1096,9 @@ long do_sigreturn(CPUX86State *env) if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; /* 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); @@ -1896,12 +1894,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); @@ -1918,7 +1914,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; } @@ -2985,8 +2980,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); @@ -3627,11 +3621,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); @@ -3644,7 +3636,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); } @@ -3802,11 +3793,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); @@ -3815,7 +3804,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); } @@ -4323,9 +4311,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? */ @@ -4338,7 +4324,6 @@ long do_sigreturn(CPUS390XState *env) return env->regs[2]; badframe: - unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } @@ -4879,15 +4864,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)) @@ -5282,12 +5265,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); @@ -5301,7 +5282,6 @@ long do_sigreturn(CPUM68KState *env) return d0; badframe: - unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; } @@ -5556,9 +5536,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); @@ -5568,7 +5546,6 @@ long do_sigreturn(CPUAlphaState *env) return env->ir[IR_V0]; badframe: - unlock_user_struct(sc, sc_addr, 0); force_sig(TARGET_SIGSEGV); }