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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 26 Oct 2015 14:28:39 -0700
From:	Alexei Starovoitov <ast@...mgrid.com>
To:	"Wangnan (F)" <wangnan0@...wei.com>,
	Peter Zijlstra <peterz@...radead.org>
Cc:	Ingo Molnar <mingo@...nel.org>,
	"David S. Miller" <davem@...emloft.net>,
	He Kuang <hekuang@...wei.com>, Kaixu Xia <xiakaixu@...wei.com>,
	Daniel Borkmann <daniel@...earbox.net>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 net-next] bpf: fix bpf_perf_event_read() helper

On 10/26/15 5:54 AM, Wangnan (F) wrote:
>
>
> On 2015/10/26 20:32, Peter Zijlstra wrote:
>> On Sun, Oct 25, 2015 at 09:23:36AM -0700, Alexei Starovoitov wrote:
>>> bpf_perf_event_read() muxes of -EINVAL into return value, but it's non
>>> ambiguous to the program whether it got an error or real counter value.
>> How can that be, the (u64)-EINVAL value is a valid counter value..
>> unlikely maybe, but still quite possible.
> In our real usecase we simply treat return value larger than
> 0x7fffffffffffffff
> as error result. We can make it even larger, for example, to
> 0xffffffffffff0000.

either above or write the program that index is valid, then you
don't need to check for errors.

> Resuling values can be pre-processed by a script to filter potential
> error result
> out so it is not a very big problem for our real usecases.
>
> For a better interface, I suggest
>
>   u64 bpf_perf_event_read(bool *perror);
>
> which still returns counter value through its return value but put error
> code
> to stack. Then BPF program can pass NULL to the function if BPF problem
> doesn't want to deal with error code.

no. we're not going to introduce another interface for this.
The current one is fine. Don't pass incorrect index and you won't see
einval. Returning ints or bools via stack is much slower.

--
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