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: Thu, 7 Mar 2024 11:52:17 +0100
From: David Hildenbrand <david@...hat.com>
To: Richard Weinberger <richard@....at>, linux-mm@...ck.org
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-doc@...r.kernel.org, upstream+pagemap@...ma-star.at,
 adobriyan@...il.com, wangkefeng.wang@...wei.com, ryan.roberts@....com,
 hughd@...gle.com, peterx@...hat.com, avagin@...gle.com, lstoakes@...il.com,
 vbabka@...e.cz, akpm@...ux-foundation.org, usama.anjum@...labora.com,
 corbet@....net
Subject: Re: [PATCH 1/2] [RFC] proc: pagemap: Expose whether a PTE is writable

On 07.03.24 00:23, Richard Weinberger wrote:
> Is a PTE present and writable, bit 58 will be set.
> This allows detecting CoW memory mappings and other mappings
> where a write access will cause a page fault.
> 

But why is that required? What is the target use case? (I did not get 
the cover letter in my inbox)

We're running slowly but steadily out of bits, so we better make wise 
decisions.

Also, consider: Architectures where the dirty/access bit is not HW 
managed could indicate "writable" here although we *will* get a page 
fault to set the page dirty/accessed.

So best this can universally do is say "this PTE currently has write 
permissions".

> Signed-off-by: Richard Weinberger <richard@....at>
> ---
>   fs/proc/task_mmu.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 3f78ebbb795f..7c7e0e954c02 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1341,6 +1341,7 @@ struct pagemapread {
>   #define PM_SOFT_DIRTY		BIT_ULL(55)
>   #define PM_MMAP_EXCLUSIVE	BIT_ULL(56)
>   #define PM_UFFD_WP		BIT_ULL(57)
> +#define PM_WRITE		BIT_ULL(58)
>   #define PM_FILE			BIT_ULL(61)
>   #define PM_SWAP			BIT_ULL(62)
>   #define PM_PRESENT		BIT_ULL(63)
> @@ -1417,6 +1418,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
>   			flags |= PM_SOFT_DIRTY;
>   		if (pte_uffd_wp(pte))
>   			flags |= PM_UFFD_WP;
> +		if (pte_write(pte))
> +			flags |= PM_WRITE;
>   	} else if (is_swap_pte(pte)) {
>   		swp_entry_t entry;
>   		if (pte_swp_soft_dirty(pte))
> @@ -1483,6 +1486,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
>   				flags |= PM_SOFT_DIRTY;
>   			if (pmd_uffd_wp(pmd))
>   				flags |= PM_UFFD_WP;
> +			if (pmd_write(pmd))
> +				flags |= PM_WRITE;
>   			if (pm->show_pfn)
>   				frame = pmd_pfn(pmd) +
>   					((addr & ~PMD_MASK) >> PAGE_SHIFT);
> @@ -1586,6 +1591,9 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask,
>   		if (huge_pte_uffd_wp(pte))
>   			flags |= PM_UFFD_WP;
>   
> +		if (pte_write(pte))
> +			flags |= PM_WRITE;
> +
>   		flags |= PM_PRESENT;
>   		if (pm->show_pfn)
>   			frame = pte_pfn(pte) +

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ