stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/core: Fix mmap failure caused by bad size check
@ 2019-02-12 15:52 Changbin Du
  2019-02-14  3:34 ` Changbin Du
  0 siblings, 1 reply; 2+ messages in thread
From: Changbin Du @ 2019-02-12 15:52 UTC (permalink / raw)
  To: peterz, mingo
  Cc: acme, Changbin Du, Mark Rutland, Julien Thierry, Linus Torvalds,
	Jiri Olsa, Alexander Shishkin, stable

Perf tool now is broken by commit 9dff0aa95a32 ("perf/core: Don't WARN()
for impossible ring-buffer sizes"). The get_order() should be used but not
the order_base_2(). This mistake makes mmap() on perf fd always fail.

Fixes: 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes")
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Julien Thierry <julien.thierry@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: <stable@vger.kernel.org>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 309ef5a64af5..55faafca4a6e 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -734,7 +734,7 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
 	size = sizeof(struct ring_buffer);
 	size += nr_pages * sizeof(void *);
 
-	if (order_base_2(size) >= MAX_ORDER)
+	if (get_order(size) >= MAX_ORDER)
 		goto fail;
 
 	rb = kzalloc(size, GFP_KERNEL);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf/core: Fix mmap failure caused by bad size check
  2019-02-12 15:52 [PATCH] perf/core: Fix mmap failure caused by bad size check Changbin Du
@ 2019-02-14  3:34 ` Changbin Du
  0 siblings, 0 replies; 2+ messages in thread
From: Changbin Du @ 2019-02-14  3:34 UTC (permalink / raw)
  To: peterz, mingo, acme
  Cc: Linus Torvalds, Mark Rutland, Julien Thierry, Jiri Olsa,
	Alexander Shishkin, stable, linux-kernel, Changbin Du

Hi Peter, Ingo and Arnaldo,
Could you help review this and have this fix merged in next RC? The perf
is totaly broken now! Thanks.

On Tue, Feb 12, 2019 at 11:52:21PM +0800, Changbin Du wrote:
> Perf tool now is broken by commit 9dff0aa95a32 ("perf/core: Don't WARN()
> for impossible ring-buffer sizes"). The get_order() should be used but not
> the order_base_2(). This mistake makes mmap() on perf fd always fail.
> 
> Fixes: 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes")
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Julien Thierry <julien.thierry@arm.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: <stable@vger.kernel.org>
> ---
>  kernel/events/ring_buffer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
> index 309ef5a64af5..55faafca4a6e 100644
> --- a/kernel/events/ring_buffer.c
> +++ b/kernel/events/ring_buffer.c
> @@ -734,7 +734,7 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
>  	size = sizeof(struct ring_buffer);
>  	size += nr_pages * sizeof(void *);
>  
> -	if (order_base_2(size) >= MAX_ORDER)
> +	if (get_order(size) >= MAX_ORDER)
>  		goto fail;
>  
>  	rb = kzalloc(size, GFP_KERNEL);
> -- 
> 2.19.1
> 

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-14  3:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 15:52 [PATCH] perf/core: Fix mmap failure caused by bad size check Changbin Du
2019-02-14  3:34 ` Changbin Du

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).