Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1709733
| From | Rik van Riel <riel@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK |
| Date | 2017-08-11 17:30 +0200 |
| Message-ID | <udk2R-5cA-9@gated-at.bofh.it> (permalink) |
| References | <ubupJ-3f0-29@gated-at.bofh.it> <ubupJ-3f0-27@gated-at.bofh.it> <ucXzk-7tV-29@gated-at.bofh.it> |
| Organization | Red Hat, Inc |
On Thu, 2017-08-10 at 17:23 +0200, Michal Hocko wrote:
> On Sun 06-08-17 10:04:25, Rik van Riel wrote:
> [...]
> > diff --git a/kernel/fork.c b/kernel/fork.c
> > index 17921b0390b4..db1fb2802ecc 100644
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -659,6 +659,13 @@ static __latent_entropy int dup_mmap(struct
> > mm_struct *mm,
> > tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT);
> > tmp->vm_next = tmp->vm_prev = NULL;
> > file = tmp->vm_file;
> > +
> > + /* With VM_WIPEONFORK, the child gets an empty
> > VMA. */
> > + if (tmp->vm_flags & VM_WIPEONFORK) {
> > + tmp->vm_file = file = NULL;
> > + tmp->vm_ops = NULL;
> > + }
>
> What about VM_SHARED/|VM)MAYSHARE flags. Is it OK to keep the around?
> At
> least do_anonymous_page SIGBUS on !vm_ops && VM_SHARED. Or do I miss
> where those flags are cleared?
Huh, good spotting. That makes me wonder why the test case that
Mike and I ran worked just fine on a MAP_SHARED|MAP_ANONYMOUS VMA,
and returned zero-filled memory when read by the child process.
OK, I'll do a minimal implementation for now, which will return
-EINVAL if MADV_WIPEONFORK is called on a VMA with MAP_SHARED
and/or an mmapped file.
It will work the way it is supposed to with anonymous MAP_PRIVATE
memory, which is likely the only memory it will be used on, anyway.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK riel@redhat.com - 2017-08-06 16:10 +0200
Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK Michal Hocko <mhocko@kernel.org> - 2017-08-10 17:30 +0200
Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK Rik van Riel <riel@redhat.com> - 2017-08-11 17:30 +0200
Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK Mike Kravetz <mike.kravetz@oracle.com> - 2017-08-11 18:40 +0200
Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK Rik van Riel <riel@redhat.com> - 2017-08-11 19:00 +0200
Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK Mike Kravetz <mike.kravetz@oracle.com> - 2017-08-11 19:10 +0200
csiph-web