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]
Date:	Fri, 31 Jul 2015 09:43:45 -0700
From:	Alexei Starovoitov <ast@...mgrid.com>
To:	Kaixu Xia <xiakaixu@...wei.com>, davem@...emloft.net,
	acme@...nel.org, mingo@...hat.com, a.p.zijlstra@...llo.nl,
	masami.hiramatsu.pt@...achi.com, jolsa@...nel.org,
	daniel@...earbox.net
Cc:	wangnan0@...wei.com, linux-kernel@...r.kernel.org,
	pi3orama@....com, hekuang@...wei.com, netdev@...r.kernel.org
Subject: Re: [PATCH v5 3/4] bpf: Implement function bpf_perf_event_read() that
 get the selected hardware PMU conuter

On 7/31/15 4:59 AM, Kaixu Xia wrote:
> +static int check_func_limit(struct bpf_map **mapp, int func_id)
> +{
> +	struct bpf_map *map = *mapp;
> +
> +	if (map && map->map_type == BPF_MAP_TYPE_PROG_ARRAY &&
> +	    func_id != BPF_FUNC_tail_call)
> +		/* prog_array map type needs extra care:
> +		 * only allow to pass it into bpf_tail_call() for now.
> +		 * bpf_map_delete_elem() can be allowed in the future,
> +		 * while bpf_map_update_elem() must only be done via syscall
> +		 */
> +		return -EINVAL;
> +
> +	if (func_id == BPF_FUNC_tail_call &&
> +	    map->map_type != BPF_MAP_TYPE_PROG_ARRAY)
> +		/* don't allow any other map type to be passed into
> +		 * bpf_tail_call()
> +		 */
> +		return -EINVAL;
> +
> +	if (map && map->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY &&
> +	    func_id != BPF_FUNC_perf_event_read)
> +		/* perf_event_array map type needs extra care:
> +		 * only allow to pass it into bpf_perf_event_read() for now.
> +		 * bpf_map_update/delete_elem() must only be done via syscall
> +		 */
> +		return -EINVAL;
> +
> +	if (func_id == BPF_FUNC_perf_event_read &&
> +	    map->map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY)
> +		/* don't allow any other map type to be passed into
> +		 * bpf_perf_event_read()
> +		 */
> +		return -EINVAL;

copy paste of comments is too much.
The whole thing probably can be better generalized with an array
{{BPF_MAP_TYPE_PROG_ARRAY, BPF_FUNC_tail_call},
  {BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_FUNC_perf_event_read},
}
and a loop?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ