mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <andrewm@uow.edu.au>
Subject: Recursive deadlock on die_lock
Date: Sun, 14 Oct 2001 14:25:52 +1000	[thread overview]
Message-ID: <27496.1003033552@ocs3.intra.ocs.com.au> (raw)

Typical die() code.

spinlock_t die_lock = SPIN_LOCK_UNLOCKED;

void die(const char * str, struct pt_regs * regs, long err)
{
        console_verbose();
        spin_lock_irq(&die_lock);
        bust_spinlocks(1);
        printk("%s: %04lx\n", str, err & 0xffff);
        show_registers(regs);
        bust_spinlocks(0);
        spin_unlock_irq(&die_lock);
        do_exit(SIGSEGV);
}

If show_registers() fails (which it does far too often on IA64) then
the system deadlocks trying to recursively obtain die_lock.  Also
die_lock is never used outside die(), it should be proc local.
Suggested fix:

void die(const char * str, struct pt_regs * regs, long err)
{
	static spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
	static int die_lock_owner = -1, die_lock_owner_depth = 0;

	if (die_lock_owner != smp_processor_id()) {
		console_verbose();
		spin_lock_irq(&die_lock);
		die_lock_owner = smp_processor_id();
		die_lock_owner_depth = 0;
		bust_spinlocks(1);
	}

	if (++die_lock_owner_depth < 3) {
		printk("%s: %04lx\n", str, err & 0xffff);
		show_registers(regs);
	}
	else
		printk(KERN_ERR "Recursive die() failure, registers suppressed\n");

	bust_spinlocks(0);
	die_lock_owner = -1;
	spin_unlock_irq(&die_lock);
        do_exit(SIGSEGV);
}


             reply	other threads:[~2001-10-14  4:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-14  4:25 Keith Owens [this message]
2001-10-14  6:42 ` Andrew Morton
2001-10-14  7:13   ` Keith Owens
2001-10-14 23:14     ` Eric W. Biederman
2001-10-15  0:42       ` Keith Owens
     [not found] <fa.k3c2fuv.1q26ra4@ifi.uio.no>
     [not found] ` <fa.idkv82v.3jcuip@ifi.uio.no>
2001-10-15  1:55   ` Sam Varshavchik

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=27496.1003033552@ocs3.intra.ocs.com.au \
    --to=kaos@ocs.com.au \
    --cc=andrewm@uow.edu.au \
    --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®