public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, Waiman Long <longman@redhat.com>,
	shenghui <shhuiw@foxmail.com>
Subject: Re: [PATCH] locking/lockdep: Zap lock classes even with lock debugging disabled
Date: Wed, 03 Apr 2019 08:48:02 -0700	[thread overview]
Message-ID: <1554306482.118779.198.camel@acm.org> (raw)
In-Reply-To: <20190403124410.GE16362@fuggles.cambridge.arm.com>

On Wed, 2019-04-03 at 13:44 +0100, Will Deacon wrote:
> On Tue, Mar 26, 2019 at 12:59:12PM -0700, Bart Van Assche wrote:
> > Commit a0b0fd53e1e6 ("locking/lockdep: Free lock classes that are no longer
> > in use") changed the behavior of lockdep_free_key_range() from
> > unconditionally zapping lock classes into only zapping lock classes if
> > debug_lock == true. Since the new behavior can cause cat /proc/lockdep to
> > crash due to a NULL pointer dereference, restore the pre-v5.1 behavior.
> 
> Can you elaborate on this NULL dereference please, and why this patch fixes
> it?

Hi Will,

Not zapping lock classes if debug_lock == false leaves dangling pointers in
several lockdep datastructures, e.g. lock_class::name in the all_lock_classes
list. The shell command "cat /proc/lockdep" causes the kernel to iterate the
all_lock_classes list. Hence the "unable to handle kernel paging request"
issue that Shenghui encountered by running cat /proc/lockdep. Please let me
know if you would like me to repost this patch with a more detailed
description.

> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Will Deacon <will.deacon@arm.com>
> > Cc: Waiman Long <longman@redhat.com>
> > Cc: shenghui <shhuiw@foxmail.com>
> > Reported-by: shenghui <shhuiw@foxmail.com>
> > Fixes: a0b0fd53e1e6 ("locking/lockdep: Free lock classes that are no longer in use") # v5.1-rc1.
> > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > ---
> >  kernel/locking/lockdep.c | 23 ++++++-----------------
> >  1 file changed, 6 insertions(+), 17 deletions(-)
> > 
> > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > index 34cdcbedda49..70480e4f8f5d 100644
> > --- a/kernel/locking/lockdep.c
> > +++ b/kernel/locking/lockdep.c
> > @@ -4689,8 +4689,7 @@ static void free_zapped_rcu(struct rcu_head *ch)
> >  		return;
> >  
> >  	raw_local_irq_save(flags);
> > -	if (!graph_lock())
> > -		goto out_irq;
> > +	arch_spin_lock(&lockdep_lock);
> 
> This also throws out the recursion counting. Is that ok?

I think that that's OK. My understanding is that lockdep keeps track of
recursion to avoid that lockdep_lock is locked recursively. However, none
of the functions modified by this patch are called with that lock held.

Thanks,

Bart.



  reply	other threads:[~2019-04-03 15:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 19:59 [PATCH] locking/lockdep: Zap lock classes even with lock debugging disabled Bart Van Assche
2019-04-03 12:44 ` Will Deacon
2019-04-03 15:48   ` Bart Van Assche [this message]
2019-04-03 17:33     ` Will Deacon
2019-04-03 21:15   ` 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=1554306482.118779.198.camel@acm.org \
    --to=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=shhuiw@foxmail.com \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox