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] [day] [month] [year] [list]
Message-ID: <20250722081422.GG3137075@e132581.arm.com>
Date: Tue, 22 Jul 2025 09:14:22 +0100
From: Leo Yan <leo.yan@....com>
To: Eduard Zingerman <eddyz87@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	KP Singh <kpsingh@...nel.org>,
	Matt Bobrowski <mattbobrowski@...gle.com>,
	Song Liu <song@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Masami Hiramatsu <mhiramat@...nel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	James Clark <james.clark@...aro.org>,
	Suzuki K Poulose <suzuki.poulose@....com>,
	Mike Leach <mike.leach@...aro.org>,
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
	bpf@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH PATCH v2 v2 2/6] bpf: Add bpf_perf_event_aux_pause kfunc

Hi Eduard,

On Mon, Jul 21, 2025 at 03:38:59PM -0700, Eduard Zingerman wrote:
> On Fri, 2025-07-18 at 16:25 +0100, Leo Yan wrote:
> 
> [...]
> 
> > +__bpf_kfunc int bpf_perf_event_aux_pause(void *p__map, u64 flags, u32 pause)
> > +{
> > +	struct bpf_map *map = p__map;
> > +	struct bpf_array *array = container_of(map, struct bpf_array, map);
> 
> Verifier makes sure that p__map is a not null pointer to an object of
> type bpf_map, but it does not guarantee that the object is an instance
> of bpf_array.
> You need to check map->type, same way bpf_arena_alloc_pages() does.

Makes sense. Will do.

> > +	unsigned int cpu = smp_processor_id();
> > +	u64 index = flags & BPF_F_INDEX_MASK;
> > +	struct bpf_event_entry *ee;
> > +	int ret = 0;
> > +
> > +	/* Disabling IRQ avoids race condition with perf event flows. */
> > +	guard(irqsave)();
> > +
> > +	if (unlikely(flags & ~(BPF_F_INDEX_MASK))) {
> > +		ret = -EINVAL;
> > +		goto out;
> > +	}
> > +
> > +	if (index == BPF_F_CURRENT_CPU)
> > +		index = cpu;
> > +
> > +	if (unlikely(index >= array->map.max_entries)) {
> > +		ret = -E2BIG;
> > +		goto out;
> > +	}
> > +
> > +	ee = READ_ONCE(array->ptrs[index]);
> > +	if (!ee) {
> > +		ret = -ENOENT;
> > +		goto out;
> > +	}
> > +
> > +	if (!has_aux(ee->event))
> > +		ret = -EINVAL;

I should refactor a bit for removing "goto out" and directly return
error cases.

Thanks for review and your suggestion in another reply.

Leo

> > +
> > +	perf_event_aux_pause(ee->event, pause);
> > +out:
> > +	return ret;
> > +}
> 
> [...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ