lkml.org 
[lkml]   [2018]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 17/24] locking/lockdep: Free lock classes that are no longer in use
From
Date
On Fri, 2018-12-07 at 13:14 +0100, Peter Zijlstra wrote:
> On Thu, Dec 06, 2018 at 05:11:41PM -0800, Bart Van Assche wrote:
> > + if (WARN_ON_ONCE(!hlock_class(prev)->hash_entry.pprev) ||
> > + WARN_ONCE(!hlock_class(next)->hash_entry.pprev,
> > + KERN_INFO "Detected use-after-free of lock class %s\n",
> > + hlock_class(next)->name)) {
> > + return 2;
> > + }
>
> Ah, this is that UaF on ->name, but it only happens when there's already
> been a UaF, so that's fine I suppose. Still a note on that earlier
> Changelog would've been nice I suppose.

How about reporting the class pointer only as is done elsewhere in the
lockdep code?

> > +/* Must be called with the graph lock held. */
> > +static void remove_class_from_lock_chain(struct lock_chain *chain,
> > + struct lock_class *class)
> > +{
> > + u64 chain_key;
> > + int i;
> > +
> > +#ifdef CONFIG_PROVE_LOCKING
> > + for (i = chain->base; i < chain->base + chain->depth; i++) {
> > + if (chain_hlocks[i] != class - lock_classes)
> > + continue;
> > + if (--chain->depth > 0)
>
> {
> > + memmove(&chain_hlocks[i], &chain_hlocks[i + 1],
> > + (chain->base + chain->depth - i) *
> > + sizeof(chain_hlocks[0]));
>
> }
>
> Also, I suppose a comment here that notes we 'leak' chain_hlock[]
> entries would be appropriate here.

OK, I will add such a comment.

> If Waiman cares, it is possible to reclaim then by extending the above
> memmove() to cover the _entire_ tail of the array and then going around
> and fixing up all the chain->base 'pointers' that are in the moved part.

Since that change is outside the scope of what I want to realize I will leave
this to Waiman.

Bart.

\
 
 \ /
  Last update: 2018-12-07 17:27    [W:0.093 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site