From: Oleg Nesterov <oleg@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>, tj@kernel.org
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
akpm@linux-foundation.org, bharrosh@panasas.com,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: UMH_WAIT_EXEC->UMH_WAIT_PROC deadlock
Date: Mon, 21 May 2012 19:34:53 +0200 [thread overview]
Message-ID: <20120521173453.GB31803@redhat.com> (raw)
In-Reply-To: <87fwau4aag.fsf@rustcorp.com.au>
On 05/21, Rusty Russell wrote:
>
> I rather like Oleg's "use system wq" patch. Seems like a net
> simplification.
OK. Lets discuss this patch (attached below).
Obviously, I like it too ;) And yes, it looks like a cleanup to me.
But. This change can obviously increase the number of
__call_usermodehelper()'s running in parallel, and in particular increase
the number of workqueue threads.
Is it OK?
Another issue is that Tejun dislikes the usage of system_unbound_wq.
I guess, because WQ_UNBOUND implies WQ_HIGHPRI. Btw, I do not really
understand why. And, otoh, I don't think that __call_usermodehelper()
should be bound to any CPU, this would look a bit strange to me.
So, Tejun, what do you think about this patch? Which system_ wq it
should use if you think it makes sense?
Oleg.
------------------------------------------------------------------------
[PATCH] kmod: kill khelper_wq, fix UMH_WAIT_EXEC->UMH_WAIT_PROC deadlock
A UMH_WAIT_EXEC request can trigger the reqursive UMH_WAIT_PROC
if kernel_execve(sub_info->path) needs request_module() to load
the binfmt module.
This leads to deadlock. The worker thread sleeps waiting for
CLONE_VFORK completion, its child queues another sub_info->work
and waits for it, but since khelper_wq->max_active == 1 no other
work can run.
Quiting Tetsuo:
The easiest example to observe this deadlock is to use
a corrupted /sbin/hotplug binary (like shown below).
# : > /tmp/dummy
# chmod 755 /tmp/dummy
# echo /tmp/dummy > /proc/sys/kernel/hotplug
# modprobe whatever
Kill khelper_wq and use the system wq instead. Workqueues were
greatly improved, I do not think kmod needs the dedicated wq.
In the scenario above, UMH_WAIT_EXEC succeeds with this patch
assuming that the number of UMH_WAIT_EXEC requests in flight
doesn't exceed max_active.
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/kmod.h | 2 --
init/main.c | 1 -
kernel/kmod.c | 14 +++-----------
3 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 9efeae6..eced4e3 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -110,8 +110,6 @@ call_usermodehelper(char *path, char **argv, char **envp, int wait)
extern struct ctl_table usermodehelper_table[];
-extern void usermodehelper_init(void);
-
extern int usermodehelper_disable(void);
extern void usermodehelper_enable(void);
extern bool usermodehelper_is_disabled(void);
diff --git a/init/main.c b/init/main.c
index ff49a6d..f538aa5 100644
--- a/init/main.c
+++ b/init/main.c
@@ -722,7 +722,6 @@ static void __init do_initcalls(void)
static void __init do_basic_setup(void)
{
cpuset_init_smp();
- usermodehelper_init();
shmem_init();
driver_init();
init_irq_proc();
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 3a69031..d1712c0 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -43,8 +43,6 @@
extern int max_threads;
-static struct workqueue_struct *khelper_wq;
-
#define CAP_BSET (void *)1
#define CAP_PI (void *)2
@@ -285,7 +283,7 @@ static int wait_for_helper(void *data)
return 0;
}
-/* This is run by khelper thread */
+/* This is run by workqueue thread */
static void __call_usermodehelper(struct work_struct *work)
{
struct subprocess_info *sub_info =
@@ -494,7 +492,7 @@ pr_crit("UMH: call %16s:%-4d inf=%p w=%d %s\n",
if (sub_info->path[0] == '\0')
goto out;
- if (!khelper_wq || usermodehelper_disabled) {
+ if (!system_unbound_wq || usermodehelper_disabled) {
retval = -EBUSY;
goto out;
}
@@ -502,7 +500,7 @@ pr_crit("UMH: call %16s:%-4d inf=%p w=%d %s\n",
sub_info->complete = &done;
sub_info->wait = wait;
- queue_work(khelper_wq, &sub_info->work);
+ queue_work(system_unbound_wq, &sub_info->work);
if (wait == UMH_NO_WAIT) /* task has freed sub_info */
goto unlock;
@@ -605,9 +603,3 @@ struct ctl_table usermodehelper_table[] = {
},
{ }
};
-
-void __init usermodehelper_init(void)
-{
- khelper_wq = create_singlethread_workqueue("khelper");
- BUG_ON(!khelper_wq);
-}
--
1.5.5.1
next prev parent reply other threads:[~2012-05-21 18:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 23:18 [PATCHSET 0/4] kmod: Optional timeout on the wait in call_usermodehelper_exec Boaz Harrosh
2012-03-20 23:23 ` [PATCH 1/4] kmod: Un-export call_usermodehelper_freeinfo() Boaz Harrosh
2012-03-20 23:26 ` [PATCH 2/4] kmod: Convert two call sites to call_usermodehelper_fns() Boaz Harrosh
2012-03-22 3:00 ` James Morris
2012-03-20 23:28 ` [PATCH 3/4] kmod: Move call_usermodehelper_fns() to .c file and unexport it's helpers Boaz Harrosh
2012-03-20 23:32 ` [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout() API Boaz Harrosh
2012-03-22 2:44 ` Boaz Harrosh
2012-03-22 2:48 ` Boaz Harrosh
2012-03-22 2:52 ` Boaz Harrosh
[not found] ` <201203241028.IGJ09825.MtOVFHFJQSLOFO@I-love.SAKURA.ne.jp>
[not found] ` <4F6D35F0.2020808@panasas.com>
[not found] ` <20120323200028.fadf49f8.akpm@linux-foundation.org>
[not found] ` <20120324145308.GA10023@redhat.com>
[not found] ` <201205191121.BIF57837.FHFOtMOLJQSOFV@I-love.SAKURA.ne.jp>
[not found] ` <4FB7170F.7070807@panasas.com>
2012-05-21 17:01 ` call_usermodehelper && check_hung_uninterruptible_tasks Oleg Nesterov
2012-05-21 18:24 ` Oleg Nesterov
[not found] ` <87fwau4aag.fsf@rustcorp.com.au>
2012-05-21 17:34 ` Oleg Nesterov [this message]
2012-05-21 18:12 ` UMH_WAIT_EXEC->UMH_WAIT_PROC deadlock Oleg Nesterov
2012-03-22 11:48 ` [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout()API Tetsuo Handa
2012-03-22 14:27 ` [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout() API Oleg Nesterov
2012-03-22 14:42 ` Oleg Nesterov
2012-03-22 19:08 ` Boaz Harrosh
2012-03-22 22:16 ` [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout()API Tetsuo Handa
2012-03-23 4:48 ` Boaz Harrosh
2012-03-23 5:23 ` Tetsuo Handa
2012-03-23 16:30 ` Oleg Nesterov
2012-03-23 13:34 ` [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout() API Oleg Nesterov
2012-03-21 15:35 ` [PATCHSET 0/4] kmod: Optional timeout on the wait in call_usermodehelper_exec Greg KH
2012-03-22 0:18 ` Boaz Harrosh
2012-03-22 0:31 ` Myklebust, Trond
2012-03-22 1:18 ` Boaz Harrosh
2012-03-27 1:57 ` [PATCHSET 0/6 version 2] " Boaz Harrosh
2012-03-27 2:00 ` [PATCH 1/6] kmod: Unexport call_usermodehelper_freeinfo() Boaz Harrosh
2012-03-27 2:02 ` [PATCH 2/6] kmod: Convert two call sites to call_usermodehelper_fns() Boaz Harrosh
2012-03-27 2:04 ` [PATCH 3/6] kmod: Move call_usermodehelper_fns() to .c file and unexport all it's helpers Boaz Harrosh
2012-03-27 2:06 ` [PATCH 4/6 OPTION-A] completion: Add new wait_for_completion_timeout_state Boaz Harrosh
2012-03-27 2:33 ` [PATCH 4/6 OPTION-A version 3] " Boaz Harrosh
2012-03-27 8:11 ` Peter Zijlstra
2012-03-28 18:19 ` Boaz Harrosh
2012-03-28 18:25 ` Peter Zijlstra
2012-03-28 17:38 ` Oleg Nesterov
2012-03-27 2:09 ` [PATCH 4/6 option-B] kmod: add new wait_for_completion_timeout_state() helper Boaz Harrosh
2012-03-27 2:13 ` [PATCH 5/6] kmod: Add new call_usermodehelper_timeout() API Boaz Harrosh
2012-03-27 15:43 ` Oleg Nesterov
2012-03-28 17:04 ` Oleg Nesterov
2012-03-27 2:15 ` [PATCH 6/6] kmod: optional: Convert the use of xchg to a kref Boaz Harrosh
2012-03-28 16:35 ` Oleg Nesterov
2012-03-27 21:07 ` [PATCHSET 0/6 version 2] kmod: Optional timeout on the wait in call_usermodehelper_exec Andrew Morton
2012-03-28 20:19 ` Oleg Nesterov
2012-03-28 21:42 ` Boaz Harrosh
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120521173453.GB31803@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bharrosh@panasas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox