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: <8ec50b96-8c75-4381-81f2-8140421d186d@os.amperecomputing.com>
Date: Tue, 14 Jan 2025 09:20:19 -0800
From: Yang Shi <yang@...amperecomputing.com>
To: David Hildenbrand <david@...hat.com>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: arnd@...db.de, gregkh@...uxfoundation.org, Liam.Howlett@...cle.com,
 vbabka@...e.cz, jannh@...gle.com, willy@...radead.org,
 liushixin2@...wei.com, akpm@...ux-foundation.org, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] /dev/zero: make private mapping full anonymous mapping




On 1/14/25 9:02 AM, David Hildenbrand wrote:
> On 14.01.25 16:06, David Hildenbrand wrote:
>> On 14.01.25 15:52, Lorenzo Stoakes wrote:
>>> On Tue, Jan 14, 2025 at 02:01:32PM +0100, David Hildenbrand wrote:
>>>> On 13.01.25 23:30, Yang Shi wrote:
>>>>> When creating private mapping for /dev/zero, the driver makes it an
>>>>> anonymous mapping by calling set_vma_anonymous().  But it just sets
>>>>> vm_ops to NULL, vm_file is still valid and vm_pgoff is also file 
>>>>> offset.
>>>>>
>>>>> This is a special case and the VMA doesn't look like either 
>>>>> anonymous VMA
>>>>> or file VMA.  It confused other kernel subsystem, for example, 
>>>>> khugepaged [1].
>>>>>
>>>>> It seems pointless to keep such special case.  Making private 
>>>>> /dev/zero>
>>>> mapping a full anonymous mapping doesn't change the semantic of
>>>>> /dev/zero either.
>>>>>
>>>>> The user visible effect is the mapping entry shown in 
>>>>> /proc/<PID>/smaps
>>>>> and /proc/<PID>/maps.
>>>>>
>>>>> Before the change:
>>>>> ffffb7190000-ffffb7590000 rw-p 00001000 00:06 
>>>>> 8                          /dev/zero
>>>>>
>>>>> After the change:
>>>>> ffffb6130000-ffffb6530000 rw-p 00000000 00:00 0
>>>>>
>>>>
>>>> Hm, not sure about this. It's actually quite consistent to have 
>>>> that output
>>>> in smaps the way it is. You mapped a file at an offset, and it 
>>>> behaves like
>>>> an anonymous mapping apart from that.
>>>>
>>>> Not sure if the buggy khugepaged thing is a good indicator to 
>>>> warrant this
>>>> change.
>>>
>>> Yeah, this is a user-facing fundamental change that hides 
>>> information and
>>> defies expectation so I mean - it's a no go really isn't it?
>>>
>>> I'd rather we _not_ make this anon though, because isn't life confusing
>>> enough David? I thought it was bad enough with 'anon, file and lol 
>>> shmem'
>>> but 'lol lol also /dev/zero' is enough to make me want to frolick in 
>>> the
>>> fields...
>>
>> I recall there are users that rely on this memory to get the shared
>> zeropage on reads etc (in comparison to shmem!), so I better not ...
>> mess with this *at all* :)
>
> Heh, and I recall reading something about odd behavior of /dev/zero 
> and some interesting history [1].
>
> "
> Unlike /dev/null, /dev/zero may be used as a source, not only as a 
> sink for data. All write operations to /dev/zero succeed with no other 
> effects. However, /dev/null is more commonly used for this purpose.
>
> When /dev/zero is memory-mapped, e.g., with mmap, to the virtual 
> address space, it is equivalent to using anonymous memory; i.e. memory 
> not connected to any file.
> "
>
> "equivalent to using anonymous memory" is interesting.

For private mapping. Shared mapping is equivalent to shmem.

>
>
> Also, /dev/zero was there before MAP_ANONYMOUS was invented according 
> to [1], which is quite interesting.

Interesting... Didn't know this before.

>
> ... so this is anonymous memory as "real" as it can get :)

Let's make /dev/zero as real as anonymous memory :)

>
>
> [1] https://en.wikipedia.org/wiki//dev/zero
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ