Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4832805ybl; Wed, 22 Jan 2020 05:34:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzeeuQy3G/UqhHnY9bpq0yKWbc9K+VgRcFNsPCLL+r11K8CbqpzFa/gxfqvqevO4hnZFvb6 X-Received: by 2002:a9d:53cb:: with SMTP id i11mr7484180oth.158.1579700078447; Wed, 22 Jan 2020 05:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579700078; cv=none; d=google.com; s=arc-20160816; b=0HQPuwOMq+8P5c+5THiVczYuH5t1FjLbbrmkshpDlZaEuqlfuzrW3oClYRL49eIpT1 +ixlQkt6f/dd/9+JBoU12il3/C/4yNrZcgH5h1oJUIPmkwaWObFq/wvDZ7RXFO3NTk/Z BSAUPtBm6GegFp6Y2r77fX41mAu6H7J398O3ccrradBSCoA0CrQS94OxXZJwWtf9IAQQ GoQi8jfd0q2iGmFVCk277ec2gMevybuBwjj+Js0Ps/W+8dzGGNRPUFR1naWn4iZ003iT G+IZ419J/4U3H3hZQmp83obirTpHZ+O/YqHLlwtszxMz7ImwMSBuFL8Ts2cGimOonv88 emdQ== 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=+pL8MetvTMhND+Gqv1e/xjou1nYFjRJ4IrDf3vuOvtM=; b=Pt/8Chx4Evj5AgojheT0QOpOmbtGClr1Pe1eu9zlw8Rbqw/4bdLgBWStTrd+A3c7AV qjfOnXDqspo4WZbGZ0BokJm9eOaVa9+sCaotQSJAYOE8OeSajIlOE3TAOAtbzBHigkoX 1zmqxOv9e+4z2WJIgXHDUBfNTVoZAtabz/45G78A7iItZjxQYHHYxVCcwUIS3N/3F9+f guILaY+pIbZCrWO8IaLnL1GDoKr4Yw2RaTJxIEsQpvcT4g1W98HZlNG628q4bbrpsNc4 wUMVqymbt7oZA27Z1Uj+QirE4CIPV0K1SZauaoOPBymORkbPvkGZLVsmCislKaVmzBma a/Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nXO1uHaY; 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 m67si20188084oib.117.2020.01.22.05.34.26; Wed, 22 Jan 2020 05:34:38 -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=nXO1uHaY; 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 S1729893AbgAVNUM (ORCPT + 99 others); Wed, 22 Jan 2020 08:20:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:36242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729297AbgAVNUI (ORCPT ); Wed, 22 Jan 2020 08:20:08 -0500 Received: from localhost (unknown [84.241.205.26]) (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 F3F7A2467E; Wed, 22 Jan 2020 13:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699207; bh=mI98QF2qNyJiueNKtM5Bbxqg45I7JeOH0vikwTQ5XLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXO1uHaYEzxIKpd7DjDmorHXZdLOwWmCOKJyXMXwM+6nVFpo4pARrLkJOOBQJHlwB A7P3NrSwfU/tnUCH4ZLXbO4xb+olkrqxMroBt3kF5ic6iNYnAaYRmXq4rpJK4Pc2WP rcXj4ut8N/SJfFfubyA/YM8T1ph4pCu5LDKHxsvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vince Weaver , Mark Rutland , "Peter Zijlstra (Intel)" , Ingo Molnar , Alexander Shishkin Subject: [PATCH 5.4 037/222] perf: Correctly handle failed perf_get_aux_event() Date: Wed, 22 Jan 2020 10:27:03 +0100 Message-Id: <20200122092836.175504422@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@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: Mark Rutland commit da9ec3d3dd0f1240a48920be063448a2242dbd90 upstream. Vince reports a worrying issue: | so I was tracking down some odd behavior in the perf_fuzzer which turns | out to be because perf_even_open() sometimes returns 0 (indicating a file | descriptor of 0) even though as far as I can tell stdin is still open. ... and further the cause: | error is triggered if aux_sample_size has non-zero value. | | seems to be this line in kernel/events/core.c: | | if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) | goto err_locked; | | (note, err is never set) This seems to be a thinko in commit: ab43762ef010967e ("perf: Allow normal events to output AUX data") ... and we should probably return -EINVAL here, as this should only happen when the new event is mis-configured or does not have a compatible aux_event group leader. Fixes: ab43762ef010967e ("perf: Allow normal events to output AUX data") Reported-by: Vince Weaver Signed-off-by: Mark Rutland Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Acked-by: Alexander Shishkin Tested-by: Vince Weaver Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11182,8 +11182,10 @@ SYSCALL_DEFINE5(perf_event_open, } } - if (event->attr.aux_output && !perf_get_aux_event(event, group_leader)) + if (event->attr.aux_output && !perf_get_aux_event(event, group_leader)) { + err = -EINVAL; goto err_locked; + } /* * Must be under the same ctx::mutex as perf_install_in_context(),