@@ -2179,6 +2179,19 @@ int kprobe_add_area_blacklist(unsigned long start, unsigned long end)
2179
2179
return 0 ;
2180
2180
}
2181
2181
2182
+ /* Remove all symbols in given area from kprobe blacklist */
2183
+ static void kprobe_remove_area_blacklist (unsigned long start , unsigned long end )
2184
+ {
2185
+ struct kprobe_blacklist_entry * ent , * n ;
2186
+
2187
+ list_for_each_entry_safe (ent , n , & kprobe_blacklist , list ) {
2188
+ if (ent -> start_addr < start || ent -> start_addr >= end )
2189
+ continue ;
2190
+ list_del (& ent -> list );
2191
+ kfree (ent );
2192
+ }
2193
+ }
2194
+
2182
2195
int __init __weak arch_populate_kprobe_blacklist (void )
2183
2196
{
2184
2197
return 0 ;
@@ -2215,6 +2228,28 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
2215
2228
return ret ? : arch_populate_kprobe_blacklist ();
2216
2229
}
2217
2230
2231
+ static void add_module_kprobe_blacklist (struct module * mod )
2232
+ {
2233
+ unsigned long start , end ;
2234
+
2235
+ start = (unsigned long )mod -> kprobes_text_start ;
2236
+ if (start ) {
2237
+ end = start + mod -> kprobes_text_size ;
2238
+ kprobe_add_area_blacklist (start , end );
2239
+ }
2240
+ }
2241
+
2242
+ static void remove_module_kprobe_blacklist (struct module * mod )
2243
+ {
2244
+ unsigned long start , end ;
2245
+
2246
+ start = (unsigned long )mod -> kprobes_text_start ;
2247
+ if (start ) {
2248
+ end = start + mod -> kprobes_text_size ;
2249
+ kprobe_remove_area_blacklist (start , end );
2250
+ }
2251
+ }
2252
+
2218
2253
/* Module notifier call back, checking kprobes on the module */
2219
2254
static int kprobes_module_callback (struct notifier_block * nb ,
2220
2255
unsigned long val , void * data )
@@ -2225,6 +2260,11 @@ static int kprobes_module_callback(struct notifier_block *nb,
2225
2260
unsigned int i ;
2226
2261
int checkcore = (val == MODULE_STATE_GOING );
2227
2262
2263
+ if (val == MODULE_STATE_COMING ) {
2264
+ mutex_lock (& kprobe_mutex );
2265
+ add_module_kprobe_blacklist (mod );
2266
+ mutex_unlock (& kprobe_mutex );
2267
+ }
2228
2268
if (val != MODULE_STATE_GOING && val != MODULE_STATE_LIVE )
2229
2269
return NOTIFY_DONE ;
2230
2270
@@ -2255,6 +2295,8 @@ static int kprobes_module_callback(struct notifier_block *nb,
2255
2295
kill_kprobe (p );
2256
2296
}
2257
2297
}
2298
+ if (val == MODULE_STATE_GOING )
2299
+ remove_module_kprobe_blacklist (mod );
2258
2300
mutex_unlock (& kprobe_mutex );
2259
2301
return NOTIFY_DONE ;
2260
2302
}
0 commit comments