(2.4.25 material?) Fix unbalanced helper_lock in kernel/kmod.c
PATCH 1/1 (2.4.25 material?) Fix unbalanced helper_lock in kernel/kmod.c
Hi all.
First up, sorry for not inlining the patch - trouble with line wrapping.
In 2.6.24-rc8, call_usermodehelper_exec has an exit path that can leave the helper_lock() call at the top of the routine unbalanced. The attached patch fixes this issue.
kernel/kmod.c +3 -1
@@ -468,8 +468,10 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, sub_info->wait = wait;queue_work (khelper_wq, &sub_info->work); -if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ +if (wait ==UMH_NO_WAIT ) {/* task has freed sub_info */ +helper_unlock ();return 0 ; + }wait_for_completion (&done); retval = sub_info->retval;
Quoted 1 line · Nigel Cunningham
Hi all.
Hi,
Quoted 1 line
First up, sorry for not inlining the patch - trouble with line wrapping.
No big deal.
Quoted 3 lines
In 2.6.24-rc8,
call_usermodehelper_exechas an exit path that can leave thehelper_lock()call at the top of the routine unbalanced. The attached patch fixes this issue.
Thanks a lot for the patch (reproduced below), I think it's 2.6.24 material. Andrew?
Quoted 1 line
Signed-off-by Nigel Cunningham <[email protected]>
---
From: Nigel Cunningham <[email protected]>
In 2.6.24-rc8, call_usermodehelper_exec has an exit path that can leave the helper_lock() call at the top of the routine unbalanced. Fix it.
---
kernel/kmod.c +3 -1
@@ -468,8 +468,10 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, sub_info->wait = wait;queue_work (khelper_wq, &sub_info->work); -if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ +if (wait ==UMH_NO_WAIT ) {/* task has freed sub_info */ +helper_unlock ();return 0 ; + }wait_for_completion (&done); retval = sub_info->retval;
Quoted 33 lines · On Thu, 17 Jan 2008 19:02:43 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 1 line · Nigel Cunningham
Hi all.
Hi,
Quoted 1 line
First up, sorry for not inlining the patch - trouble with line wrapping.
No big deal.
Quoted 3 lines
In 2.6.24-rc8,
call_usermodehelper_exechas an exit path that can leave thehelper_lock()call at the top of the routine unbalanced. The attached patch fixes this issue.Thanks a lot for the patch (reproduced below), I think it's 2.6.24 material. Andrew?
Quoted 1 line
Signed-off-by Nigel Cunningham <[email protected]>---
From: Nigel Cunningham <[email protected]>In 2.6.24-rc8,
call_usermodehelper_exechas an exit path that can leave thehelper_lock()call at the top of the routine unbalanced. Fix it.Signed-off-by Nigel Cunningham <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>---
kernel/kmod.c +0
-0@@ -468,8 +468,10 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, sub_info->wait = wait;
kernel/kmod.c int call_usermodehelper_exec(struct subprocess_info *sub_info, · line 477
Quoted 10 lines
kernel/kmod.c +3
-1queue_work (khelper_wq, &sub_info->work); -if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ +if (wait ==UMH_NO_WAIT ) {/* task has freed sub_info */ +helper_unlock ();return 0 ; + }wait_for_completion (&done); retval = sub_info->retval;
Yup, I ended up queueing this:
From: Nigel Cunningham <[email protected]>
call_usermodehelper_exec() has an exit path that can leave the helper_lock() call at the top of the routine unbalanced. The attached patch fixes this issue.
---
kernel/kmod.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
kernel/kmod.c renamed from kernel/kmod.c~fix-unbalanced-helper_lock-in-kernel-kmodc +6 -7
@@ -451,13 +451,11 @@ int call_usermodehelper_exec(struct subp enum umh_wait wait) {DECLARE_COMPLETION_ONSTACK (done); -int retval; +int retval =0 ;helper_lock (); -if (sub_info->path[0 ] =='\0' ) { - retval =0 ; +if (sub_info->path[0 ] =='\0' ) goto out; - }if (!khelper_wq || usermodehelper_disabled) { retval = -EBUSY ;
@@ -468,13 +466,14 @@ int call_usermodehelper_exec(struct subp sub_info->wait = wait;queue_work (khelper_wq, &sub_info->work); -if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ -return 0 ; +if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ + goto unlock;wait_for_completion (&done); retval = sub_info->retval; - out: +out:call_usermodehelper_freeinfo (sub_info); +unlock:helper_unlock ();return retval; }
_
Quoted 1 line · Nigel Cunningham
Hi all.
Hi,
Quoted 1 line
First up, sorry for not inlining the patch - trouble with line wrapping.
No big deal.
Quoted 3 lines
In 2.6.24-rc8,
call_usermodehelper_exechas an exit path that can leave thehelper_lock()call at the top of the routine unbalanced. The attached patch fixes this issue.
Thanks a lot for the patch (reproduced below), I think it's 2.6.24 material. Andrew?
Quoted 1 line
Signed-off-by Nigel Cunningham <[email protected]>
---
From: Nigel Cunningham <[email protected]>
In 2.6.24-rc8, call_usermodehelper_exec has an exit path that can leave the helper_lock() call at the top of the routine unbalanced. Fix it.
---
kernel/kmod.c +3 -1
@@ -468,8 +468,10 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, sub_info->wait = wait;queue_work (khelper_wq, &sub_info->work); -if (wait ==UMH_NO_WAIT )/* task has freed sub_info */ +if (wait ==UMH_NO_WAIT ) {/* task has freed sub_info */ +helper_unlock ();return 0 ; + }wait_for_completion (&done); retval = sub_info->retval;