diff options
author | Davidlohr Bueso <dave@stgolabs.net> | 2015-04-16 12:47:59 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:07 -0400 |
commit | 6e399cd144d8500ffb5d40fa6848890e2580a80a (patch) | |
tree | 930e8ec3664bc6b14c562f38acdc511ea7e938b8 /fs/exec.c | |
parent | 90f31d0ea88880f780574f3d0bb1a227c4c66ca3 (diff) | |
download | linux-6e399cd144d8500ffb5d40fa6848890e2580a80a.tar.gz linux-6e399cd144d8500ffb5d40fa6848890e2580a80a.tar.bz2 linux-6e399cd144d8500ffb5d40fa6848890e2580a80a.zip |
prctl: avoid using mmap_sem for exe_file serialization
Oleg cleverly suggested using xchg() to set the new mm->exe_file instead
of calling set_mm_exe_file() which requires some form of serialization --
mmap_sem in this case. For archs that do not have atomic rmw instructions
we still fallback to a spinlock alternative, so this should always be
safe. As such, we only need the mmap_sem for looking up the backing
vm_file, which can be done sharing the lock. Naturally, this means we
need to manually deal with both the new and old file reference counting,
and we need not worry about the MMF_EXE_FILE_CHANGED bits, which can
probably be deleted in the future anyway.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Suggested-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c index c7f9b733406d..a5fef835ebc5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1078,7 +1078,13 @@ int flush_old_exec(struct linux_binprm * bprm) if (retval) goto out; + /* + * Must be called _before_ exec_mmap() as bprm->mm is + * not visibile until then. This also enables the update + * to be lockless. + */ set_mm_exe_file(bprm->mm, bprm->file); + /* * Release all of the old mmap stuff */ |