Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21736471ybl; Mon, 6 Jan 2020 10:10:58 -0800 (PST) X-Google-Smtp-Source: APXvYqz5tAw9/PEJO8o2RjS4KS96RcRqfLEI903AiFTSOioUCDDHKQtKd/tVsk0i48Xvwn6Jt7T9 X-Received: by 2002:a9d:6301:: with SMTP id q1mr11098411otk.70.1578334258690; Mon, 06 Jan 2020 10:10:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578334258; cv=none; d=google.com; s=arc-20160816; b=WeWEJg3AboJdBKQD2654gkYmijMevoYgTSd3wxlR7lnYi38gTAcwITZDM/IrD5CkZO DyVxiPHxhareUCvjCR/RB5fxAD9lDjYErIuHwETLoByptiP7lQbmAzWX7V6dRsOR92Ow +wUnNrglZRuiC06dQrRuvZSKrzJzPFhRmS/ePB54sNma/5qYH1CB8AWa4naWSBs94ElF yHmvkZITwzLrDIuQ7tmkfXoOKgiCGCRfYZSaou1eP/pO+FVYWEraRpCik5MkdEPIMnj3 vkFNtUMZK4NOIwke7eWApA925QEgimQmUwpROOf66X3ftlFmsK4AFMv5l0eB53/w6APl 7/Sg== 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:references :message-id:in-reply-to:subject:cc:to:date:from:dkim-signature; bh=Scg+5c1bo7BzriOdYCjzy69y4LMw3hBOSsv5RxX0B2s=; b=mVtCprlYMpRcRoR80w/44Eb+GEcNwP+q6Zh+wtEy8PCIh2ZVJhWwWjzbsKSQxxDRCg 54ouF/qWUNHNzutjvdVEimcLhZMovV+25q7iwMdm4olz2GaRamfEa64CpcpQqZVybe+I 9jwjwiHjSolOL0nTR5XJqUNEQyH0T6QJapbkAkWol32BtxhHlEhfO84nR66g/zbqPitB G3MnyPYV6ZEPlZRlg2sjC6jfEdr/m73fSGY+3iaaiVfHH/sZ6DUGpRav7Cz99Hb0bxI+ TCRD30Sex3PPbgtTeDaEjSdni4buYk1sWMdaLalPnl+v4WmOWZmFp4baiWJzpA7yqwvw ETCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=bZc9isEt; 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 y6si28689144oih.217.2020.01.06.10.10.45; Mon, 06 Jan 2020 10:10:58 -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=@maine.edu header.s=google header.b=bZc9isEt; 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 S1726643AbgAFSKD (ORCPT + 99 others); Mon, 6 Jan 2020 13:10:03 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:37491 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgAFSKC (ORCPT ); Mon, 6 Jan 2020 13:10:02 -0500 Received: by mail-qv1-f66.google.com with SMTP id f16so19409193qvi.4 for ; Mon, 06 Jan 2020 10:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maine.edu; s=google; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Scg+5c1bo7BzriOdYCjzy69y4LMw3hBOSsv5RxX0B2s=; b=bZc9isEtCO4q9pUWW9qXKMRW92eYNSKQQ5G3t4oSCu+AcoFlX77fXSICadA+EstGuE mwOf7VGZnRi2uoNfC/XkOx57rnwoRAD6P9P4mqOovetU8iiMnCDQ659d5iJJRoWo0l1x YUD2XYBKKm9GdEac4aQ2udYBy2l88uzsUpqF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Scg+5c1bo7BzriOdYCjzy69y4LMw3hBOSsv5RxX0B2s=; b=d633nZZHVnd5y6Oy46jTbUZigu+qr9zNoIwdNpS6HlvYUliVs7Z9UjMEKztXZm9bOz QgZBeRiv3jqFQl4QQ3hDe1A8lMMFiNcFvK/nHgOwh0o+JAIGJIXPIvOH9wd+whxTB5zM 5pRbk0I5I1a+sd30a/PyF/ezPlZHjX9lTXAIKCUiJr5Ea35uSdzJgscdI7drNrLqVVVc iNylCTMgRRH7KI90SgnVzR9DMXld2njgdOfWEu0/y5mn2crYVyWBPYzrkRjhFcnuPMEX 0U94Ha4RAQKa3MsiRBUm8FmmA1HCv/gxQSbMLt8amjacrk2wfOiZZ2t6zbghVpOEI6Pl +u7w== X-Gm-Message-State: APjAAAVbTVLXsmWp3mrlBgLaN6VyP2ILjd7xt4PrqOGkMLbOX22r9Ori 7hF0NPnDp//mSyBXMiqyDm4A6A== X-Received: by 2002:a05:6214:1745:: with SMTP id dc5mr77634297qvb.230.1578334201693; Mon, 06 Jan 2020 10:10:01 -0800 (PST) Received: from macbook-air (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id r10sm21007469qkm.23.2020.01.06.10.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 10:10:00 -0800 (PST) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Mon, 6 Jan 2020 13:09:56 -0500 (EST) X-X-Sender: vince@macbook-air To: Mark Rutland cc: Vince Weaver , Alexander Shishkin , Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim Subject: Re: [PATCH] perf: correctly handle failed perf_get_aux_event() (was: Re: [perf] perf_event_open() sometimes returning 0) In-Reply-To: <20200106120338.GC9630@lakrids.cambridge.arm.com> Message-ID: References: <20200106120338.GC9630@lakrids.cambridge.arm.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Jan 2020, Mark Rutland wrote: > On Thu, Jan 02, 2020 at 02:22:47PM -0500, Vince Weaver wrote: > > On Thu, 2 Jan 2020, Vince Weaver wrote: > > > Vince, does the below (untested) patch work for you? yes, this patch fixes things for me. Tested-by: Vince Weaver > ---->8---- > From c79f31b42aaf85f3a924af9218794b3bc8b79892 Mon Sep 17 00:00:00 2001 > From: Mark Rutland > Date: Mon, 6 Jan 2020 11:51:06 +0000 > Subject: [PATCH] perf: correctly handle failed perf_get_aux_event() > > 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 > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Alexander Shishkin > --- > kernel/events/core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index a1f8bde19b56..2173c23c25b4 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -11465,8 +11465,10 @@ SYSCALL_DEFINE5(perf_event_open, > } > } > > - if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) > + if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) { > + err = -EINVAL; > goto err_locked; > + } > > /* > * Must be under the same ctx::mutex as perf_install_in_context(), > -- > 2.11.0 > >