Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp464956ybl; Tue, 28 Jan 2020 06:23:27 -0800 (PST) X-Google-Smtp-Source: APXvYqy4IcvfjS+4zoJLCXTSjP6WXbwZGwCV1uC2oIs3yR8h9yBYLFXw75hkWUK11IXJ9xqQ88HE X-Received: by 2002:a9d:7f12:: with SMTP id j18mr17561710otq.17.1580221407381; Tue, 28 Jan 2020 06:23:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221407; cv=none; d=google.com; s=arc-20160816; b=sAaqP/oCE1xkSBgODUR/3yDgmwTrwJ//rqAePyakZUJVhItwtqSyhgY3J9tf3+IIET /C3Y0RAB+08jaL+47Rt2cLT6LIF7ZhaDG0peBK2pFISlzJmHT+P9UpIgI4sundfXVaqy 7shabCL0bItLz3Hjpvs1GWWyIImNTH/q/EcbbLcmdoD3AwFuBMO1B6oGoO0D6ipzYFpY 9Q7zrFI1kpNfxgI4HY3HsZhDQRHpxPBPcpYak0E6KSxCup1sG/DvCHpYZDx99cTmCBG8 VXrnaevswvQUw5se3w5/V9mwGd04pJoJ1BPl84exDs7Z86dBXNsjmXFY18PAdw1X9PNI yUeQ== 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=Q4SVeMk3dYiz3453cSq1fcyG7j/xUkh/JVvVJf+LG3k=; b=mhIGmmPwW2S67AzlubaT3C4ef4t87A4XK9dD/6XM7GVOy/A9O0rK42LR87o+p8n7eg MHOEKiwyMEFNRhbjH6DtnVkJmTwqjXaugWR+t/4+Iri+eAqXE5QTsNB4+u3JNOe8RGOH Ftprmu46BJavwBK5KdZp4+Vg1UUj02XRh6Tnz7f0Ci2nTpCG61QotI/X0r95V1hi2kyt hAt062DiSWyoNQxYI3X6wDnKtmjMb+ZiTHK251UCQ8E2VFRHvcaJbaPCVYeJyJ7tOJEC gsEVSLRHup06HUI4m1aNvAL9WFzqwv84zWFrLbI3g0KkXwZtOL/AY2vbXTM9sChVH7iy eAlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zPh6PltP; 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 2si4642505ois.221.2020.01.28.06.23.15; Tue, 28 Jan 2020 06:23:27 -0800 (PST) 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=zPh6PltP; 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 S1731255AbgA1OVR (ORCPT + 99 others); Tue, 28 Jan 2020 09:21:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:46520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731238AbgA1OVQ (ORCPT ); Tue, 28 Jan 2020 09:21:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 730952071E; Tue, 28 Jan 2020 14:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221275; bh=PkdHkgPs1rwq/MEdmnI6tsx7avovdsP70a/agvoptX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zPh6PltPFVr+G1m4o3IkeA3K756LM1b+nRK4hC9+zOjTwTT5a7pBMbwQEqXHR7vhw P5m+kaksLEcZjUIXF5EaR/x6vYv7TylgrPtxffKv2hu5WtzbE48ePVLZqNUmOK31x3 vOv1LI7Zr+Uh6zl6wTWHvw3IxE5Bu02HeUDoC9kM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Bangoria , "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Stephane Eranian , Thomas Gleixner , Vince Weaver , acme@kernel.org, linuxppc-dev@lists.ozlabs.org, maddy@linux.vnet.ibm.com, mpe@ellerman.id.au, Ingo Molnar , Sasha Levin Subject: [PATCH 4.9 160/271] perf/ioctl: Add check for the sample_period value Date: Tue, 28 Jan 2020 15:05:09 +0100 Message-Id: <20200128135904.486507028@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Ravi Bangoria [ Upstream commit 913a90bc5a3a06b1f04c337320e9aeee2328dd77 ] 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 Signed-off-by: Sasha Levin --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5bbf7537a6121..64ace5e9af2a0 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4624,6 +4624,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) if (perf_event_check_period(event, value)) return -EINVAL; + if (!event->attr.freq && (value & (1ULL << 63))) + return -EINVAL; + event_function_call(event, __perf_event_period, &value); return 0; -- 2.20.1