Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1191014ybn; Wed, 2 Oct 2019 12:11:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTRvwJNAqdre7x1fqpy4t2ufJZlRZNWG8Pq4VSeHl4KmCJ9aMM54sfkq1TXAFXnZX1nteK X-Received: by 2002:a17:906:fd4:: with SMTP id c20mr4369172ejk.41.1570043516746; Wed, 02 Oct 2019 12:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043516; cv=none; d=google.com; s=arc-20160816; b=QdZ4+eAnuT1XVX417Re4YldKryYuHLp9JoVMz/qeCCWTsweFwAn7GO/GhZC0UqztT6 o22sUFb9IDq5HcL+Rkc/Wf5EtDJdp7o0mzMBY+I1/7HfF0gI4Emxn7cMLDDMIgS+IWR/ hww87EzcABtIVTji01aMYJVKhbpbQmAkA6Iu3FeK3zeSmeNNERlUfnNuqdZ5t5aWDpFZ p2WWhEi/4G8FqkzSIVsNzpKvf6Mqrhs/+GmUk3t7kBODXfvAzNsSLSDwPZ1jJKn9H2U5 jPATSw2NR3EzgBdvVV/kcng9VXTZjcMdfZfzlGqKCV/lUjh2gqZYr9Yt2WTURpRzbTbw 4seA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=itjTwQOiWJCdAFRAuQwQCB2oJFmjdSrklPgvdXnYwGg=; b=dMLIKPOMRIgz1TAvvBgGApU4XcZ4m44c2Sq1UrrK3E8b1FHWfrlYChV3OHWWlB1Pcu wBfcP0zI+2PA1hVi3RqAwJ2EB+2hHZkV7mVwvkEESgRxpsJf3U3YlEhcnl3JZz5b+G5z Axz7nqszuoBDskOurxlGqSy5XwXPhcWi1mfyi34pYbAJwM3ZKWjutaIaNXqg6uHKBnJM rvLV+BO1z29BHHKlzs0XyxcGs6mUpAFtaf6+1NZISuhR/HvbLpoOgemJONesM5LT77+g njltC01YgA77uRWnYJfkyiPnvvAK7+h5VtqbOUmhp52sSs+uaRF01sqdjEk4pqjrMilU lXpg== 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 n6si4232ejj.232.2019.10.02.12.11.32; Wed, 02 Oct 2019 12:11:56 -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 S1729527AbfJBTIj (ORCPT + 99 others); Wed, 2 Oct 2019 15:08:39 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36126 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729385AbfJBTIW (ORCPT ); Wed, 2 Oct 2019 15:08:22 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyu-000368-RX; Wed, 02 Oct 2019 20:08:12 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyq-0003fy-10; Wed, 02 Oct 2019 20:08:08 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , mpe@ellerman.id.au, "Ravi Bangoria" , "Thomas Gleixner" , "Arnaldo Carvalho de Melo" , "Ingo Molnar" , linuxppc-dev@lists.ozlabs.org, "Stephane Eranian" , maddy@linux.vnet.ibm.com, "Peter Zijlstra (Intel)" , "Alexander Shishkin" , "Vince Weaver" , acme@kernel.org, "Jiri Olsa" , "Linus Torvalds" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 76/87] perf/ioctl: Add check for the sample_period value In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Ravi Bangoria commit 913a90bc5a3a06b1f04c337320e9aeee2328dd77 upstream. perf_event_open() limits the sample_period to 63 bits. See: 0819b2e30ccb ("perf: Limit perf_event_attr::sample_period to 63 bits") Make ioctl() consistent with it. Also on PowerPC, negative sample_period could cause a recursive PMIs leading to a hang (reported when running perf-fuzzer). Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: acme@kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: maddy@linux.vnet.ibm.com Cc: mpe@ellerman.id.au Fixes: 0819b2e30ccb ("perf: Limit perf_event_attr::sample_period to 63 bits") Link: https://lkml.kernel.org/r/20190604042953.914-1-ravi.bangoria@linux.ibm.com Signed-off-by: Ingo Molnar [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3823,6 +3823,9 @@ static int perf_event_period(struct perf if (perf_event_check_period(event, value)) return -EINVAL; + if (!event->attr.freq && (value & (1ULL << 63))) + return -EINVAL; + task = ctx->task; pe.value = value;