From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: dave@linux.vnet.ibm.com, containers@lists.linux-foundation.org,
jeremy@goop.org, linux-kernel@vger.kernel.org, arnd@arndb.de
Subject: Re: [RFC v4][PATCH 5/9] Memory managemnet (restore)
Date: Wed, 10 Sep 2008 10:00:19 -0500 [thread overview]
Message-ID: <20080910150019.GA17478@us.ibm.com> (raw)
In-Reply-To: <48C7082A.1050608@cs.columbia.edu>
Quoting Oren Laadan (orenl@cs.columbia.edu):
>
>
> Serge E. Hallyn wrote:
> > Quoting Oren Laadan (orenl@cs.columbia.edu):
>
> [...]
>
> >> +/* change the protection of an address range to be writable/non-writable.
> >> + * this is useful when restoring the memory of a read-only vma */
> >> +static int cr_vma_set_writable(struct mm_struct *mm, unsigned long start,
> >> + unsigned long end, int writable)
> >> +{
> >> + struct vm_area_struct *vma, *prev;
> >> + unsigned long flags = 0;
> >> + int ret = -EINVAL;
> >> +
> >> + cr_debug("vma %#lx-%#lx writable %d\n", start, end, writable);
> >> +
> >> + down_write(&mm->mmap_sem);
> >> + vma = find_vma_prev(mm, start, &prev);
> >> + if (!vma || vma->vm_start > end || vma->vm_end < start)
> >> + goto out;
> >> + if (writable && !(vma->vm_flags & VM_WRITE))
> >> + flags = vma->vm_flags | VM_WRITE;
> >> + else if (!writable && (vma->vm_flags & VM_WRITE))
> >> + flags = vma->vm_flags & ~VM_WRITE;
> >> + cr_debug("flags %#lx\n", flags);
> >> + if (flags)
> >> + ret = mprotect_fixup(vma, &prev, vma->vm_start,
> >> + vma->vm_end, flags);
> >
> > As Dave has pointed out, this appears to be a security problem. I think
>
> As I replied to Dave, I don't see why this would be a security problem.
>
> This handles private memory only. In particular, the uncommon case of a
> read-only VMA tha has modified contents. This _cannot_ affect the file
> from which this VMA may have been mapped.
>
> Shared memory (not file-mapped) will be handled differently: since it is
> always backed up by an inode in shmfs, the restart will populate the
> relevant pages directly. Besides, non-file-mapped shared memory is again
> not a security concern.
>
> Finally, shared memory that maps to a file is simply _not saved_ at all;
> it is part of the file system, and belongs to the (future) file system
> snapshot capability. Since the contents are always available in the file
> system, we don't need to save it (like we don't save shared libraries).
>
> That said, it is necessary that the code ensures that the vm_flags that
> belong to a VMA of a private type, e.g. CR_VMA_ANON/CR_VMA_FILE, indeed
> match it (ie, don't have VM_MAY_SHARE/VM_SHARED). I'll add that.
Cool. That sounds good and I'll look for that in the next version.
There still may be objections about bypassing selinux execmem/execheap
permission checks, but I think that's ok for now. Long-term I expect
we'll want the security_file_mprotect checks there, and selinux users
will have to use a policy where restart is started in a privileged
restart_t domain or somesuch (and eventually transitions back to the
checkpointed selinux type if possible).
thanks,
-serge
> > what you need to do is create a new helper mprotect_fixup_withchecks(),
> > which does all the DAC+MAC checks which are done in the sys_mprotect()
> > loop starting with "for (nstart = start ; ; ) {... Otherwise an
> > unprivileged user can create a checkpoint image of a program which has
> > done a ro shared file mmap, edit the checkpoint, then restart it and (i
> > assume) cause the modified contents to be written to the file. This
> > could violate both DAC checks and selinux checks.
> >
> > So create that helper which does the security checks, and use it
> > both here and in the sys_mprotect() loop, please.
> >
>
> [...]
>
> Oren.
next prev parent reply other threads:[~2008-09-10 15:00 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-09 7:42 [RFC v4][PATCH 0/9] Kernel based checkpoint/restart` Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 1/9] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 2/9] General infrastructure for checkpoint restart Oren Laadan
2008-09-10 6:10 ` MinChan Kim
2008-09-10 18:36 ` Oren Laadan
2008-09-10 22:54 ` MinChan Kim
2008-09-11 6:44 ` Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 3/9] x86 support for checkpoint/restart Oren Laadan
2008-09-09 8:17 ` Ingo Molnar
2008-09-09 23:23 ` Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 4/9] Memory management (dump) Oren Laadan
2008-09-09 9:22 ` Vegard Nossum
2008-09-10 7:51 ` MinChan Kim
2008-09-10 23:49 ` MinChan Kim
2008-09-10 16:55 ` Dave Hansen
2008-09-10 17:45 ` Dave Hansen
2008-09-10 18:28 ` Oren Laadan
2008-09-10 21:03 ` Cleanups for [PATCH " Dave Hansen
2008-09-10 21:38 ` [RFC v4][PATCH " Dave Hansen
2008-09-12 16:57 ` Dave Hansen
2008-09-09 7:42 ` [RFC v4][PATCH 5/9] Memory managemnet (restore) Oren Laadan
2008-09-09 16:07 ` Serge E. Hallyn
2008-09-09 23:35 ` Oren Laadan
2008-09-10 15:00 ` Serge E. Hallyn [this message]
2008-09-10 19:31 ` Dave Hansen
2008-09-10 19:48 ` Oren Laadan
2008-09-10 20:49 ` Dave Hansen
2008-09-11 6:59 ` Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 6/9] Checkpoint/restart: initial documentation Oren Laadan
2008-09-10 7:13 ` MinChan Kim
2008-09-09 7:42 ` [RFC v4][PATCH 7/9] Infrastructure for shared objects Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 8/9] File descriprtors (dump) Oren Laadan
2008-09-09 8:06 ` Vegard Nossum
2008-09-09 8:23 ` Vegard Nossum
2008-09-10 2:01 ` Oren Laadan
2008-09-11 5:02 ` MinChan Kim
2008-09-11 6:37 ` Oren Laadan
2008-09-09 7:42 ` [RFC v4][PATCH 9/9] File descriprtors (restore) Oren Laadan
2008-09-09 16:26 ` Dave Hansen
2008-09-10 1:49 ` Oren Laadan
2008-09-10 16:09 ` Dave Hansen
2008-09-10 18:55 ` Oren Laadan
2008-09-09 18:06 ` [RFC v4][PATCH 0/9] Kernel based checkpoint/restart` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080910150019.GA17478@us.ibm.com \
--to=serue@us.ibm.com \
--cc=arnd@arndb.de \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orenl@cs.columbia.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox