linux-kernelorg-stable/fs
Oleg Nesterov e56fb28740 exec: do not abuse ->cred_guard_mutex in threadgroup_lock()
threadgroup_lock() takes signal->cred_guard_mutex to ensure that
thread_group_leader() is stable.  This doesn't look nice, the scope of
this lock in do_execve() is huge.

And as Dave pointed out this can lead to deadlock, we have the
following dependencies:

	do_execve:		cred_guard_mutex -> i_mutex
	cgroup_mount:		i_mutex -> cgroup_mutex
	attach_task_by_pid:	cgroup_mutex -> cred_guard_mutex

Change de_thread() to take threadgroup_change_begin() around the
switch-the-leader code and change threadgroup_lock() to avoid
->cred_guard_mutex.

Note that de_thread() can't sleep with ->group_rwsem held, this can
obviously deadlock with the exiting leader if the writer is active, so it
does threadgroup_change_end() before schedule().

Reported-by: Dave Jones <davej@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-30 17:04:07 -07:00
..
9p
adfs
affs
afs
autofs4
befs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-04-30 09:36:50 -07:00
bfs
btrfs
cachefiles
ceph
cifs
coda
configfs
cramfs
debugfs
devpts
dlm
ecryptfs ecryptfs: close rmmod race 2013-04-09 14:08:16 -04:00
efs
exofs
exportfs
ext2
ext3 mm: make snapshotting pages for stable writes a per-bio operation 2013-04-29 15:54:33 -07:00
ext4 ext4: fix big-endian bugs which could cause fs corruptions 2013-04-03 12:37:17 -04:00
f2fs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-04-30 09:36:50 -07:00
fat fat (exportfs): rebuild directory-inode if fat_dget() 2013-04-29 18:28:41 -07:00
freevxfs
fscache
fuse
gfs2 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-04-30 09:36:50 -07:00
hfs hfs/hfsplus: convert printks to pr_<level> 2013-04-30 17:04:05 -07:00
hfsplus hfsplus: remove duplicated message prefix in hfsplus_block_free() 2013-04-30 17:04:05 -07:00
hostfs
hpfs
hppfs
hugetlbfs
isofs
jbd fs/buffer.c: remove unnecessary init operation after allocating buffer_head. 2013-04-29 15:54:39 -07:00
jbd2 fs/buffer.c: remove unnecessary init operation after allocating buffer_head. 2013-04-29 15:54:39 -07:00
jffs2
jfs
lockd
logfs
minix
ncpfs
nfs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-04-30 09:36:50 -07:00
nfs_common
nfsd nfsd: convert nfs4_alloc_stid() to use idr_alloc_cyclic() 2013-04-29 18:28:41 -07:00
nilfs2 nilfs2: remove unneeded test in nilfs_writepage() 2013-04-30 17:04:05 -07:00
nls
notify inotify: invalid mask should return a error number but not set it 2013-04-30 17:04:00 -07:00
ntfs
ocfs2
omfs
openpromfs
proc fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes 2013-04-30 17:04:07 -07:00
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
squashfs
sysfs
sysv
ubifs
udf
ufs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-04-30 09:36:50 -07:00
xfs
Kconfig
Kconfig.binfmt fs: make binfmt support for #! scripts modular and removable 2013-04-30 17:04:04 -07:00
Makefile fs: make binfmt support for #! scripts modular and removable 2013-04-30 17:04:04 -07:00
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c coredump: factor out the setting of PF_DUMPCORE 2013-04-30 17:04:06 -07:00
binfmt_elf.c coredump: factor out the setting of PF_DUMPCORE 2013-04-30 17:04:06 -07:00
binfmt_elf_fdpic.c coredump: factor out the setting of PF_DUMPCORE 2013-04-30 17:04:06 -07:00
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c binfmt_misc: reuse string_unescape_inplace() 2013-04-30 17:04:03 -07:00
binfmt_script.c
binfmt_som.c
bio-integrity.c
bio.c
block_dev.c fs/block_dev.c: no need to check inode->i_bdev in bd_forget() 2013-04-30 17:04:00 -07:00
buffer.c fs/buffer.c: remove unnecessary init operation after allocating buffer_head. 2013-04-29 15:54:39 -07:00
char_dev.c
compat.c
compat_binfmt_elf.c
compat_ioctl.c
coredump.c coredump: change wait_for_dump_helpers() to use wait_event_interruptible() 2013-04-30 17:04:06 -07:00
coredump.h
dcache.c fs/dcache.c: add cond_resched() to shrink_dcache_parent() 2013-04-30 17:04:00 -07:00
dcookies.c
direct-io.c direct-io: submit bio after boundary buffer is added to it 2013-04-29 15:54:29 -07:00
drop_caches.c
eventfd.c
eventpoll.c epoll: cleanup: use RCU_INIT_POINTER when nulling 2013-04-30 17:04:04 -07:00
exec.c exec: do not abuse ->cred_guard_mutex in threadgroup_lock() 2013-04-30 17:04:07 -07:00
fcntl.c
fhandle.c
fifo.c
file.c
file_table.c
filesystems.c
fs-writeback.c writeback: set worker desc to identify writeback workers in task dumps 2013-04-30 17:04:02 -07:00
fs_struct.c
generic_acl.c
inode.c
internal.h
ioctl.c
ioprio.c
libfs.c
locks.c
mbcache.c
mount.h
mpage.c
namei.c
namespace.c
no-block.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c fs/read_write.c: fix generic_file_llseek() comment 2013-04-29 15:54:28 -07:00
read_write.h
readdir.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c
super.c
sync.c
timerfd.c
utimes.c
xattr.c
xattr_acl.c