]> git.baikalelectronics.ru Git - kernel.git/commit
exec: fix set_binfmt() vs sys_delete_module() race
authorOleg Nesterov <oleg@redhat.com>
Wed, 23 Sep 2009 22:56:59 +0000 (15:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Sep 2009 14:21:01 +0000 (07:21 -0700)
commitc614d4536b8a86480cbb8b627b5872ddf255c26a
tree58ae7325f80394cb86409d5876c710376dde8e1a
parentc6cd59029c05757d5aee141605f3b5b78f6fc752
exec: fix set_binfmt() vs sys_delete_module() race

sys_delete_module() can set MODULE_STATE_GOING after
search_binary_handler() does try_module_get().  In this case
set_binfmt()->try_module_get() fails but since none of the callers
check the returned error, the task will run with the wrong old
->binfmt.

The proper fix should change all ->load_binary() methods, but we can
rely on fact that the caller must hold a reference to binfmt->module
and use __module_get() which never fails.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/exec.c
include/linux/binfmts.h