mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andrew Morton <akpm@osdl.org>
Cc: Arjan van de Ven <arjan@infradead.org>, linux-kernel@vger.kernel.org
Subject: [patch, 2.6.17-mm2] fix acct_collect() siglock bug
Date: Sat, 24 Jun 2006 23:48:53 +0200	[thread overview]
Message-ID: <20060624214853.GA19254@elte.hu> (raw)


the patch below fixes a siglock usage bug introduced in -mm2. The lock 
validator found it during bootup.

---------------
Subject: fix acct_collect() siglock bug
From: Ingo Molnar <mingo@elte.hu>

the lock validator noticed the following bug:

 =========================================================
 [ INFO: possible irq lock inversion dependency detected ]
 ---------------------------------------------------------
 swapper/0 just changed the state of lock:
  (tasklist_lock){..-?}, at: [<c01247c8>] send_group_sig_info+0xe/0x2f
 but this lock took another, soft-irq-unsafe lock in the past:
  (&sighand->siglock){--..}

 and interrupts could create inverse lock ordering between them.
 ...
  -> (init_sighand.siglock){....} ops: 18 {
 ...
       hardirq-on-W at:
                       [<c0130577>] lock_acquire+0x56/0x73
                       [<c03ec59c>] _spin_lock+0x24/0x32
                       [<c01374bd>] acct_collect+0x81/0x115
                       [<c011b4fa>] do_exit+0x19a/0x7b3
                       [<c01273ce>] ____call_usermodehelper+0xdf/0xe1
                       [<c01007f1>] kernel_thread_helper+0x5/0xb

it turns out that acct_collect() takes current->sighand->siglock
with interrupts enabled - a big no-no. Fix it by disabling
interrupts.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/acct.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux/kernel/acct.c
===================================================================
--- linux.orig/kernel/acct.c
+++ linux/kernel/acct.c
@@ -549,7 +549,7 @@ void acct_collect(long exitcode, int gro
 		up_read(&current->mm->mmap_sem);
 	}
 
-	spin_lock(&current->sighand->siglock);
+	spin_lock_irq(&current->sighand->siglock);
 	if (group_dead)
 		pacct->ac_mem = vsize / 1024;
 	if (thread_group_leader(current)) {
@@ -567,7 +567,7 @@ void acct_collect(long exitcode, int gro
 	pacct->ac_stime = cputime_add(pacct->ac_stime, current->stime);
 	pacct->ac_minflt += current->min_flt;
 	pacct->ac_majflt += current->maj_flt;
-	spin_unlock(&current->sighand->siglock);
+	spin_unlock_irq(&current->sighand->siglock);
 }
 
 /**

                 reply	other threads:[~2006-06-24 21:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060624214853.GA19254@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®