Bug 2506

Summary: Probes on "__exit" functions should not be allowed
Product: systemtap Reporter: Josh Stone <jistone>
Component: translatorAssignee: Josh Stone <jistone>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Josh Stone 2006-04-03 22:50:27 UTC
The translator should not allow probes within "__exit" functions that are linked
into vmlinux.

See this thread:
http://sources.redhat.com/ml/systemtap/2006-q2/msg00000.html
Comment 1 Josh Stone 2006-04-03 23:15:28 UTC
Functions with the "__kprobes" decorator should also not be allowed, whether in
vmlinux or in a module.
Comment 2 bibo,mao 2006-04-10 06:34:47 UTC
Sometime probe in function with __init prefix should be disabled in kprobe 
kernel part. And there should be different return value when failing in 
register_kprobe, sometimes systemtap can continue to register other probepoints 
by return value from register_kprobe even if it fails to register current 
kprobe.
Comment 3 Josh Stone 2006-05-04 00:03:46 UTC
Added patch to block __exit probes in tapsets.cxx r1.125

I don't know how to detect __kprobes sections at compile time, so I will open
another bug on this aspect.
Comment 4 Frank Ch. Eigler 2006-05-30 00:24:44 UTC
Please confirm that ".exit." alone is sufficient, that "has_kernel" is not also
required.  Module-level .exit. functions should probably be probable.
Comment 5 Josh Stone 2006-05-30 19:35:41 UTC
(In reply to comment #4)
> Please confirm that ".exit." alone is sufficient, that "has_kernel" is not also
> required.  Module-level .exit. functions should probably be probable.

The phrase "should probably be probable" is quite confusing -- perhaps you mean
"probeable"?  ;)

Care should be taken with has_kernel, as that only indicates that the probepoint
is kernel.xxx.  A probe on module("kernel").xxx is an equivalent alias.

I tried a probe on a module __exit function, and while the probe was placed
successfully, it was quite worthless.  Kprobes increases the usage count of
probed modules, so they are effectively pinned in place and cannot be rmmod'ed.
 I suppose that CONFIG_MODULE_FORCE_UNLOAD could be used to get around this, but
this is dangerous and would probably break kprobes.  Thus, I don't see any point
to allowing probes on module __exit functions.