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: <20130624092807.GM28407@twins.programming.kicks-ass.net>
Date:	Mon, 24 Jun 2013 11:28:07 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Robert Richter <rric@...nel.org>
Cc:	Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...nel.org>,
	Arnaldo Carvalho de Melo <acme@...radead.org>,
	Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
	Borislav Petkov <bp@...e.de>,
	Robert Richter <robert.richter@...aro.org>
Subject: Re: [PATCH v2 02/14] perf: Add persistent events

On Tue, Jun 11, 2013 at 06:42:28PM +0200, Robert Richter wrote:
> From: Borislav Petkov <bp@...en8.de>
> 
> Add the needed pieces for persistent events which makes them
> process-agnostic. Also, make their buffers read-only when mmaping them
> from userspace.
> 
> While at it, do not return a void function, as caught by Fengguang's
> build robot.
> 
> Changes made by Robert Richter <robert.richter@...aro.org>:
> 
> * mmap should return EACCES error if fd can not be opened writable.
>   This error code also helps userland to map buffers readonly on
>   failure.
> 
> Signed-off-by: Borislav Petkov <bp@...e.de>
> [ Return -EACCES if mapped buffers must be readonly ]
> Signed-off-by: Robert Richter <robert.richter@...aro.org>
> Signed-off-by: Robert Richter <rric@...nel.org>
> ---
>  include/uapi/linux/perf_event.h |  3 ++-
>  kernel/events/core.c            | 10 +++++++++-
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index fb104e5..6032361 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -272,8 +272,9 @@ struct perf_event_attr {
>  
>  				exclude_callchain_kernel : 1, /* exclude kernel callchains */
>  				exclude_callchain_user   : 1, /* exclude user callchains */
> +				persistent     :  1, /* always-on event */
>  
> -				__reserved_1   : 41;
> +				__reserved_1   : 40;
>  
>  	union {
>  		__u32		wakeup_events;	  /* wakeup every n events */
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index b790ab6..a13e457 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3713,6 +3713,11 @@ static void perf_mmap_close(struct vm_area_struct *vma)
>  {
>  	struct perf_event *event = vma->vm_file->private_data;
>  
> +	if (event->attr.persistent) {
> +		atomic_dec(&event->mmap_count);
> +		return;
> +	}
> +
>  	if (atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex)) {
>  		unsigned long size = perf_data_size(event->rb);
>  		struct user_struct *user = event->mmap_user;
> @@ -3756,9 +3761,12 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
>  	if (event->cpu == -1 && event->attr.inherit)
>  		return -EINVAL;
>  
> -	if (!(vma->vm_flags & VM_SHARED))
> +	if (!(vma->vm_flags & VM_SHARED) && !event->attr.persistent)
>  		return -EINVAL;
>  
> +	if (event->attr.persistent && (vma->vm_flags & VM_WRITE))
> +		return -EACCES;
> +
>  	vma_size = vma->vm_end - vma->vm_start;
>  	nr_pages = (vma_size / PAGE_SIZE) - 1;


I find this patch incomplete for its asymmetric; there a dec, but not an
implied inc.
--
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