[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMgLiBsGcTq8yoa1Rud0-qiRk11uChyS=CU8+5KTw35c2YmyBw@mail.gmail.com>
Date: Fri, 3 Dec 2021 10:56:02 +0800
From: fei luo <morphyluo@...il.com>
To: david@...hat.com
Cc: akpm@...ux-foundation.org, mike.kravetz@...cle.com, arnd@...db.de,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-arch@...r.kernel.org, xiaofeng.yan2012@...il.com
Subject: Re: [RFD] clear virtual machine memory when virtual machine is turned off
David Hildenbrand <david@...hat.com> 于2021年12月2日周四 20:47写道:
>
> >
> > Although this part of memory will be cleared before being reused by
> >
> > user-mode programs , But the sensitive data staying in the memory
> >
> > for a long time will undoubtedly increase the risk of information leakage,
> >
> > so I wonder whether it is possible to add a flag (like MAP_UNMAPZERO)
> >
> > to the mmap(2) system call to indicate that the mapped memory needs
> >
> > to be cleared zero when unmap called or when the program exits.
> >
>
> it's not immediately clear to me why data of user space program #1
> should be more important than data of user space program #2 and why the
> program should make that decision.
>
What I mean here is that by adding a flag to the mmap(2) system call to
indicate that this memory will be cleared after munmap() called or
the process exits, and no sensitive data will be left in the system memory,
so as to avoid information leakage after the process exits.And the task
of clearing memory needs to be done in the kernel
> >
> > Of course, the page clear operation not only occurs when unmap called
> >
> > or program exits, but also need to consider scenes such as page migration,
> >
> > swap, balloon etc.
>
> What about page migration (who clears the old memory location?),
> swapping (who clears the swap space, also considering zram?), writeback
> (who clears file storage)? Also, as you indicate, MADV_DONTNEED,
> MADV_FREE, FALLOC_FL_PUNCH_HOLE would need care ...
>
> To disable swapping you can use mlock(). To handle file storage ...
> don't use files. You'd still have to handle any cases where physical
> memory locations might be freed and land in the buddy, and for that we
> do have ...
>
Yes, this feature needs to consider when page migration, the content
of the old page needs to be cleared, and the swap space needs to
be cleared before swap. Of course, for security reasons, swap can be
prohibited. Here I just listed some of the changes involved, not all
aspects. This feature is mainly aimed at clearing the memory of
the virtual machine after shutdown, so it is more aimed at anonymous
mapping and huge page mapping
> >
> >
> > When reusing the page that has been cleared, there is no need to clear it
> >
> > again, which also speeds up the memory allocation of user-mode programs.
> >
> >
> > Is this feature feasible?
>
> "init_on_free=1" for the system as a whole, which might sounds like what
> might tackle part of your use case.
>
This feature is mainly to prevent the used memory information from leaking,
not to clear the memory before use.
--
Thanks
Powered by blists - more mailing lists