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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141002121553.GB6324@worktop.programming.kicks-ass.net>
Date:	Thu, 2 Oct 2014 14:15:53 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Mike Galbraith <umgwanakikbuti@...il.com>
Cc:	mingo@...nel.org, oleg@...hat.com, torvalds@...ux-foundation.org,
	tglx@...utronix.de, ilya.dryomov@...tank.com,
	linux-kernel@...r.kernel.org, Eric Paris <eparis@...hat.com>,
	rafael.j.wysocki@...el.com
Subject: Re: [PATCH 00/11] nested sleeps, fixes and debug infrastructure

On Thu, Oct 02, 2014 at 12:22:51PM +0200, Peter Zijlstra wrote:
> Subject: audit,wait: Fixup kauditd_thread wait loop
> 
> The kauditd_thread wait loop is a bit iffy; it has a number of problems:
> 
>  - calls try_to_freeze() before schedule(); you typically want the
>    thread to re-evaluate the sleep condition when unfreezing, also
>    freeze_task() issues a wakeup.
> 
>  - it unconditionally does the {add,remove}_wait_queue(), even when the
>    sleep condition is false.
> 
> Introduce a new wait_event() variant, wait_event_freezable() that does
> all the right things and employ it here.
> 
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Eric Paris <eparis@...hat.com>
> Reported-by: Mike Galbraith <umgwanakikbuti@...il.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
>  include/linux/wait.h |   25 +++++++++++++++++++++++++
>  kernel/audit.c       |   11 +----------
>  2 files changed, 26 insertions(+), 10 deletions(-)
> 
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -266,6 +266,31 @@ do {									\
>  	__wait_event(wq, condition);					\
>  } while (0)
>  
> +#define __wait_event_freezable(wq, condition)				\
> +	(void)___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0,	\
> +			    schedule(); try_to_freeze())
> +
> +/**
> + * wait_event - sleep until a condition gets true or freeze (for kthreads)
> + * @wq: the waitqueue to wait on
> + * @condition: a C expression for the event to wait for
> + *
> + * The process is put to sleep (TASK_INTERRUPTIBLE -- so as not to contribute
> + * to system load) until the @condition evaluates to true. The
> + * @condition is checked each time the waitqueue @wq is woken up.
> + *
> + * wake_up() has to be called after changing any variable that could
> + * change the result of the wait condition.
> + */
> +#define wait_event_freezable(wq, condition)				\
> +do {									\
> +	WARN_ON_ONCE(!(current->flags & PF_KTHREAD));			\
> +	might_sleep();							\
> +	if (condition)							\
> +		break;							\
> +	__wait_event_freezable(wq, condition);				\
> +} while (0)
> +
>  #define __wait_event_timeout(wq, condition, timeout)			\
>  	___wait_event(wq, ___wait_cond_timeout(condition),		\
>  		      TASK_UNINTERRUPTIBLE, 0, timeout,			\

Bah, that doesn't compile, because there already appears to be one,
hidden in freezer.h. Now I can't actually tell if it does the same thing
or not.

Rafael?
--
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