From patchwork Tue Aug 26 14:13:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 36033 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B5B02054F for ; Tue, 26 Aug 2014 14:16:43 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id m1sf88258401oag.11 for ; Tue, 26 Aug 2014 07:16:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=VShTM2z/K4l2cRxm+wob92lXC/R6Wprx6b7fux0zHyE=; b=fcImVr+uECfpsdgzUkF79IbOJUI5QxAhFLB2ONJrn1wx5qfWvKEM3vCnguppU2nwcj tq0N7XLfyTJyVGT8TEzC8ui5fhJ6qr8Se+prPBti7ejXXE+icTtHFh1tq1EN5pItU98t cPQPHzXyEAd72/NSbB2DuN+Sm4NiP06aIPSVZeXPgah0UY0OFysns0Zx4JBuJQBguYwt hiOIkmkxJSeoMn7kpREm51BvL0qu1XckmXfuwGe1n0k8nXPEI1wFVMJX6A9GJXfGhkSW sucr0N+bEjUOC6UC+5ghDf+ryfsZa5hRO21O3YA14L/0jUr8cnzk3zQIgDJRHFOCAOV/ 1VnA== X-Gm-Message-State: ALoCoQm95Kf1EBxLTH38DELS4KUzXMWGBkcjUWBveDIViOqN7md289S4Lbug6RstJmCSNz77fIoM X-Received: by 10.42.38.15 with SMTP id a15mr21848495ice.30.1409062602087; Tue, 26 Aug 2014 07:16:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.136 with SMTP id e8ls2486658qgf.36.gmail; Tue, 26 Aug 2014 07:16:41 -0700 (PDT) X-Received: by 10.236.220.101 with SMTP id n95mr43787364yhp.63.1409062601813; Tue, 26 Aug 2014 07:16:41 -0700 (PDT) Received: from mail-yh0-f52.google.com (mail-yh0-f52.google.com [209.85.213.52]) by mx.google.com with ESMTPS id p10si2621976yhd.51.2014.08.26.07.16.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 07:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.213.52 as permitted sender) client-ip=209.85.213.52; Received: by mail-yh0-f52.google.com with SMTP id t59so11877549yho.11 for ; Tue, 26 Aug 2014 07:16:41 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr20350640vdb.8.1409062601687; Tue, 26 Aug 2014 07:16:41 -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.45.67 with SMTP id uj3csp202843vcb; Tue, 26 Aug 2014 07:16:41 -0700 (PDT) X-Received: by 10.68.57.165 with SMTP id j5mr20254638pbq.147.1409062600838; Tue, 26 Aug 2014 07:16:40 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f5si4786396pdo.42.2014.08.26.07.16.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 07:16:40 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMHX2-0003eR-6a; Tue, 26 Aug 2014 14:15:32 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMHVG-00087X-PT for linux-arm-kernel@lists.infradead.org; Tue, 26 Aug 2014 14:13:44 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.34]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s7QEDHwo011793; Tue, 26 Aug 2014 15:13:17 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 6C9721AE064E; Tue, 26 Aug 2014 15:13:37 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/11] KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg Date: Tue, 26 Aug 2014 15:13:23 +0100 Message-Id: <1409062410-25891-5-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.0.rc1 In-Reply-To: <1409062410-25891-1-git-send-email-will.deacon@arm.com> References: <1409062410-25891-1-git-send-email-will.deacon@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140826_071343_203425_9B67D191 X-CRM114-Status: GOOD ( 11.43 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: Marc Zyngier , catalin.marinas@arm.com, Will Deacon , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.213.52 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 We currently return the number of bytes not copied if set_timer_reg fails, which is almost certainly not what userspace would like. This patch returns -EFAULT instead. Cc: Christoffer Dall Cc: Marc Zyngier Signed-off-by: Will Deacon Acked-by: Marc Zyngier Acked-by: Christoffer Dall --- arch/arm/kvm/guest.c | 2 +- arch/arm64/kvm/guest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c index 813e49258690..cc0b78769bd8 100644 --- a/arch/arm/kvm/guest.c +++ b/arch/arm/kvm/guest.c @@ -163,7 +163,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)); if (ret != 0) - return ret; + return -EFAULT; return kvm_arm_timer_set_reg(vcpu, reg->id, val); } diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 8d1ec2887a26..76794692c20b 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -174,7 +174,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)); if (ret != 0) - return ret; + return -EFAULT; return kvm_arm_timer_set_reg(vcpu, reg->id, val); }