diff options
-rw-r--r-- | kernel/kprobes.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index ca4c22d78cfd..dae198b68e97 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -68,7 +68,7 @@ static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; | |||
68 | static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; | 68 | static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; |
69 | 69 | ||
70 | /* NOTE: change this value only with kprobe_mutex held */ | 70 | /* NOTE: change this value only with kprobe_mutex held */ |
71 | static bool kprobe_enabled; | 71 | static bool kprobes_all_disarmed; |
72 | 72 | ||
73 | static DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ | 73 | static DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ |
74 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; | 74 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; |
@@ -598,7 +598,7 @@ static int __kprobes register_aggr_kprobe(struct kprobe *old_p, | |||
598 | * If the old_p has gone, its breakpoint has been disarmed. | 598 | * If the old_p has gone, its breakpoint has been disarmed. |
599 | * We have to arm it again after preparing real kprobes. | 599 | * We have to arm it again after preparing real kprobes. |
600 | */ | 600 | */ |
601 | if (kprobe_enabled) | 601 | if (!kprobes_all_disarmed) |
602 | arch_arm_kprobe(ap); | 602 | arch_arm_kprobe(ap); |
603 | } | 603 | } |
604 | 604 | ||
@@ -709,7 +709,7 @@ int __kprobes register_kprobe(struct kprobe *p) | |||
709 | hlist_add_head_rcu(&p->hlist, | 709 | hlist_add_head_rcu(&p->hlist, |
710 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); | 710 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); |
711 | 711 | ||
712 | if (kprobe_enabled) | 712 | if (!kprobes_all_disarmed) |
713 | arch_arm_kprobe(p); | 713 | arch_arm_kprobe(p); |
714 | 714 | ||
715 | out_unlock_text: | 715 | out_unlock_text: |
@@ -751,7 +751,7 @@ valid_p: | |||
751 | * enabled and not gone - otherwise, the breakpoint would | 751 | * enabled and not gone - otherwise, the breakpoint would |
752 | * already have been removed. We save on flushing icache. | 752 | * already have been removed. We save on flushing icache. |
753 | */ | 753 | */ |
754 | if (kprobe_enabled && !kprobe_gone(old_p)) { | 754 | if (!kprobes_all_disarmed && !kprobe_gone(old_p)) { |
755 | mutex_lock(&text_mutex); | 755 | mutex_lock(&text_mutex); |
756 | arch_disarm_kprobe(p); | 756 | arch_disarm_kprobe(p); |
757 | mutex_unlock(&text_mutex); | 757 | mutex_unlock(&text_mutex); |
@@ -1190,8 +1190,8 @@ static int __init init_kprobes(void) | |||
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | /* By default, kprobes are enabled */ | 1193 | /* By default, kprobes are armed */ |
1194 | kprobe_enabled = true; | 1194 | kprobes_all_disarmed = false; |
1195 | 1195 | ||
1196 | err = arch_init_kprobes(); | 1196 | err = arch_init_kprobes(); |
1197 | if (!err) | 1197 | if (!err) |
@@ -1289,7 +1289,7 @@ static struct file_operations debugfs_kprobes_operations = { | |||
1289 | .release = seq_release, | 1289 | .release = seq_release, |
1290 | }; | 1290 | }; |
1291 | 1291 | ||
1292 | static void __kprobes enable_all_kprobes(void) | 1292 | static void __kprobes arm_all_kprobes(void) |
1293 | { | 1293 | { |
1294 | struct hlist_head *head; | 1294 | struct hlist_head *head; |
1295 | struct hlist_node *node; | 1295 | struct hlist_node *node; |
@@ -1298,8 +1298,8 @@ static void __kprobes enable_all_kprobes(void) | |||
1298 | 1298 | ||
1299 | mutex_lock(&kprobe_mutex); | 1299 | mutex_lock(&kprobe_mutex); |
1300 | 1300 | ||
1301 | /* If kprobes are already enabled, just return */ | 1301 | /* If kprobes are armed, just return */ |
1302 | if (kprobe_enabled) | 1302 | if (!kprobes_all_disarmed) |
1303 | goto already_enabled; | 1303 | goto already_enabled; |
1304 | 1304 | ||
1305 | mutex_lock(&text_mutex); | 1305 | mutex_lock(&text_mutex); |
@@ -1311,7 +1311,7 @@ static void __kprobes enable_all_kprobes(void) | |||
1311 | } | 1311 | } |
1312 | mutex_unlock(&text_mutex); | 1312 | mutex_unlock(&text_mutex); |
1313 | 1313 | ||
1314 | kprobe_enabled = true; | 1314 | kprobes_all_disarmed = false; |
1315 | printk(KERN_INFO "Kprobes globally enabled\n"); | 1315 | printk(KERN_INFO "Kprobes globally enabled\n"); |
1316 | 1316 | ||
1317 | already_enabled: | 1317 | already_enabled: |
@@ -1319,7 +1319,7 @@ already_enabled: | |||
1319 | return; | 1319 | return; |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | static void __kprobes disable_all_kprobes(void) | 1322 | static void __kprobes disarm_all_kprobes(void) |
1323 | { | 1323 | { |
1324 | struct hlist_head *head; | 1324 | struct hlist_head *head; |
1325 | struct hlist_node *node; | 1325 | struct hlist_node *node; |
@@ -1328,11 +1328,11 @@ static void __kprobes disable_all_kprobes(void) | |||
1328 | 1328 | ||
1329 | mutex_lock(&kprobe_mutex); | 1329 | mutex_lock(&kprobe_mutex); |
1330 | 1330 | ||
1331 | /* If kprobes are already disabled, just return */ | 1331 | /* If kprobes are already disarmed, just return */ |
1332 | if (!kprobe_enabled) | 1332 | if (kprobes_all_disarmed) |
1333 | goto already_disabled; | 1333 | goto already_disabled; |
1334 | 1334 | ||
1335 | kprobe_enabled = false; | 1335 | kprobes_all_disarmed = true; |
1336 | printk(KERN_INFO "Kprobes globally disabled\n"); | 1336 | printk(KERN_INFO "Kprobes globally disabled\n"); |
1337 | mutex_lock(&text_mutex); | 1337 | mutex_lock(&text_mutex); |
1338 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { | 1338 | for (i = 0; i < KPROBE_TABLE_SIZE; i++) { |
@@ -1364,7 +1364,7 @@ static ssize_t read_enabled_file_bool(struct file *file, | |||
1364 | { | 1364 | { |
1365 | char buf[3]; | 1365 | char buf[3]; |
1366 | 1366 | ||
1367 | if (kprobe_enabled) | 1367 | if (!kprobes_all_disarmed) |
1368 | buf[0] = '1'; | 1368 | buf[0] = '1'; |
1369 | else | 1369 | else |
1370 | buf[0] = '0'; | 1370 | buf[0] = '0'; |
@@ -1387,12 +1387,12 @@ static ssize_t write_enabled_file_bool(struct file *file, | |||
1387 | case 'y': | 1387 | case 'y': |
1388 | case 'Y': | 1388 | case 'Y': |
1389 | case '1': | 1389 | case '1': |
1390 | enable_all_kprobes(); | 1390 | arm_all_kprobes(); |
1391 | break; | 1391 | break; |
1392 | case 'n': | 1392 | case 'n': |
1393 | case 'N': | 1393 | case 'N': |
1394 | case '0': | 1394 | case '0': |
1395 | disable_all_kprobes(); | 1395 | disarm_all_kprobes(); |
1396 | break; | 1396 | break; |
1397 | } | 1397 | } |
1398 | 1398 | ||