LKML Archive on
help / color / mirror / Atom feed
From: Oleg Nesterov <>
To: Matt Helsley <>
Subject: Re: + fix-procfs-task-exe-symlink.patch added to -mm tree
Date: Wed, 30 Jan 2008 14:06:17 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <1201656208.4400.141.camel@localhost.localdomain>

On 01/29, Matt Helsley wrote:
> On Tue, 2008-01-29 at 14:36 +0300, Oleg Nesterov wrote:
> > 
> > This patch has a lot of complications because it tries to preserve the
> > current behaviour: we release the bprm->file when all VM_EXECTUABLE vmas
> > are unmapped. Q: is this so important/useful? I don't think this is very
> > common case, and I don't quite understand why it is critical to release
> > the file. To unmount fs after starting the app? One can always copy
> Yes. While most programs don't need this it is still very important for
> some critical programs to be able to unmap the executable and thereby
> allow unmounting the filesystem. Unfortunately, I don't have a confirmed
> specific example for you. A wild guess: some distro install or live CDs
> might use this.

OK, thanks. I just wanted to be sure I didn't miss some other reason.

> > Sorry, I was wrong.
> > 
> > mmput() has to release ->exe_file if it is called when exec fails before the
> > first do_mmmap(MAP_EXECUTABLE). This also means that it is not completely
> > trivial to set ->exe_file before exec_mmap(), it can fail. This is solvable,
> > but I'm not sure we should do this.
> >
> > Still, the accounting looks a little bit fragile to me. flush_old_exec()
> > increments ->f_count but sets ->num_exe_file_vmas = 0 because we know that
> > the next elf_map() will bump ->num_exe_file_vmas and thus "sync" 2 counters.
> > But I don't see how to do better if we really want to release the file when
> > VM_EXECUTABLE disappears.
> OK, I'll leave it unless something better comes to mind.

Err, I was double wrong. It _is_ trivial to set ->exe_file before exec_mmap(),


+ 		get_file(bprm->file);
+ 		set_mm_exe_file(bprm->mm, bprm->file);
		retval = exec_mmap(bprm->mm);
		if (retval)
			goto mmap_failed;

		bprm->mm = NULL;		/* We're using it now */

If exec_mmap() fails, the caller (do_execve) has to mmput(bprm->mm)
anyway, and this imply set_mm_exe_file(NULL). This way set_mm_exe_file()
doesn't need any locking.

Not that this is relly important, but still.

However. I didn't notice this patch plays with #ifdef CONFIG_PROC_FS.
Without CONFIG_PROC_FS we seem to leak bprm->file, I'd suggest to move
get_file(bprm->file) into set_mm_exe_file().

> Thanks for taking a look at this patch and asking questions.

Thanks for your answers ;)


  reply	other threads:[~2008-01-30 11:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
     [not found] ` <>
     [not found]   ` <1201565920.10206.149.camel@localhost.localdomain>
2008-01-29 11:36     ` Oleg Nesterov
2008-01-30  1:23       ` Matt Helsley
2008-01-30 11:06         ` Oleg Nesterov [this message]
2008-01-30 23:32           ` Matt Helsley

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: + fix-procfs-task-exe-symlink.patch added to -mm tree' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).