Skip to content

Commit 615d0eb

Browse files
Masami HiramatsuIngo Molnar
authored andcommitted
kprobes: Disable booster when CONFIG_PREEMPT=y
Disable kprobe booster when CONFIG_PREEMPT=y at this time, because it can't ensure that all kernel threads preempted on kprobe's boosted slot run out from the slot even using freeze_processes(). The booster on preemptive kernel will be resumed if synchronize_tasks() or something like that is introduced. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Mathieu Desnoyers <compudj@krystal.dyndns.org> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <20100202214904.4694.24330.stgit@dhcp-100-2-132.bos.redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 57d8188 commit 615d0eb

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

arch/ia64/kernel/kprobes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static int __kprobes pre_kprobes_handler(struct die_args *args)
870870
return 1;
871871

872872
ss_probe:
873-
#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
873+
#if !defined(CONFIG_PREEMPT)
874874
if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
875875
/* Boost up -- we can execute copied instructions directly */
876876
ia64_psr(regs)->ri = p->ainsn.slot;

arch/x86/kernel/kprobes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
429429
static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
430430
struct kprobe_ctlblk *kcb)
431431
{
432-
#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER)
432+
#if !defined(CONFIG_PREEMPT)
433433
if (p->ainsn.boostable == 1 && !p->post_handler) {
434434
/* Boost up -- we can execute copied instructions directly */
435435
reset_current_kprobe();

kernel/kprobes.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ static LIST_HEAD(kprobe_insn_pages);
124124
static int kprobe_garbage_slots;
125125
static int collect_garbage_slots(void);
126126

127-
static int __kprobes check_safety(void)
128-
{
129-
int ret = 0;
130-
#if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER)
131-
ret = freeze_processes();
132-
if (ret == 0) {
133-
struct task_struct *p, *q;
134-
do_each_thread(p, q) {
135-
if (p != current && p->state == TASK_RUNNING &&
136-
p->pid != 0) {
137-
printk("Check failed: %s is running\n",p->comm);
138-
ret = -1;
139-
goto loop_end;
140-
}
141-
} while_each_thread(p, q);
142-
}
143-
loop_end:
144-
thaw_processes();
145-
#else
146-
synchronize_sched();
147-
#endif
148-
return ret;
149-
}
150-
151127
/**
152128
* __get_insn_slot() - Find a slot on an executable page for an instruction.
153129
* We allocate an executable page if there's no room on existing ones.
@@ -235,9 +211,8 @@ static int __kprobes collect_garbage_slots(void)
235211
{
236212
struct kprobe_insn_page *kip, *next;
237213

238-
/* Ensure no-one is preepmted on the garbages */
239-
if (check_safety())
240-
return -EAGAIN;
214+
/* Ensure no-one is interrupted on the garbages */
215+
synchronize_sched();
241216

242217
list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) {
243218
int i;

0 commit comments

Comments
 (0)