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: <a89b861e-e5ff-32cf-c511-5b17ef60c2dd@redhat.com>
Date:   Mon, 20 Sep 2021 19:36:08 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Tiberiu A Georgescu <tiberiu.georgescu@...anix.com>,
        akpm@...ux-foundation.org, corbet@....net, peterx@...hat.com,
        linux-doc@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Cc:     ivan.teterevkov@...anix.com, florian.schmidt@...anix.com,
        carl.waldspurger@...anix.com, jonathan.davies@...anix.com
Subject: Re: [PATCH v2 1/1] Documentation: update pagemap with shmem
 exceptions

On 20.09.21 18:49, Tiberiu A Georgescu wrote:
> Mentioning the current missing information in the pagemap and alternatives
> on how to retrieve it, in case someone stumbles upon unexpected behaviour.
> 
> Signed-off-by: Tiberiu A Georgescu <tiberiu.georgescu@...anix.com>
> Reviewed-by: Ivan Teterevkov <ivan.teterevkov@...anix.com>
> Reviewed-by: Florian Schmidt <florian.schmidt@...anix.com>
> Reviewed-by: Carl Waldspurger <carl.waldspurger@...anix.com>
> Reviewed-by: Jonathan Davies <jonathan.davies@...anix.com>
> ---
>   Documentation/admin-guide/mm/pagemap.rst | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 
> diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
> index fb578fbbb76c..ea3f88f3c18d 100644
> --- a/Documentation/admin-guide/mm/pagemap.rst
> +++ b/Documentation/admin-guide/mm/pagemap.rst
> @@ -196,6 +196,28 @@ you can go through every map in the process, find the PFNs, look those up
>   in kpagecount, and tally up the number of pages that are only referenced
>   once.
>   
> +Exceptions for Shared Memory
> +============================
> +
> +Page table entries for shared pages are cleared when the pages are zapped or
> +swapped out. This makes swapped out pages indistinguishable from never-allocated
> +ones.
> +
> +In kernel space, the swap location can still be retrieved from the page cache.
> +However, values stored only on the normal PTE get lost irretrievably when the
> +page is swapped out (i.e. SOFT_DIRTY).
> +
> +In user space, whether the page is swapped or none can be deduced with the
> +lseek system call. For a single page, the algorithm is:
> +
> +0. If the pagemap entry of the page has bit 63 (page present) set, the page
> +   is present.
> +1. Otherwise, get an fd to the file where the page is backed. For anonymous
> +   shared pages, the file can be found in ``/proc/pid/map_files/``.
> +2. Call lseek with LSEEK_DATA flag and seek to the virtual address of the page
> +   you wish to inspect. If it overshoots the PAGE_SIZE, the page is NONE.
> +3. Otherwise, the page is in swap.
> +
>   Other notes
>   ===========
>   
> 

Thanks!

Reviewed-by: David Hildenbrand <david@...hat.com>

-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ