lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b4d28088-3de5-43a5-a4b6-12d3a29244b7@intel.com>
Date: Thu, 11 Jul 2024 09:46:33 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Ian Rogers <irogers@...gle.com>, Peter Zijlstra <peterz@...radead.org>,
 Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>,
 Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Jiri Olsa <jolsa@...nel.org>, Kan Liang <kan.liang@...ux.intel.com>,
 John Garry <john.g.garry@...cle.com>, Will Deacon <will@...nel.org>,
 James Clark <james.clark@....com>, Mike Leach <mike.leach@...aro.org>,
 Leo Yan <leo.yan@...ux.dev>, Suzuki K Poulose <suzuki.poulose@....com>,
 Yicong Yang <yangyicong@...ilicon.com>,
 Jonathan Cameron <jonathan.cameron@...wei.com>,
 Nick Terrell <terrelln@...com>, Nick Desaulniers <ndesaulniers@...gle.com>,
 Oliver Upton <oliver.upton@...ux.dev>,
 Anshuman Khandual <anshuman.khandual@....com>, Song Liu <song@...nel.org>,
 Ilkka Koskinen <ilkka@...amperecomputing.com>,
 Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
 Huacai Chen <chenhuacai@...nel.org>, Yanteng Si <siyanteng@...ngson.cn>,
 Sun Haiyong <sunhaiyong@...ngson.cn>, linux-kernel@...r.kernel.org,
 linux-perf-users@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v3 01/28] perf auxtrace: Remove dummy tools

On 11/07/24 09:43, Adrian Hunter wrote:
> On 29/06/24 07:53, Ian Rogers wrote:
>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>> index 0ec92d47373c..44db5b49128f 100644
>> --- a/tools/perf/util/session.c
>> +++ b/tools/perf/util/session.c
>> @@ -1764,6 +1764,36 @@ int perf_session__deliver_synth_event(struct perf_session *session,
>>  	return machines__deliver_event(&session->machines, evlist, event, sample, tool, 0, NULL);
>>  }
>>  
>> +int perf_session__deliver_synth_attr_event(struct perf_session *session,
>> +					   const struct perf_event_attr *attr,
>> +					   u64 id)
>> +{
>> +	union {
>> +		struct {
>> +			struct perf_record_header_attr attr;
>> +			u64 ids[1];
>> +		} attr_id;
>> +		union perf_event ev;
>> +	} ev = {
>> +		.attr_id = {
>> +			.attr = {
>> +				.header = {
>> +					.type = PERF_RECORD_HEADER_ATTR,
>> +					.size = PERF_ALIGN(sizeof(struct perf_event_attr),
>> +							   sizeof(u64))
>> +					    + sizeof(struct perf_event_header)
>> +					    + sizeof(u64),
>> +				},
>> +			},
>> +			.ids = { id, }
>> +		},
> 
> Nested definitions are not needed.  It can just be:
> 
> 		.attr_id.attr.header.type = PERF_RECORD_HEADER_ATTR,
> 		.attr_id.attr.header.size = sizeof(ev.attr_id),
> 		.attr_id.ids[0] = id,
> 
>> +	};
>> +
>> +	memcpy(&ev.attr_id.attr.attr, attr, min((u32)sizeof(struct perf_event_attr), attr->size));
> 
> It is not unreasonable to validate attr->size, but neither slicing
> nor padding will work.  Better to just return an error:
> 
> 	if (attr->size != sizeof(ev.attr_id.attr))

Or rather

 	if (attr->size != sizeof(ev.attr_id.attr.attr))

> 		return -EINVAL;
> 
> Then:
> 
> 	ev.attr_id.attr.attr = *attr;
> 
> 
>> +	ev.attr_id.attr.attr.size = sizeof(struct perf_event_attr);
>> +	return perf_session__deliver_synth_event(session, &ev.ev, NULL);
>> +}
>> +


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ