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: <1cf094b7-f530-4956-bbbd-be5a44a8a1f2@amd.com>
Date: Tue, 10 Jun 2025 14:30:27 +0530
From: Shivank Garg <shivankg@....com>
To: David Hildenbrand <david@...hat.com>, mhiramat@...nel.org,
 oleg@...hat.com, peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
 namhyung@...nel.org, mark.rutland@....com,
 alexander.shishkin@...ux.intel.com, jolsa@...nel.org, irogers@...gle.com,
 adrian.hunter@...el.com, kan.liang@...ux.intel.com, akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
 linux-perf-users@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [RFC] mm: use folio_expected_ref_count() helper for reference
 counting



On 6/10/2025 12:38 PM, David Hildenbrand wrote:
> On 09.06.25 19:08, Shivank Garg wrote:
>> Replace open-coded folio reference count calculations with the
>> folio_expected_ref_count() helper to improve code maintainability
>> and reduce duplication.
>>
>> No functional changes intended.
>>
>> Signed-off-by: Shivank Garg <shivankg@....com>
>> ---
>>   kernel/events/uprobes.c | 5 +++--
>>   mm/memfd.c              | 4 ++--
>>   2 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
>> index 4c965ba77f9f..c978c8c27340 100644
>> --- a/kernel/events/uprobes.c
>> +++ b/kernel/events/uprobes.c
>> @@ -434,10 +434,11 @@ static int __uprobe_write_opcode(struct vm_area_struct *vma,
>>       /*
>>        * When unregistering, we may only zap a PTE if uffd is disabled and
>>        * there are no unexpected folio references ...
>> +     * Expected refs: mappings + swapcache.
>> +     * We hold one additional reference (+1).
>>        */
>>       if (is_register || userfaultfd_missing(vma) ||
>> -        (folio_ref_count(folio) != folio_mapcount(folio) + 1 +
>> -         folio_test_swapcache(folio) * folio_nr_pages(folio)))
>> +        (folio_ref_count(folio) != folio_expected_ref_count(folio) + 1))
>>           goto remap;
>>   
> 
> With the comment removed (the caller holds a reference from GUP) or simplified ("Caller holds an additional folio reference.")
> 
Sure, I'll make this change in revision.

> Acked-by: David Hildenbrand <david@...hat.com>
> 
Thank you!

Best Regards,
Shivank

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ