All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: pm list <linux-pm@lists.linux-foundation.org>,
	nigel@nigel.suspend2.net,
	TuxOnIce-devel <tuxonice-devel@lists.tuxonice.net>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] (2.4.25 material?) Fix unbalanced helper_lock in kernel/kmod.c
Date: Thu, 17 Jan 2008 11:23:32 -0800	[thread overview]
Message-ID: <20080117112332.9e34b7d9.akpm@linux-foundation.org> (raw)
In-Reply-To: <200801171902.44133.rjw@sisk.pl>

On Thu, 17 Jan 2008 19:02:43 +0100 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> On Thursday, 17 of January 2008, Nigel Cunningham wrote:
> > Hi all.
> 
> Hi,
> 
> > First up, sorry for not inlining the patch - trouble with line wrapping.
> 
> No big deal.
> 
> > 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.
> 
> Thanks a lot for the patch (reproduced below), I think it's 2.6.24 material.
> Andrew?
> 
> > Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
> 
> ---
> From: Nigel Cunningham <nigel@tuxonice.net>
> 
> 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.
> 
> Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
> diff --git a/kernel/kmod.c b/kernel/kmod.c
> index c6a4f8a..de27e15 100644
> --- a/kernel/kmod.c
> +++ b/kernel/kmod.c
> @@ -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;
>  

Yup, I ended up queueing this:

From: Nigel Cunningham <nigel@nigel.suspend2.net>

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.

Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/kmod.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff -puN kernel/kmod.c~fix-unbalanced-helper_lock-in-kernel-kmodc kernel/kmod.c
--- a/kernel/kmod.c~fix-unbalanced-helper_lock-in-kernel-kmodc
+++ a/kernel/kmod.c
@@ -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;
 }
_

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: nigel@nigel.suspend2.net, LKML <linux-kernel@vger.kernel.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	TuxOnIce-devel <tuxonice-devel@lists.tuxonice.net>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH] (2.4.25 material?) Fix unbalanced helper_lock in kernel/kmod.c
Date: Thu, 17 Jan 2008 11:23:32 -0800	[thread overview]
Message-ID: <20080117112332.9e34b7d9.akpm@linux-foundation.org> (raw)
In-Reply-To: <200801171902.44133.rjw@sisk.pl>

On Thu, 17 Jan 2008 19:02:43 +0100 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> On Thursday, 17 of January 2008, Nigel Cunningham wrote:
> > Hi all.
> 
> Hi,
> 
> > First up, sorry for not inlining the patch - trouble with line wrapping.
> 
> No big deal.
> 
> > 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.
> 
> Thanks a lot for the patch (reproduced below), I think it's 2.6.24 material.
> Andrew?
> 
> > Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
> 
> ---
> From: Nigel Cunningham <nigel@tuxonice.net>
> 
> 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.
> 
> Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
> diff --git a/kernel/kmod.c b/kernel/kmod.c
> index c6a4f8a..de27e15 100644
> --- a/kernel/kmod.c
> +++ b/kernel/kmod.c
> @@ -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;
>  

Yup, I ended up queueing this:

From: Nigel Cunningham <nigel@nigel.suspend2.net>

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.

Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/kmod.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff -puN kernel/kmod.c~fix-unbalanced-helper_lock-in-kernel-kmodc kernel/kmod.c
--- a/kernel/kmod.c~fix-unbalanced-helper_lock-in-kernel-kmodc
+++ a/kernel/kmod.c
@@ -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;
 }
_


  reply	other threads:[~2008-01-17 19:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-17  0:29 [PATCH] (2.4.25 material?) Fix unbalanced helper_lock in kernel/kmod.c Nigel Cunningham
2008-01-17 18:02 ` Rafael J. Wysocki
2008-01-17 19:23   ` Andrew Morton [this message]
2008-01-17 19:23     ` Andrew Morton
2008-01-17 18:02 ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2008-01-17  0:29 Nigel Cunningham

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=20080117112332.9e34b7d9.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=rjw@sisk.pl \
    --cc=tuxonice-devel@lists.tuxonice.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.