Re: [RFC] c/r: prctl: Add ability to set new mm_struct::exe_file v3
From: Cyrill Gorcunov
Date: Fri Mar 09 2012 - 07:57:38 EST
On Fri, Mar 09, 2012 at 01:48:11PM +0100, Oleg Nesterov wrote:
...
> > +
> > + /*
> > + * Setting new mm::exe_file is only allowed
> > + * when no executable VMAs left. This is
> ^^^^^^^^^^
> Perhaps this is just me, but imho "executable" is not clear enough.
> I'd suggest VM_EXECUTABLE to avoid the confusion with VM_EXEC.
OK
>
> > + * special C/R case when a restored program
> > + * need to change own /proc/$pid/exe symlink.
> > + * After this call mm::num_exe_file_vmas become
> > + * meaningless.
> > + */
> > + down_write(&mm->mmap_sem);
> > + if (mm->num_exe_file_vmas == 0) {
>
> You can check this at the very start lockless and simplify the code.
> Once it is zero, it can never grow (or we have a bug anyway).
sure
>
> > + set_mm_exe_file(mm, exe_file);
> > + exe_file = NULL;
> > + } else
> > + err = -EBUSY;
> > + up_write(&mm->mmap_sem);
> > +
> > +exit:
> > + if (exe_file)
> > + fput(exe_file);
>
> This doesn't look correct, you need fput() in any case.
> set_mm_exe_file() does another get_file().
yeah, thanks, will update.
Cyrill
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/