lkml.org 
[lkml]   [2019]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v7 17/23] locking/lockdep: Verify whether lock objects are small enough to be used as class keys
    Date
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Waiman Long <longman@redhat.com>
    Cc: Johannes Berg <johannes@sipsolutions.net>
    Signed-off-by: Bart Van Assche <bvanassche@acm.org>
    ---
    kernel/locking/lockdep.c | 11 +++++++++++
    1 file changed, 11 insertions(+)

    diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
    index f5df97812dfa..93216e195b4f 100644
    --- a/kernel/locking/lockdep.c
    +++ b/kernel/locking/lockdep.c
    @@ -758,6 +758,17 @@ static bool assign_lock_key(struct lockdep_map *lock)
    {
    unsigned long can_addr, addr = (unsigned long)lock;

    +#ifdef __KERNEL__
    + /*
    + * lockdep_free_key_range() assumes that struct lock_class_key
    + * objects do not overlap. Since we use the address of lock
    + * objects as class key for static objects, check whether the
    + * size of lock_class_key objects does not exceed the size of
    + * the smallest lock object.
    + */
    + BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(raw_spinlock_t));
    +#endif
    +
    if (__is_kernel_percpu_address(addr, &can_addr))
    lock->key = (void *)can_addr;
    else if (__is_module_percpu_address(addr, &can_addr))
    --
    2.21.0.rc0.258.g878e2cd30e-goog
    \
     
     \ /
      Last update: 2019-02-15 00:03    [W:3.582 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site