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]
Date:	Thu, 9 Jun 2011 15:55:42 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	efault@....de, Arne Jansen <lists@...-jansens.de>
Subject: Re: [PATCH 3/3] printk: Avoid all wakeups from printk


* Peter Zijlstra <a.p.zijlstra@...llo.nl> wrote:

> +static void __console_flush(void);

I'd suggest moving this function to the right place, so that no 
prototypes are necessary.

> +/*
> + * Special 'atomic' semaphore operations that mimmick down_trylock() + up(),

mimic

> + * except they don't release the semaphore internal lock and optimize the
> + * sem->count fiddling away.
> + *
> + * The advantage is that this construct doesn't generate wakeups on atomic_up()
> + * since any contending semaphore acuiqisition will still be spinning on the

acquisition.

> + * internal lock, instead of having gotten queued on the wait_list.
> + *
> + * printk() uses this to avoid generating wakeups, which would make it unsafe
> + * to use in certain contexts (avoids lock inversion or lock recursion with
> + * the scheduler locks).
> + *
> + * Assumes IRQs are disabled.

I'd add:

    * Note: We emphatically do *not* want this function exported. Ever.

and maybe:

    * Note2: Even asking for that will likely buy you a nasty response.

> + */
> +static int atomic_down_trylock(struct semaphore *sem)
> +{
> +	spin_lock(&sem->lock);
> +	if (sem->count > 0)
> +		return 0;
> +
> +	spin_unlock(&sem->lock);
> +	return 1;
> +}
> +
> +static void atomic_up(struct semaphore *sem)
> +{
> +	spin_unlock(&sem->lock);
> +}
> +
>  asmlinkage int vprintk(const char *fmt, va_list args)
>  {
>  	int printed_len = 0;
> @@ -943,19 +939,14 @@ asmlinkage int vprintk(const char *fmt, 
>  		if (*p == '\n')
>  			new_text_line = 1;
>  	}
> +	printk_cpu = UINT_MAX;
> +	spin_unlock(&logbuf_lock);

Hm, is that printk_cpu setting inside the critical section safe? What 
happens if we get an NMI on this CPU in that window?

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