[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190403173304.GI17500@fuggles.cambridge.arm.com>
Date: Wed, 3 Apr 2019 18:33:04 +0100
From: Will Deacon <will.deacon@....com>
To: Bart Van Assche <bvanassche@....org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, Waiman Long <longman@...hat.com>,
shenghui <shhuiw@...mail.com>
Subject: Re: [PATCH] locking/lockdep: Zap lock classes even with lock
debugging disabled
On Wed, Apr 03, 2019 at 08:48:02AM -0700, Bart Van Assche wrote:
> 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?
>
> 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.
That would help me, at least (maybe with the crash log). Thanks.
> > > Cc: Thomas Gleixner <tglx@...utronix.de>
> > > Cc: Will Deacon <will.deacon@....com>
> > > Cc: Waiman Long <longman@...hat.com>
> > > Cc: shenghui <shhuiw@...mail.com>
> > > Reported-by: shenghui <shhuiw@...mail.com>
> > > Fixes: a0b0fd53e1e6 ("locking/lockdep: Free lock classes that are no longer in use") # v5.1-rc1.
> > > Signed-off-by: Bart Van Assche <bvanassche@....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.
Might be worth adding a comment to that effect, so people don't change that
in future.
Will
Powered by blists - more mailing lists