]> git.karo-electronics.de Git - karo-tx-linux.git/commit
prctl: avoid using mmap_sem for exe_file serialization
authorDavidlohr Bueso <dave@stgolabs.net>
Tue, 7 Apr 2015 23:57:06 +0000 (09:57 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 9 Apr 2015 09:07:11 +0000 (19:07 +1000)
commit93c5f4ad30941a2d9ac3ee1420cdd2ac0481daa1
tree93edd2ef800fe84f579be27d3288e157fb1f0650
parentad05ba9b2479b83bb7d088a4d443628844b47d5b
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>
fs/exec.c
kernel/fork.c
kernel/sys.c