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: <20240319162430.3e76504d06f12edc107029a4@linux-foundation.org>
Date: Tue, 19 Mar 2024 16:24:30 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Oscar Salvador <osalvador@...e.de>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, Michal Hocko
 <mhocko@...e.com>, Vlastimil Babka <vbabka@...e.cz>, Marco Elver
 <elver@...gle.com>, Andrey Konovalov <andreyknvl@...il.com>, Alexander
 Potapenko <glider@...gle.com>, Tetsuo Handa
 <penguin-kernel@...ove.sakura.ne.jp>,
 syzbot+41bbfdb8d41003d12c0f@...kaller.appspotmail.com
Subject: Re: [PATCH v2 1/2] mm,page_owner: Fix refcount imbalance

On Tue, 19 Mar 2024 19:32:11 +0100 Oscar Salvador <osalvador@...e.de> wrote:

> Current code does not contemplate scenarios were an allocation and
> free operation on the same pages do not handle it in the same amount
> at once.
> To give an example, page_alloc_exact(), where we will allocate a page
> of enough order to stafisfy the size request, but we will free the
> remainings right away.
> 
> In the above example, we will increment the stack_record refcount
> only once, but we will decrease it the same number of times as number
> of unused pages we have to free.
> This will lead to a warning because of refcount imbalance.
> 
> Fix this by recording the number of base pages in the refcount field.
> 
> ...
>
> -static void dec_stack_record_count(depot_stack_handle_t handle)
> +static void dec_stack_record_count(depot_stack_handle_t handle,
> +				   int nr_base_pages)
>  {
>  	struct stack_record *stack_record = __stack_depot_get_stack_record(handle);
>  
>  	if (stack_record)
> -		refcount_dec(&stack_record->count);
> +		refcount_sub_and_test(nr_base_pages, &stack_record->count);
>  }

mm/page_owner.c: In function 'dec_stack_record_count':
mm/page_owner.c:226:17: error: ignoring return value of 'refcount_sub_and_test' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  226 |                 refcount_sub_and_test(nr_base_pages, &stack_record->count);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ