Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2242044ybi; Thu, 20 Jun 2019 11:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpn3bCC1Oe4t/qmxELEpqcMVizz/6g9hU0QlIa1sLelz6vt/dh/THjVv/CEq7HzOpWmOnQ X-Received: by 2002:a17:902:306:: with SMTP id 6mr128071068pld.148.1561055266115; Thu, 20 Jun 2019 11:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055266; cv=none; d=google.com; s=arc-20160816; b=aCn+wS7vSKMAro5ioqQam8KRw1QEhN9oqeYL8igZWroKxSrEySUn/JHBbBQmQNbJsR oxyeFfbYy2quUAmeKzBFutfvRPAjkTxyZ0fjC//lqtfYHgJysU4l5bUENSWIaoJ8Mv4Q 8L2IY+pdMhv4d8VjnqcswXaQXDXN7zjZhPWmgj5/ZqY9Aby8X1ffrFTDTV9zUpsy8jpj mE4p0G1ICPE492Re0JMqE/Ubdkj8DPg8QTlfxrJCv53qHmy0KzpnF6vewdch+nrVb6IJ nmfx1a7vjaR0DQeE9ie0LrEtupPkcr8yzAbf3wmAetD8E273D602p81JzBkKgQMmn9NK KrCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=fKLYxyBIU8pqaK508lM7lQ+mR4K92C6wSxJ88f2JnfM=; b=EIup7fr/M9PawMeKBiSwIUJzbNeOZEAKANXsw1aGGjVvehDvmmeH/wXTjLHPV+VGPJ pHnDF5DspGBPsfe3fNRkSBRcuC+z+H6rbE2Fbnzf86PA8xTJ2OFDq+59wxJ9SgB5yduF 44IUdTPWUZENFdM2T/lWD/tOFY0rlyDjJkrhVoWq8gxItDu1KOQtQAUSOZT1qCU5pv8T K9xegKduxIno9eX6pDpiyQnWin/vBUqc9jusJaawK8Kp22NmY9VTwWJ9TYDMYMTzPzzy mqYB+/2NrBw8fsrQhEQZqrQM1/h9CaGg0fofT66rW0t1BI/+8Blg/++n1DU7V7PJijm4 Z+8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si193162pgl.594.2019.06.20.11.27.31; Thu, 20 Jun 2019 11:27:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728298AbfFTS12 (ORCPT + 99 others); Thu, 20 Jun 2019 14:27:28 -0400 Received: from mga05.intel.com ([192.55.52.43]:56248 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbfFTSFD (ORCPT ); Thu, 20 Jun 2019 14:05:03 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2019 11:05:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,397,1557212400"; d="scan'208";a="243714870" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga001.jf.intel.com with ESMTP; 20 Jun 2019 11:05:01 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 9ABAE300FFA; Thu, 20 Jun 2019 11:05:01 -0700 (PDT) From: Andi Kleen To: ehankland@google.com Cc: linux-kernel@vger.kernel.org, linux-kvm@vger.kernel.org Subject: Re: [PATCH v1] KVM: x86: PMU Whitelist References: Date: Thu, 20 Jun 2019 11:05:01 -0700 In-Reply-To: (Eric Hankland's message of "Wed, 22 May 2019 15:23:00 -0700") Message-ID: <877e9g9lpu.fsf@firstfloor.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eric Hankland writes: > > +int kvm_vcpu_ioctl_set_pmu_whitelist(struct kvm_vcpu *vcpu, > + struct kvm_pmu_whitelist __user *whtlst) > +{ > + struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); > + struct kvm_pmu_whitelist *old = pmu->whitelist; > + struct kvm_pmu_whitelist *new = NULL; > + struct kvm_pmu_whitelist tmp; > + int r; > + size_t size; > + > + r = -EFAULT; > + if (copy_from_user(&tmp, whtlst, sizeof(struct kvm_pmu_whitelist))) > + goto err; > + > + size = sizeof(tmp) + sizeof(tmp.events[0]) * tmp.num_events; > + new = kvzalloc(size, GFP_KERNEL_ACCOUNT); Consider what happens when tmp.num_events is large enough to wrap size. I suspect that's a kernel exploit as written. Also don't you need to copy tmp to new? -Andi