lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimYx2Og1BG37wb0WZ0_U8WJjLKHMKgU45qycUaM@mail.gmail.com>
Date:	Mon, 20 Dec 2010 15:07:09 +0800
From:	Yong Zhang <yong.zhang0@...il.com>
To:	Andy Walls <awalls@...metrocast.net>
Cc:	linux-kernel@...r.kernel.org, nicolas.mailhot@...oste.net,
	Tejun Heo <tj@...nel.org>, Jarod Wilson <jarod@...hat.com>,
	Ingo Molnar <mingo@...hat.com>,
	Mauro Carvalho Chehab <mchehab@...hat.com>,
	Hans Verkuil <hverkuil@...all.nl>
Subject: Re: [PATCH] kthread_worker: Initialize dynamically allocated spinlock
 properly for lockdep

On Sun, Dec 19, 2010 at 8:49 PM, Andy Walls <awalls@...metrocast.net> wrote:
> init_kthread_worker(), via KTHREAD_WORKER_INIT(), used an
> initializer for static spin_lock objects, SPIN_LOCK_UNLOCKED, on
> a dynamically allocated kthread_worker object's internal spinlock_t.
> This causes lockdep to gripe:
>
>        INFO: trying to register non-static key.
>        the code is fine but needs lockdep annotation.
>        turning off the locking correctness validator.
>
> To keep lockdep happy, use spin_lock_init() for dynamically
> allocated kthread_worker objects' internal spinlock_t.
>
> Reported-by: Nicolas <nicolas.mailhot@...oste.net>
> Signed-off-by: Andy Walls <awalls@...metrocast.net>
>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: Jarod Wilson <jarod@...hat.com>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Mauro Carvalho Chehab <mchehab@...hat.com>
> Cc: Hans Verkuil <hverkuil@...all.nl>
>
> diff --git a/include/linux/kthread.h b/include/linux/kthread.h
> index 685ea65..e65d0b1 100644
> --- a/include/linux/kthread.h
> +++ b/include/linux/kthread.h
> @@ -83,7 +83,13 @@ struct kthread_work {
>
>  static inline void init_kthread_worker(struct kthread_worker *worker)
>  {
> -       *worker = (struct kthread_worker)KTHREAD_WORKER_INIT(*worker);
> +       /*
> +        * Lockdep complains if a dynamically allocated worker's spinlock_t
> +        * is initialzed using SPIN_LOCK_UNLOCKED.
> +        */
> +       spin_lock_init(&worker->lock);

This will make different kthead_worker->lock initialized with one same
key. You know spin_lock_init() will be like below:
# define raw_spin_lock_init(lock)				\
do {								\
	static struct lock_class_key __key;			\
								\
	__raw_spin_lock_init((lock), #lock, &__key);		\
} while (0)

So we should put the real initializer to kernel/kthread.c
and make init_kthread_worker() to be a MACRO.

BTW, init_kthread_work() should also be changed like above
because member done is a wait_queue_head.

Thanks,
Yong

-- 
Only stand for myself.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ