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: <150a4c24-6082-cf74-035d-c6cf4dacc46d@intel.com>
Date:   Mon, 28 Aug 2023 10:59:10 +0300
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Namhyung Kim <namhyung@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...nel.org>
Cc:     Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v2 3/4] perf tools: Convert to
 perf_record_header_attr_id()

On 25/08/23 18:25, Namhyung Kim wrote:
> Instead of accessing the attr.id directly, use the
> perf_record_header_attr_id() helper to handle old versions.
> 
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
>  tools/perf/util/header.c           | 2 +-
>  tools/perf/util/session.c          | 4 ++--
>  tools/perf/util/synthetic-events.c | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index f89321cbfdee..63967c34157d 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -4408,7 +4408,7 @@ int perf_event__process_attr(struct perf_tool *tool __maybe_unused,
>  	if (perf_evsel__alloc_id(&evsel->core, 1, n_ids))
>  		return -ENOMEM;
>  
> -	ids = (void *)&event->attr.attr + event->attr.attr.size;
> +	ids = perf_record_header_attr_id(event);
>  	for (i = 0; i < n_ids; i++) {
>  		perf_evlist__id_add(&evlist->core, &evsel->core, 0, i, ids[i]);
>  	}
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 00d18c74c090..1e9aa8ed15b6 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -833,8 +833,8 @@ static void perf_event__hdr_attr_swap(union perf_event *event,
>  	perf_event__attr_swap(&event->attr.attr);
>  
>  	size = event->header.size;
> -	size -= (void *)&event->attr.id - (void *)event;
> -	mem_bswap_64(event->attr.id, size);
> +	size -= perf_record_header_attr_id(event) - (void *)event;
> +	mem_bswap_64(perf_record_header_attr_id(event), size);

Should this and below also be a fix for stable?

>  }
>  
>  static void perf_event__event_update_swap(union perf_event *event,
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index 45714a2785fd..a0579c7d7b9e 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -2145,7 +2145,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *
>  		return -ENOMEM;
>  
>  	ev->attr.attr = *attr;
> -	memcpy(ev->attr.id, id, ids * sizeof(u64));
> +	memcpy(perf_record_header_attr_id(ev), id, ids * sizeof(u64));
>  
>  	ev->attr.header.type = PERF_RECORD_HEADER_ATTR;
>  	ev->attr.header.size = (u16)size;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ