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: <d6d8aef5-9ebf-4a38-bdb5-f1daf7818873@suse.cz>
Date: Fri, 8 Mar 2024 08:53:05 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Oscar Salvador <osalvador@...e.de>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
 Michal Hocko <mhocko@...e.com>, Marco Elver <elver@...gle.com>,
 Andrey Konovalov <andreyknvl@...il.com>,
 Alexander Potapenko <glider@...gle.com>,
 kernel test robot <oliver.sang@...el.com>
Subject: Re: [PATCH 1/2] mm,page_owner: Check for null stack_record before
 bumping its refcount

On 3/6/24 13:32, Oscar Salvador wrote:
> Although the retrieval of the stack_records for {dummy,failure}_handle
> happen when page_owner gets initialized, there seems to be some situations
> where stackdepot space has been already depleted by then, so we get
> 0-handles which make stack_records being NULL for those cases.
> 
> Be careful to 1) only bump stack_records refcount and 2) only access
> stack_record fields if we actually have a non-null stack_record between
> hands.
> 
> Reported-by: kernel test robot <oliver.sang@...el.com>
> Closes: https://lore.kernel.org/oe-lkp/202403051032.e2f865a-lkp@intel.com
> Fixes: 4bedfb314bdd ("mm,page_owner: implement the tracking of the stacks count")
> Signed-off-by: Oscar Salvador <osalvador@...e.de>

Reviewed-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  mm/page_owner.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 033e349f6479..7163a1c44ccf 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -107,8 +107,10 @@ static __init void init_page_owner(void)
>  	/* Initialize dummy and failure stacks and link them to stack_list */
>  	dummy_stack.stack_record = __stack_depot_get_stack_record(dummy_handle);
>  	failure_stack.stack_record = __stack_depot_get_stack_record(failure_handle);
> -	refcount_set(&dummy_stack.stack_record->count, 1);
> -	refcount_set(&failure_stack.stack_record->count, 1);
> +	if (dummy_stack.stack_record)
> +		refcount_set(&dummy_stack.stack_record->count, 1);
> +	if (failure_stack.stack_record)
> +		refcount_set(&failure_stack.stack_record->count, 1);
>  	dummy_stack.next = &failure_stack;
>  	stack_list = &dummy_stack;
>  }
> @@ -856,6 +858,9 @@ static int stack_print(struct seq_file *m, void *v)
>  	unsigned long nr_entries;
>  	struct stack_record *stack_record = stack->stack_record;
>  
> +	if (!stack->stack_record)
> +		return 0;
> +
>  	nr_entries = stack_record->size;
>  	entries = stack_record->entries;
>  	stack_count = refcount_read(&stack_record->count) - 1;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ