Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp265394img; Mon, 18 Mar 2019 02:37:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzq3fdiCuQQ4nK2PtLNohdDd7SS+6iSEeHZ4Aoph2or8poBLQIBIokc7Ius86gY/3UIaHc5 X-Received: by 2002:a65:6148:: with SMTP id o8mr16892870pgv.442.1552901822541; Mon, 18 Mar 2019 02:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901822; cv=none; d=google.com; s=arc-20160816; b=cZTBqutcvujDhqdJPYO6fzPsHheH4l+KkcPXjqf//stR8vPVm4h9jk8m1KIMymDcgI GPZhX0HGJc18jhXS5JrMLgRiB0nyH1dFlOU/pcWX/m+Lh5nRDkG+iN2isiUaTBBb4Mgu fx5hONpK7/PgedkV5RPS+X4R4jLzpHdFJlo8GiE0E/bkU2Cfx148U9xFGEFmVnmG8zko 6alUdsYs8ZUKDr/oEpFYlOKWmAOIy9bdZLm91QrfNh2au75T2xbV3W7x9klb3+Q+KnK5 aezgR/VbvbBkkFZZV7qqGFG+8/j/UeNMb24v40zoju5b6jDwDBGghwV1W5rxH+sue/dx 0p7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oQ7JposgR8sO9aEz0JCfIcp3ruftF5EHa+syq1jqwxU=; b=EIhJ0WyI/LPD9xqSMFMnEpGnXerpLAUbcQ4PeGJFIusnnQ2a/3QB9OS0n/ry+BkmTb XZKEN3ThBcd4o7dXoX93PuDhBevwYo5Zn9nwGSIkFW52udkRcRpvsagY8jvNzrH1f6tC sNoVy5en3e9MatwfQoJTJirR0SbjwMk8dRh6a4/CEBVj+gi4WhKqmbkg8j/ra1rRITaE DgodlalOYnpnW90VkNSr3ymFVqBt33htF1mGb5mSO1fBRqICCpSjIaAm/TN4+ISAqw3B IFflE88sBK4qW/XJoycN9nU5jcDYgPY7T85ae4WfF/QzY10qO44JGPuQloKSVA0nsj8a xUsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OlTKfhwn; 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 g10si8507159plo.308.2019.03.18.02.36.47; Mon, 18 Mar 2019 02:37:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OlTKfhwn; 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 S2387485AbfCRJff (ORCPT + 99 others); Mon, 18 Mar 2019 05:35:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:43972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387479AbfCRJfe (ORCPT ); Mon, 18 Mar 2019 05:35:34 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4B4521773; Mon, 18 Mar 2019 09:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901734; bh=S9q19Zs5Vd1sFabqbocnO1kliz9YS4tnRlIRZfJL8fc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OlTKfhwnJgkogbEyEnoTycPN8EI6QE00VOszOmKTzsm0GyXCtE0jlbRP9LNs4MhXE ZlpgOLwQj+bZb0nl8jfP8nvkljEzHG37L2lCoXvVER/p8BPsXpr2HUuNRkYWPmUkD/ O+IwZF3lb25QHfgwCKD8DAsQZYznfw32pEDy/5U8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Jones , "DSouza, Nelson" , "Peter Zijlstra (Intel)" , Thomas Gleixner , eranian@google.com, jolsa@redhat.com, stable@kernel.org Subject: [PATCH 4.14 31/34] perf/x86/intel: Fix memory corruption Date: Mon, 18 Mar 2019 10:25:55 +0100 Message-Id: <20190318084149.364327318@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084144.657740413@linuxfoundation.org> References: <20190318084144.657740413@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra commit ede271b059463731cbd6dffe55ffd70d7dbe8392 upstream. Through: validate_event() x86_pmu.get_event_constraints(.idx=-1) tfa_get_event_constraints() dyn_constraint() cpuc->constraint_list[-1] is used, which is an obvious out-of-bound access. In this case, simply skip the TFA constraint code, there is no event constraint with just PMC3, therefore the code will never result in the empty set. Fixes: 400816f60c54 ("perf/x86/intel: Implement support for TSX Force Abort") Reported-by: Tony Jones Reported-by: "DSouza, Nelson" Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Tested-by: Tony Jones Tested-by: "DSouza, Nelson" Cc: eranian@google.com Cc: jolsa@redhat.com Cc: stable@kernel.org Link: https://lkml.kernel.org/r/20190314130705.441549378@infradead.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3262,7 +3262,7 @@ tfa_get_event_constraints(struct cpu_hw_ /* * Without TFA we must not use PMC3. */ - if (!allow_tsx_force_abort && test_bit(3, c->idxmsk)) { + if (!allow_tsx_force_abort && test_bit(3, c->idxmsk) && idx >= 0) { c = dyn_constraint(cpuc, c, idx); c->idxmsk64 &= ~(1ULL << 3); c->weight--;