[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120616094714.GF32029@moon>
Date: Sat, 16 Jun 2012 13:47:14 +0400
From: Cyrill Gorcunov <gorcunov@...nvz.org>
To: Konstantin Khlebnikov <khlebnikov@...nvz.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
Pavel Emelianov <xemul@...allels.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Oleg Nesterov <oleg@...hat.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Matt Helsley <matthltc@...ibm.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH 3.5] c/r: prctl: less paranoid prctl_set_mm_exe_file()
On Sat, Jun 16, 2012 at 01:42:23PM +0400, Konstantin Khlebnikov wrote:
> >Side note: there is a little nit with this patch actually,
> >because while when we do c/r we do "right things" and unmap
> >all vm-executable mappings before we set up new exe_file. But
> >we can't guarantee that some brave soul would not setup
> >new exe-file just for it's own, then what we migh have
> >
> > - mm::exe_file set up and points to some file, moreover num_exe_file_vmas might be> 1
> > - application calls for prctl_set_mm_exe_file
> > - set_mm_exe_file(mm, exe_file) called, and it drops num_exe_file_vmas to 0
> > - finally application might call for removed_exe_file_vma
> >
> >void removed_exe_file_vma(struct mm_struct *mm)
> >{
> > mm->num_exe_file_vmas--;
> > if ((mm->num_exe_file_vmas == 0)&& mm->exe_file) {
> > fput(mm->exe_file);
> > mm->exe_file = NULL;
> > }
> >
> >}
> >
> >and it does _not_ test for num_exe_file_vmas being 0 before doing decrement,
> >thus we get inconsistency in counter.
>
> No, removed_exe_file_vma() is called only for vma with VM_EXECUTABLE flag,
> there no way to get such vma other than sys_execve().
> And this brave soul cannot call prctl_set_mm_exe_file() successfully,
> just because for vma with VM_EXECUTABLE flag vma->vm_file == mm->exe_file.
>
> Anyway, I plan to get rid of mm->num_exe_file_vmas and VM_EXECUTABLE.
Yeah, you've changed !path_equal to path_equal. And yes, getting rid of
num_exe_file_vmas is good idea. Btw, Konstantin, why do we need to
call for path_equal? Maybe we can simply test for mm->exe_file == NULL,
and refuse to change anything if it's not nil value? This will simplify
the code.
Cyrill
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists