Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3720317pxv; Mon, 26 Jul 2021 10:11:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLO6gC9nEKTfrP8oagnyY7qC4katBcxSAZAfFHCUh2P6y3jajMQJCMm2KyN6luDkGhVygU X-Received: by 2002:a17:906:4a59:: with SMTP id a25mr4383988ejv.483.1627319402686; Mon, 26 Jul 2021 10:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319402; cv=none; d=google.com; s=arc-20160816; b=NXDPJWFFY6dWO9eQjTyEqDJ/2nJJlh7N1Y1UX+F+8KOwMTKturWUjO41v5dcdm9ySL rxfT7pJaV6Hbr75BeOt+80kPdaaLi5nKuMxoIS3FTXVZ4wtySBBxCKXTKgJsKoM601Io rnENXevXDLV7xP6GnUcu847146+nrAxjMWB4v91QWnuF50M00E3u4SL7TzwnRnu69Vkc 8UvGM0g+F92nVS+6PkRZ+cLxiqAEeQ4WzJwZZNpLetHOmyhDQ96tZ92kf2gGBG7NICvJ t0oPEfLmhpenaMu6Azc0/cCo8HTGkKv4qmo71Dh8DgBw9ywWB/WMJish3p9CWtoDmdMW 4ywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ggo5CsL2pken4WgUG99uzJgH6BXtfPLpuiGUhya3/rE=; b=02Wq4Ai0VQzQsYCstwFJiuEGb/uS7A7FA0gZ/lUy82t/oibEVmkp7KGcNhG+YWounX qNWqCH079GlcpXF4JJDuESsaawM8zOuTq2LMOaRKPH0k7YoIVlWhZ027g2eZtw242h+y ok0xqsWJE8eluj7Q43Ixi28AMDKDLVQAbBS55d0GctgfuiWYtN2kXJPG8npUvPhVu7fs T3TRrOGjn4XHzLf8cqFohUxMNEfZLCJuj/49tWrZ902cPvbxAv85TTJcB7Clb6OSY4Ki vggxIVNt3i2qUurp+srnb2A5Z+qh5BpJzIL8h3OUp5UzCpgXqEPnJ/eiKu7xSYfUc2hK dZLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g4yEHjx0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si450253edr.479.2021.07.26.10.09.36; Mon, 26 Jul 2021 10:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g4yEHjx0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238431AbhGZPnC (ORCPT + 99 others); Mon, 26 Jul 2021 11:43:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237552AbhGZPXz (ORCPT ); Mon, 26 Jul 2021 11:23:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4BFF760F5B; Mon, 26 Jul 2021 16:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315462; bh=ZA+CXvK/os7wFu3ZdUkdH6+y724OSWlmvqIhKcTXMFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g4yEHjx0KejB7vaPNRaOveIKrIca0q1eF6pge00POXou1SsG5S/1nUYlnBKpN27NI zxxDxYPXRFAL64JYpQWvTOsa2zNLWhJAYr9RPi7z31PfG92Dy+ULAydohMKssRz0bX 1UxIW3YSbA8zLk3lJ3y9QGxlWJncYF25OppRgqsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , Nicholas Piggin , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 071/167] KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak Date: Mon, 26 Jul 2021 17:38:24 +0200 Message-Id: <20210726153841.781414902@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Piggin [ Upstream commit bc4188a2f56e821ea057aca6bf444e138d06c252 ] vcpu_put is not called if the user copy fails. This can result in preempt notifier corruption and crashes, among other issues. Fixes: b3cebfe8c1ca ("KVM: PPC: Move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl") Reported-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210716024310.164448-2-npiggin@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/kvm/powerpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 32fa0fa3d4ff..543db9157f3b 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -2041,9 +2041,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, { struct kvm_enable_cap cap; r = -EFAULT; - vcpu_load(vcpu); if (copy_from_user(&cap, argp, sizeof(cap))) goto out; + vcpu_load(vcpu); r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); vcpu_put(vcpu); break; @@ -2067,9 +2067,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, case KVM_DIRTY_TLB: { struct kvm_dirty_tlb dirty; r = -EFAULT; - vcpu_load(vcpu); if (copy_from_user(&dirty, argp, sizeof(dirty))) goto out; + vcpu_load(vcpu); r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty); vcpu_put(vcpu); break; -- 2.30.2