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: <d82aedb5-9406-4808-96b4-1d9ef63485a3@I-love.SAKURA.ne.jp>
Date: Wed, 20 Mar 2024 13:40:05 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: Andrew Morton <akpm@...ux-foundation.org>,
        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>,
        syzbot+41bbfdb8d41003d12c0f@...kaller.appspotmail.com
Subject: Re: [PATCH v2 1/2] mm,page_owner: Fix refcount imbalance

On 2024/03/20 8:24, Andrew Morton wrote:
> On Tue, 19 Mar 2024 19:32:11 +0100 Oscar Salvador <osalvador@...e.de> wrote:
>> -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
> 

Hmm, I guess that this is not an expected user of refcount API.
If it is correct behavior that refcount becomes 0 here, you need to explain like

-		refcount_sub_and_test(nr_base_pages, &stack_record->count);
+		if (refcount_sub_and_test(nr_base_pages, &stack_record->count)) {
+			// Explain why nothing to do here, and explain where/how
+			// refcount again becomes positive value using refcount_set().
+		}

or replace refcount_t with atomic_t where it is legal to make refcount positive
without using atomic_set().


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ