* [PATCH] Prevent trace call into unloaded module text @ 2008-11-24 14:04 Wu Fengguang 2008-11-26 11:17 ` Avi Kivity 0 siblings, 1 reply; 5+ messages in thread From: Wu Fengguang @ 2008-11-24 14:04 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm Add marker_synchronize_unregister() before module unloading. This prevents possible trace calls into unloaded module text. Signed-off-by: Wu Fengguang <wfg@linux.intel.com> --- diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a87f45e..64f38b3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2102,5 +2102,6 @@ void kvm_exit(void) kvm_arch_exit(); kvm_exit_debug(); __free_page(bad_page); + marker_synchronize_unregister(); } EXPORT_SYMBOL_GPL(kvm_exit); ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Prevent trace call into unloaded module text 2008-11-24 14:04 [PATCH] Prevent trace call into unloaded module text Wu Fengguang @ 2008-11-26 11:17 ` Avi Kivity 2008-11-26 11:46 ` Wu Fengguang 0 siblings, 1 reply; 5+ messages in thread From: Avi Kivity @ 2008-11-26 11:17 UTC (permalink / raw) To: Wu Fengguang; +Cc: kvm Wu Fengguang wrote: > Add marker_synchronize_unregister() before module unloading. > This prevents possible trace calls into unloaded module text. > > Signed-off-by: Wu Fengguang <wfg@linux.intel.com> > --- > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index a87f45e..64f38b3 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2102,5 +2102,6 @@ void kvm_exit(void) > kvm_arch_exit(); > kvm_exit_debug(); > __free_page(bad_page); > + marker_synchronize_unregister(); > } > EXPORT_SYMBOL_GPL(kvm_exit); > What about kvm-intel.ko and kvm-amd.ko? They also contain markers. (and, why doesn't module unload do this automatically?) -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prevent trace call into unloaded module text 2008-11-26 11:17 ` Avi Kivity @ 2008-11-26 11:46 ` Wu Fengguang 2008-11-26 11:59 ` Wu Fengguang 0 siblings, 1 reply; 5+ messages in thread From: Wu Fengguang @ 2008-11-26 11:46 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm@vger.kernel.org On Wed, Nov 26, 2008 at 01:17:55PM +0200, Avi Kivity wrote: > Wu Fengguang wrote: > > Add marker_synchronize_unregister() before module unloading. > > This prevents possible trace calls into unloaded module text. > > > > Signed-off-by: Wu Fengguang <wfg@linux.intel.com> > > --- > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index a87f45e..64f38b3 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -2102,5 +2102,6 @@ void kvm_exit(void) > > kvm_arch_exit(); > > kvm_exit_debug(); > > __free_page(bad_page); > > + marker_synchronize_unregister(); > > } > > EXPORT_SYMBOL_GPL(kvm_exit); > > > > What about kvm-intel.ko and kvm-amd.ko? They also contain markers. vmx_exit and svm_exit() all calls into kvm_exit(), so they have been handled in a common way. > (and, why doesn't module unload do this automatically?) Maybe most modules don't need it for now? Thanks, Fengguang ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prevent trace call into unloaded module text 2008-11-26 11:46 ` Wu Fengguang @ 2008-11-26 11:59 ` Wu Fengguang 2008-11-27 13:32 ` Avi Kivity 0 siblings, 1 reply; 5+ messages in thread From: Wu Fengguang @ 2008-11-26 11:59 UTC (permalink / raw) To: Avi Kivity; +Cc: kvm@vger.kernel.org On Wed, Nov 26, 2008 at 07:46:19PM +0800, Wu Fengguang wrote: > On Wed, Nov 26, 2008 at 01:17:55PM +0200, Avi Kivity wrote: > > Wu Fengguang wrote: > > > Add marker_synchronize_unregister() before module unloading. > > > This prevents possible trace calls into unloaded module text. > > > > > > Signed-off-by: Wu Fengguang <wfg@linux.intel.com> > > > --- > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > > index a87f45e..64f38b3 100644 > > > --- a/virt/kvm/kvm_main.c > > > +++ b/virt/kvm/kvm_main.c > > > @@ -2102,5 +2102,6 @@ void kvm_exit(void) > > > kvm_arch_exit(); > > > kvm_exit_debug(); > > > __free_page(bad_page); > > > + marker_synchronize_unregister(); > > > } > > > EXPORT_SYMBOL_GPL(kvm_exit); > > > > > > > What about kvm-intel.ko and kvm-amd.ko? They also contain markers. > > vmx_exit and svm_exit() all calls into kvm_exit(), so they have been > handled in a common way. > > > (and, why doesn't module unload do this automatically?) > > Maybe most modules don't need it for now? OK I got a better answer: because marker_synchronize_unregister() must be called after marker_probe_unregister() calls and the tear down of any private data the trace functions rely on. So there are no automatic way. Below is the updated patch. Thanks, Fengguang --- Prevent trace call into torn down text or data Add marker_synchronize_unregister() immediately after probe unregisters. This prevents possible trace calls into unloaded module text, or the trace functions accessing invalidated data. Signed-off-by: Wu Fengguang <wfg@linux.intel.com> --- diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c index 41dcc84..f598744 100644 --- a/virt/kvm/kvm_trace.c +++ b/virt/kvm/kvm_trace.c @@ -252,6 +252,7 @@ void kvm_trace_cleanup(void) struct kvm_trace_probe *p = &kvm_trace_probes[i]; marker_probe_unregister(p->name, p->probe_func, p); } + marker_synchronize_unregister(); relay_close(kt->rchan); debugfs_remove(kt->lost_file); ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Prevent trace call into unloaded module text 2008-11-26 11:59 ` Wu Fengguang @ 2008-11-27 13:32 ` Avi Kivity 0 siblings, 0 replies; 5+ messages in thread From: Avi Kivity @ 2008-11-27 13:32 UTC (permalink / raw) To: Wu Fengguang; +Cc: kvm@vger.kernel.org Wu Fengguang wrote: > Below is the updated patch. > Applied, thanks. -- error compiling committee.c: too many arguments to function ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-27 13:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-11-24 14:04 [PATCH] Prevent trace call into unloaded module text Wu Fengguang 2008-11-26 11:17 ` Avi Kivity 2008-11-26 11:46 ` Wu Fengguang 2008-11-26 11:59 ` Wu Fengguang 2008-11-27 13:32 ` Avi Kivity
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).