From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932582AbbCIOgu (ORCPT ); Mon, 9 Mar 2015 10:36:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14494 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932169AbbCIOgs (ORCPT ); Mon, 9 Mar 2015 10:36:48 -0400 Date: Mon, 9 Mar 2015 15:34:36 +0100 From: Oleg Nesterov To: Borislav Petkov Cc: Dave Hansen , Ingo Molnar , Andy Lutomirski , Linus Torvalds , Pekka Riikonen , Rik van Riel , Suresh Siddha , LKML , "Yu, Fenghua" , Quentin Casasnovas Subject: Re: [PATCH 1/1] x86/fpu: x86/fpu: avoid math_state_restore() without used_math() in __restore_xstate_sig() Message-ID: <20150309143436.GA3526@redhat.com> References: <54F74F59.5070107@intel.com> <20150305195127.GA12657@redhat.com> <20150307153824.GA25954@redhat.com> <20150307153844.GB25954@redhat.com> <20150309140712.GB12732@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150309140712.GB12732@pd.tnic> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09, Borislav Petkov wrote: > > On Sat, Mar 07, 2015 at 04:38:44PM +0100, Oleg Nesterov wrote: > > math_state_restore() assumes it is called with irqs disabled, but > > this is not true if the caller is __restore_xstate_sig(). > > > > This means that if ia32_fxstate == T and __copy_from_user() fails > > __restore_xstate_sig() returns with irqs disabled too. This trgiggers > > > > BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:41 > > [] dump_stack+0x59/0xa0 > > [] ___might_sleep+0x105/0x110 > > [] ? _raw_spin_unlock_irqrestore+0x3d/0x70 > > [] __might_sleep+0x7d/0xb0 > > [] down_read+0x26/0xa0 > > [] ? _raw_spin_unlock_irqrestore+0x5a/0x70 > > [] print_vma_addr+0x58/0x130 > > [] signal_fault+0xbe/0xf0 > > [] sys32_rt_sigreturn+0xba/0xd0 > > > > Change __restore_xstate_sig() to call set_used_math() unconditionally, > > this avoids sti/cli in math_state_restore(). If copy_from_user() fails > > we can simply do fpu_finit() by hand. > > > > Note: this is only the first step. math_state_restore() should not check > > used_math(), it should set this flag. While init_fpu() should simply die. > > > > Signed-off-by: Oleg Nesterov > > Cc: > > Makes sense to me. I guess we should wait for Dave to test first though... The patch only fixes the problem with irqs disabled, I tested this. The problem with fpu_init/XRSTORS is another thing... Oleg.