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: <20090126230721.GA6556@elte.hu>
Date:	Tue, 27 Jan 2009 00:07:21 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Johannes Berg <johannes@...solutions.net>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Linux Kernel list <linux-kernel@...r.kernel.org>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] timer: implement lockdep deadlock detection


* Johannes Berg <johannes@...solutions.net> wrote:

> This modifies the timer code in a way to allow lockdep to detect 
> deadlocks resulting from a lock being taken in the timer function as 
> well as around the del_timer_sync() call.
> 
> Validated with this module, otherwise bootup was clean.

That's a really neat trick ...

Curious: have you hit such a bug recently that motivated you to implement 
it?

> +#ifdef CONFIG_LOCKDEP
> +#define init_timer(timer)						\
> +	do {								\
> +		static struct lock_class_key __key;			\
> +		init_timer_key((timer), #timer, &__key);		\
> +	} while (0)
> +#define init_timer_deferrable(timer)					\
> +	do {								\

(Style detail: please put a newline after each macro block to make them 
stand apart a bit more.)

>  int del_timer_sync(struct timer_list *timer)
>  {
> +#ifdef CONFIG_LOCKDEP
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	lock_map_acquire(&timer->lockdep_map);
> +	lock_map_release(&timer->lockdep_map);
> +	local_irq_restore(flags);
> +#endif

yummie. We have repeat bugs in this area that are rather tricky to find. 
This will trigger them in a debuggable way.

> @@ -861,10 +881,21 @@ static inline void __run_timers(struct t
>  
>  			set_running_timer(base, timer);
>  			detach_timer(timer, 1);
> +
>  			spin_unlock_irq(&base->lock);

Yes, the newline is needed there :-) [seriously]

>  				int preempt_count = preempt_count();
> +
> +				/* Couple the lock chain with the lock chain at
> +				 * del_timer_sync by acquiring the lock_map around
> +				 * the fn() call here and in del_timer_sync.
> +				 */

Please use the standard multi-line comment style:

  /*
   * Comment .....
   * ...... goes here:
   */

Looks good otherwise,

Thanks,

	Ingo
--
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