From: Bart Van Assche <bvanassche@acm.org>
To: shenghui <shhuiw@foxmail.com>,
peterz@infradead.org, mingo@redhat.com, will.deacon@arm.com,
linux-kernel@vger.kernel.org
Subject: Re: "cat /proc/lockdep" after "rmmod <some module>" when !debug_locks will crash the system
Date: Mon, 25 Mar 2019 08:27:01 -0700 [thread overview]
Message-ID: <1553527621.118779.2.camel@acm.org> (raw)
In-Reply-To: <5c98a345.1c69fb81.21300.0be5SMTPIN_ADDED_BROKEN@mx.google.com>
On Mon, 2019-03-25 at 17:45 +0800, shenghui wrote:
> Sorry to trouble you.
>
> I installed virtualbox-5.2.24 on my system (x86 32) and on bootup I got some warning:
> ---------------------
> 1251 [ 42.640869] DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)
> 1252 [ 42.640880] WARNING: CPU: 0 PID: 841 at kernel/locking/lockdep.c:4132 check_flags.part.45+0x9e/0x190
> ...
>
> As no crash afterwards, I just ignore the warning and continue using my system.
>
> Later I rmmod some module and run "cat /proc/lockdep", the system crashed.
> (Sorry I cannot capture the crash log as kdump didn't work on my system, but I can
> see some words "...normal kernel read fault...")
>
>
> Then I walked through the code and found:
> 1) DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled) will turn debug_locks to 0
> 2) if !debug_locks, graph_lock() will return 0
> 3) On module unloading, lockdep_free_key_range_reg() will run.
> But when !debug_locks, lockdep_free_key_range_reg() will do nothing.
>
> 4743 static void lockdep_free_key_range_reg(void *start, unsigned long size)
> 4744 {
> ...
> 4751 raw_local_irq_save(flags);
> 4752 locked = graph_lock();
> 4753 if (!locked)
> 4754 goto out_irq;
> ...
> 4759
> 4760 graph_unlock();
> 4761 out_irq:
> 4762 raw_local_irq_restore(flags);
>
> 4) The result is: module is unloaded, but some lock_class related with the module
> still exist in all_lock_classes.
> 5) 'cat /proc/lockdep' will access elements of all_lock_classes, and will trigger the crash.
>
>
> Seems the usage of "!graph_lock()" can prevent any new changes to all_lock_classes and other hashtables
> if !debug_locks.
Hi Shenghui,
None of the rmmod / cat /proc/lockdep tests I ran triggered the above warning.
It would help if you could share the steps you followed to trigger that warning.
Thanks,
Bart.
next parent reply other threads:[~2019-03-25 15:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5c98a345.1c69fb81.21300.0be5SMTPIN_ADDED_BROKEN@mx.google.com>
2019-03-25 15:27 ` Bart Van Assche [this message]
[not found] ` <5c9973cc.1c69fb81.371e8.7b9fSMTPIN_ADDED_BROKEN@mx.google.com>
2019-03-26 17:44 ` "cat /proc/lockdep" after "rmmod <some module>" when !debug_locks will crash the system Bart Van Assche
2019-03-26 17:49 ` Bart Van Assche
2019-03-25 17:06 ` Bart Van Assche
[not found] ` <5c99721b.1c69fb81.5bb69.0006SMTPIN_ADDED_BROKEN@mx.google.com>
2019-03-26 0:54 ` Bart Van Assche
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=1553527621.118779.2.camel@acm.org \
--to=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shhuiw@foxmail.com \
--cc=will.deacon@arm.com \
/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.