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: <20080311090816.GF25110@elte.hu>
Date:	Tue, 11 Mar 2008 10:08:16 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Suresh Siddha <suresh.b.siddha@...el.com>
Cc:	hpa@...or.com, tglx@...utronix.de, andi@...stfloor.org,
	hch@...radead.org, linux-kernel@...r.kernel.org,
	Arjan van de Ven <arjan@...ux.intel.com>
Subject: Re: [patch 2/2] x86, fpu: lazy allocation of FPU area - v5


* Suresh Siddha <suresh.b.siddha@...el.com> wrote:

>  asmlinkage void math_state_restore(void)
>  {
>  	struct task_struct *me = current;
> -	clts();			/* Allow maths ops (or we recurse) */
>  
> -	if (!used_math())
> -		init_fpu(me);
> +	if (!used_math()) {
> +		local_irq_enable();
> +		/*
> +		 * does a slab alloc which can sleep
> +		 */
> +		if (init_fpu(me)) {
> +			/*
> +			 * ran out of memory!
> +			 */
> +			do_group_exit(SIGKILL);
> +			return;
> +		}
> +		local_irq_disable();
> +	}
> +
> +	clts();			/* Allow maths ops (or we recurse) */
>  	restore_fpu_checking(&me->thread.xstate->fxsave);
>  	task_thread_info(me)->status |= TS_USEDFPU;
>  	me->fpu_counter++;

hm, three things:

firstly, the clts is now done _after_ fpu_init() - are you sure that's 
OK? We do it in this order so that FINIT [on older cpus] does not fault.

secondly, while i know you were responding to review feedback from 
others, but the do_group_exit(SIGKILL) looks quite bad. It's totally 
undebuggable to the user - not even a coredump will be generated AFAICS 
- and the user has no idea that this all happened due to out-of-memory. 
A (forced) SIGBUS is our usual answer to out-of-memory situations. [such 
as when a pagetable allocation fails] If you get review feedback that 
suggests a crappy solution then please resist it! :-)

thirdly, the irq enable/disable worries me. Can it ever trigger in 
kernel code that has irqs off? If it happens when kernel uses the FPU in 
irqs-off sections (to do SSE optimized routines, etc.) then enabling 
irqs is dangerous - the original callsite had it disabled for a reason. 
At minimum we should add a debug check to math_state_restore(), 
something like:

  WARN_ON_ONCE(!(regs->flags & X86_EFLAGS_IF))

(this means we need to pass regs to math_state_restore())

	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