From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] kvm: Prevent kvm_init from corrupting debugfs structures Date: Thu, 15 Oct 2009 13:04:23 -0300 Message-ID: <20091015160423.GC9629@amt.cnet> References: <20091014232100.GE26149@tux1.beaverton.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , linux-kernel , kvm@vger.kernel.org To: "Darrick J. Wong" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:8900 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762884AbZJOQYW (ORCPT ); Thu, 15 Oct 2009 12:24:22 -0400 Content-Disposition: inline In-Reply-To: <20091014232100.GE26149@tux1.beaverton.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Oct 14, 2009 at 04:21:00PM -0700, Darrick J. Wong wrote: > I'm seeing an oops condition when kvm-intel and kvm-amd are modprobe'd > during boot (say on an Intel system) and then rmmod'd: > > # modprobe kvm-intel > kvm_init() > kvm_init_debug() > kvm_arch_init() <-- stores debugfs dentries internally > (success, etc) > > # modprobe kvm-amd > kvm_init() > kvm_init_debug() <-- second initialization clobbers kvm's > internal pointers to dentries > kvm_arch_init() > kvm_exit_debug() <-- and frees them > > # rmmod kvm-intel > kvm_exit() > kvm_exit_debug() <-- double free of debugfs files! > > *BOOM* > > If execution gets to the end of kvm_init(), then the calling module has been > established as the kvm provider. Move the debugfs initialization to the end of > the function, and remove the now-unnecessary call to kvm_exit_debug() from the > error path. That way we avoid trampling on the debugfs entries and freeing > them twice. > > Signed-off-by: Darrick J. Wong Applied, thanks.