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]
Date: Fri, 7 Jun 2024 10:46:44 +0200
From: David Hildenbrand <david@...hat.com>
To: Barry Song <21cnbao@...il.com>, akpm@...ux-foundation.org,
 linux-mm@...ck.org
Cc: chrisl@...nel.org, kasong@...cent.com, linux-kernel@...r.kernel.org,
 minchan@...nel.org, ryan.roberts@....com, surenb@...gle.com,
 v-songbaohua@...o.com, willy@...radead.org
Subject: Re: [PATCH] mm: introduce pmd|pte_need_soft_dirty_wp helpers for
 softdirty write-protect

On 06.06.24 05:40, Barry Song wrote:
> From: Barry Song <v-songbaohua@...o.com>
> 
> This patch introduces the pte_need_soft_dirty_wp and
> pmd_need_soft_dirty_wp helpers to determine if write protection is
> required for softdirty tracking. This can enhance code readability
> and improve its overall appearance.
> 
> These new helpers are utilized in gup, huge_memory, and protect,
> and are particularly applied in do_swap_page() to optimize a
> softdirty scenario where mkwrite can still be performed.

[...]

> +static inline bool pmd_need_soft_dirty_wp(struct vm_area_struct *vma, pmd_t pmd)
> +{
> +	return vma_soft_dirty_enabled(vma) && !pmd_soft_dirty(pmd);
> +}
> +
> +static inline bool pte_need_soft_dirty_wp(struct vm_area_struct *vma, pte_t pte)
> +{
> +	return vma_soft_dirty_enabled(vma) && !pte_soft_dirty(pte);
> +}
> +

Should these be "needs" ? I tend to like these names/semantics.


>   static inline void vma_iter_config(struct vma_iterator *vmi,
>   		unsigned long index, unsigned long last)
>   {
> diff --git a/mm/memory.c b/mm/memory.c
> index db9130488231..6307c43796aa 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4322,7 +4322,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
>   	if (!folio_test_ksm(folio) &&
>   	    (exclusive || folio_ref_count(folio) == 1)) {
>   		if ((vma->vm_flags & VM_WRITE) && !userfaultfd_pte_wp(vma, pte) &&
> -		    !vma_soft_dirty_enabled(vma)) {
> +		    !pte_need_soft_dirty_wp(vma, pte)) {
>   			pte = pte_mkwrite(pte, vma);

I would move that into a separate patch, as it's not a simple conversion.

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ