From: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, h.mitake@gmail.com,
Dmitry Torokhov <dtor@mail.ru>, Vojtech Pavlik <vojtech@ucw.cz>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 1/2] lockdep: check the depth of subclass
Date: Wed, 13 Oct 2010 17:13:55 +0900 [thread overview]
Message-ID: <4CB56A43.9040706@dcl.info.waseda.ac.jp> (raw)
In-Reply-To: <1286955233.29097.68.camel@twins>
On 10/13/10 16:33, Peter Zijlstra wrote:
> On Wed, 2010-10-13 at 11:26 +0900, Hitoshi Mitake wrote:
>> >> @@ -639,6 +639,21 @@ look_up_lock_class(struct lockdep_map
*lock, unsigned int subclass)
>> >> }
>> >> #endif
>> >>
>> >> + if (unlikely(subclass>= MAX_LOCKDEP_SUBCLASSES)) {
>> >> + /*
>> >> + * This check should be done not only in
__lock_acquire()
>> >> + * but also here. Because register_lock_class() is
also called
>> >> + * by lock_set_class(). Callers of
lock_set_class() can
>> >> + * pass invalid value as subclass.
>> >> + */
>> >> +
>> >> + debug_locks_off();
>> >> + printk(KERN_ERR "BUG: looking up invalid subclass:
%u\n", subclass);
>> >> + printk(KERN_ERR "turning off the locking
correctness validator.\n");
>> >> + dump_stack();
>> >> + return NULL;
>> >> + }
>> >
>> > Would we catch all cases if we moved this check from
__lock_acquire()
>> > into register_lock_class()? It would result in only a single
instance of
>> > this logic.
>> >
>>
>> I think that __lock_acquire() should also check the value of subclass.
>> Because it access to the lock->class_cache as array
>> before calling look_up_lock_class() after applying this patch.
>>
>> So if the check isn't done in __lock_acquire(),
>> the invalid addresses might be interpreted as the addresses of
>> struct lock_class.
>
>
> But __lock_acquire() does:
>
> if (subclass< NR_LOCKDEP_CACHING_CLASSES)
> class = lock->class_cache[subclass];
>
> if (!class)
> class = register_lock_class();
>
> So by moving the: subclass>= MAX_LOCKDEP_SUBCLASSES, check into
> register_lock_class() it would still trigger for __lock_acquire().
> Because NR_LOCKDEP_CACHING_CLASSES<= MAX_LOCKDEP_SUBCLASSES, and thus
> for subclass>= MAX_LOCKDEP_SUBCLASSES we'll always call into
> register_lock_class() and trigger the failure there, no?
>
>
>
Ahh, sorry, you are right.
So current checking subclass >= MAX_LOCKDEP_SUBCLASSES is redundant,
I'll remove this checking and resend second version later.
Thanks for your advice!
next prev parent reply other threads:[~2010-10-13 8:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 9:01 Hitoshi Mitake
2010-10-05 9:01 ` [RFC PATCH 2/2] lockdep: caching subclasses Hitoshi Mitake
2010-10-12 10:36 ` Peter Zijlstra
2010-10-18 19:17 ` [tip:core/locking] lockdep: Add improved subclass caching tip-bot for Hitoshi Mitake
2010-10-12 10:27 ` [PATCH 1/2] lockdep: check the depth of subclass Peter Zijlstra
2010-10-12 16:03 ` Dmitry Torokhov
2010-10-13 2:27 ` Hitoshi Mitake
2010-10-13 18:18 ` Dmitry Torokhov
2010-10-13 2:26 ` Hitoshi Mitake
2010-10-13 7:33 ` Peter Zijlstra
2010-10-13 8:13 ` Hitoshi Mitake [this message]
2010-10-13 8:30 ` [PATCH v2] " Hitoshi Mitake
2010-10-13 8:48 ` Peter Zijlstra
2010-10-18 19:17 ` [tip:core/locking] lockdep: Check " tip-bot for Hitoshi Mitake
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=4CB56A43.9040706@dcl.info.waseda.ac.jp \
--to=mitake@dcl.info.waseda.ac.jp \
--cc=dtor@mail.ru \
--cc=fweisbec@gmail.com \
--cc=h.mitake@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vojtech@ucw.cz \
/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®