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]
Message-Id: <20220312111004.a199b41e036fe79da05b84f6@kernel.org>
Date:   Sat, 12 Mar 2022 11:10:04 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Beau Belgrave <beaub@...ux.microsoft.com>,
        Anders Roxell <anders.roxell@...aro.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Linux Trace Devel <linux-trace-devel@...r.kernel.org>
Subject: Re: [PATCH] tracing/user_events: Use alloc_pages instead of
 kzalloc() for register pages

On Fri, 11 Mar 2022 19:04:57 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@...dmis.org>
> 
> kzalloc virtual addresses do not work with SetPageReserved, use the actual
> page virtual addresses instead via alloc_pages.

Indeed. kzalloc allocates a slab object, we need a page.

Acked-by: Masami Hiramatsu <mhiramat@...nel.org>

Thank you,

> 
> The issue is reported when booting with user_events and
> DEBUG_VM_PGFLAGS=y.
> 
> Also make the number of events based on the ORDER.
> 
> Link: https://lore.kernel.org/all/CADYN=9+xY5Vku3Ws5E9S60SM5dCFfeGeRBkmDFbcxX0ZMoFing@mail.gmail.com/
> Link: https://lore.kernel.org/all/20220311223028.1865-1-beaub@linux.microsoft.com/
> 
> Cc: Beau Belgrave <beaub@...ux.microsoft.com>
> Reported-by: Anders Roxell <anders.roxell@...aro.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@...dmis.org>
> ---
>  kernel/trace/trace_events_user.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
> index 4febc1d6ae72..e10ad057e797 100644
> --- a/kernel/trace/trace_events_user.c
> +++ b/kernel/trace/trace_events_user.c
> @@ -30,9 +30,10 @@
>  
>  /*
>   * Limits how many trace_event calls user processes can create:
> - * Must be multiple of PAGE_SIZE.
> + * Must be a power of two of PAGE_SIZE.
>   */
> -#define MAX_PAGES 1
> +#define MAX_PAGE_ORDER 0
> +#define MAX_PAGES (1 << MAX_PAGE_ORDER)
>  #define MAX_EVENTS (MAX_PAGES * PAGE_SIZE)
>  
>  /* Limit how long of an event name plus args within the subsystem. */
> @@ -1622,16 +1623,17 @@ static void set_page_reservations(bool set)
>  
>  static int __init trace_events_user_init(void)
>  {
> +	struct page *pages;
>  	int ret;
>  
>  	/* Zero all bits beside 0 (which is reserved for failures) */
>  	bitmap_zero(page_bitmap, MAX_EVENTS);
>  	set_bit(0, page_bitmap);
>  
> -	register_page_data = kzalloc(MAX_EVENTS, GFP_KERNEL);
> -
> -	if (!register_page_data)
> +	pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, MAX_PAGE_ORDER);
> +	if (!pages)
>  		return -ENOMEM;
> +	register_page_data = page_address(pages);
>  
>  	set_page_reservations(true);
>  
> @@ -1640,7 +1642,7 @@ static int __init trace_events_user_init(void)
>  	if (ret) {
>  		pr_warn("user_events could not register with tracefs\n");
>  		set_page_reservations(false);
> -		kfree(register_page_data);
> +		__free_pages(pages, MAX_PAGE_ORDER);
>  		return ret;
>  	}
>  
> -- 
> 2.34.1
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ