Re: [PATCH v1] fs/proc/task_mmu: fix PAGE_IS_PFNZERO detection for the huge zero folio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30.06.25 07:18, Muhammad Usama Anjum wrote:
On 6/17/25 7:35 PM, David Hildenbrand wrote:
is_zero_pfn() does not work for the huge zero folio. Fix it by using
is_huge_zero_pmd().

Found by code inspection.

Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs")
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
---

Probably we should Cc stable, thoughts?

We should also extend the pagemap_ioctl selftest to cover this case, but I
don't have time for that right now. @Muhammad ?
Currently, we don't have any test case covering zero pfn. I'm trying to write
a few test cases. But I'm not able to get ZERO PFN. I've tried to allocate a
read only memory and then read it. Is there a trick to how to create ZERO PFN
memory from userspace?

You need a MAP_ANON | MAP_PRIVATE mapping and have to make sure that the compiler does not optimize out the read.

E.g.,

char *mem =  mmap(...);
char tmp = *mem;

asm volatile("" : "+r" (tmp))

or

char *mem =  mmap(...);

*(volatile char *)mem;


To get the shared huge zero folio, you need a suitably aligned VMA. See run_with_huge_zeropage() in in tools/testing/selftests/mm/cow.c as one example.

--
Cheers,

David / dhildenb





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux