Skip to content

Commit

Permalink
kprobes: Sanitize struct kretprobe_instance allocations
Browse files Browse the repository at this point in the history
For as long as kretprobes have existed, we've allocated NR_CPUS
instances of kretprobe_instance structures. With the default
value of CONFIG_NR_CPUS increasing on certain architectures, we
are potentially wasting kernel memory.

See http://sourceware.org/bugzilla/show_bug.cgi?id=10839#c3 for
more details.

Use a saner num_possible_cpus() instead of NR_CPUS for
allocation.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: fweisbec@gmail.com
LKML-Reference: <20091030135310.GA22230@in.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ananth N Mavinakayanahalli authored and Ingo Molnar committed Nov 2, 2009
1 parent 5e9b397 commit 4dae560
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,9 @@ int __kprobes register_kretprobe(struct kretprobe *rp)
/* Pre-allocate memory for max kretprobe instances */
if (rp->maxactive <= 0) {
#ifdef CONFIG_PREEMPT
rp->maxactive = max(10, 2 * NR_CPUS);
rp->maxactive = max(10, 2 * num_possible_cpus());
#else
rp->maxactive = NR_CPUS;
rp->maxactive = num_possible_cpus();
#endif
}
spin_lock_init(&rp->lock);
Expand Down

0 comments on commit 4dae560

Please sign in to comment.