Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp22310152ybl; Mon, 6 Jan 2020 23:40:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxld4DP0uMmDEl5tAJpuyr/7cPm4ht2FBFuE97KfgMq7bXyK3VwATjun4QjTk/hli3HsH05 X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr127237673ota.154.1578382855440; Mon, 06 Jan 2020 23:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578382855; cv=none; d=google.com; s=arc-20160816; b=aSfXMfUnMoggxvAqzgAeLIptdP3u1bj8EwRD0BjihmXBbtLtj7d7cGMb9gCG8NSWB1 e5R+rKbSBcVr4ss7ipHmTRc6bu4A9YInc0nSVW1tkIi4hnqNXTGJ/hDjZlQOurYkQ50B vA1SYwATQB21X3Zh1K6NC0tdFDdO5daJ7PH5sCA9bv/BW0c+uTEAg2mvadQbd0QnTpAQ Uz8RZDtzycmGCenXIwcJeMvpULQCKvNtpOXl03UciQ/PNul1PebR69zsF7TxyoPRmtIH zheehkHwmpjMNSS+HrGAJ5qbGdZPhj3wRLKjRTp/VHNDHWN97Rddr3TYqxq/9FbKQnUe oimQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=45hyKhE92iM4yXRug7dHMT3agumTLM9DE3aXUuf53sQ=; b=yfPKLk7BMkrq0P2PbxlgLisYGL0EzZPeMb3G7gmG52vOG5DyulpQ/Oy1SD5ph32md7 aM0O5f1v6s7Ag34cLdPBjabHHUso4O4hqt5VlmjuNUaLdMVz/bH8jHx7i1ytUsJ76Jmi 4vvA551g+oml+NNINym2VsWF+SHNG0xv0rJql8irUPuJjwEGTtbhBUgDv469y/DEjTye Wx82hC79Y/vLEQ6HXBG0NlBLvW0YvJkTTFjgFNn57LoaJbISYHKRoGZNKcLLgqBLswe3 gEVNs4o65iiBjBU5X49Cdrb8egTIalQ8pV94W7hXbtJc2S2H6xlWlYKr9FMpTs+8QUbh G+aA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si39047597otp.139.2020.01.06.23.40.42; Mon, 06 Jan 2020 23:40:55 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbgAGHjz (ORCPT + 99 others); Tue, 7 Jan 2020 02:39:55 -0500 Received: from mga07.intel.com ([134.134.136.100]:33726 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgAGHjy (ORCPT ); Tue, 7 Jan 2020 02:39:54 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 23:39:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,404,1571727600"; d="scan'208";a="223097653" Received: from um.fi.intel.com (HELO um) ([10.237.72.57]) by orsmga003.jf.intel.com with ESMTP; 06 Jan 2020 23:39:51 -0800 From: Alexander Shishkin To: Mark Rutland , Vince Weaver , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , alexander.shishkin@linux.intel.com 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> References: <20200106120338.GC9630@lakrids.cambridge.arm.com> Date: Tue, 07 Jan 2020 09:39:51 +0200 Message-ID: <87o8vfbtq0.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mark Rutland writes: > On Thu, Jan 02, 2020 at 02:22:47PM -0500, Vince Weaver wrote: >> On Thu, 2 Jan 2020, Vince Weaver wrote: >> >> > 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. > > Yikes. > >> 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) > > Looks like that was introduced in commit: > > ab43762ef010967e ("perf: Allow normal events to output AUX data") > > I guess we should return -EINVAL in this case. That's right. Thanks for looking into this! > 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; > + } > FWIW, Acked-by: Alexander Shishkin Thanks, -- Alex