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]
Date:   Wed, 20 Dec 2017 18:10:11 +0000
From:   Song Liu <songliubraving@...com>
To:     Peter Zijlstra <peterz@...radead.org>
CC:     Steven Rostedt <rostedt@...dmis.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        David Miller <davem@...emloft.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Daniel Borkmann" <daniel@...earbox.net>,
        Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v5 3/6] perf: implement pmu perf_kprobe


> On Dec 20, 2017, at 2:14 AM, Peter Zijlstra <peterz@...radead.org> wrote:
> 
> On Wed, Dec 20, 2017 at 11:03:01AM +0100, Peter Zijlstra wrote:
>> On Wed, Dec 06, 2017 at 02:45:15PM -0800, Song Liu wrote:
>>> @@ -8537,7 +8620,7 @@ static int perf_event_set_filter(struct perf_event *event, void __user *arg)
>>> 	char *filter_str;
>>> 	int ret = -EINVAL;
>>> 
>>> -	if ((event->attr.type != PERF_TYPE_TRACEPOINT ||
>>> +	if ((!perf_event_is_tracing(event) ||
>>> 	     !IS_ENABLED(CONFIG_EVENT_TRACING)) &&
>>> 	    !has_addr_filter(event))
>>> 		return -EINVAL;
>> 
>> You actually missed an instance later in this same function... fixing
>> that.
> 
> 
> @@ -8518,23 +8601,19 @@ perf_event_set_addr_filter(struct perf_e
> 
> static int perf_event_set_filter(struct perf_event *event, void __user *arg)
> {
> -	char *filter_str;
> 	int ret = -EINVAL;
> -
> -	if ((event->attr.type != PERF_TYPE_TRACEPOINT ||
> -	    !IS_ENABLED(CONFIG_EVENT_TRACING)) &&
> -	    !has_addr_filter(event))
> -		return -EINVAL;
> +	char *filter_str;
> 
> 	filter_str = strndup_user(arg, PAGE_SIZE);
> 	if (IS_ERR(filter_str))
> 		return PTR_ERR(filter_str);
> 
> -	if (IS_ENABLED(CONFIG_EVENT_TRACING) &&
> -	    event->attr.type == PERF_TYPE_TRACEPOINT)
> -		ret = ftrace_profile_set_filter(event, event->attr.config,
> -						filter_str);
> -	else if (has_addr_filter(event))
> +#ifdef CONFIG_EVENT_TRACING
> +	if (perf_event_is_tracing(event))
> +		ret = ftrace_profile_set_filter(event, event->attr.config, filter_str);
> +	else
> +#endif
> +	if (has_addr_filter(event))
> 		ret = perf_event_set_addr_filter(event, filter_str);
> 
> 	kfree(filter_str);
> 
> 
> 
> Is that right?

Yeah, this is right and neat. Thanks a lot for your help on this. 

I think there is one more thing to change:

diff --git i/kernel/events/core.c w/kernel/events/core.c
index a906f30..516ff9b 100644
--- i/kernel/events/core.c
+++ w/kernel/events/core.c
@@ -8226,7 +8226,7 @@ static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd)

 static void perf_event_free_bpf_prog(struct perf_event *event)
 {
-       if (event->attr.type != PERF_TYPE_TRACEPOINT) {
+       if (!perf_event_is_tracing(event)) {
                perf_event_free_bpf_handler(event);
                return;
        }

Thanks,
Song

Powered by blists - more mailing lists