Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
perf: Validate cpu early in perf_event_alloc()
perf: Find_get_context: fix the per-cpu-counter check
perf: Fix contexted inheritance

+12 -11
+12 -11
kernel/perf_event.c
··· 2228 2228 unsigned long flags; 2229 2229 int ctxn, err; 2230 2230 2231 - if (!task && cpu != -1) { 2231 + if (!task) { 2232 2232 /* Must be root to operate on a CPU event: */ 2233 2233 if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN)) 2234 2234 return ERR_PTR(-EACCES); 2235 - 2236 - if (cpu < 0 || cpu >= nr_cpumask_bits) 2237 - return ERR_PTR(-EINVAL); 2238 2235 2239 2236 /* 2240 2237 * We could be clever and allow to attach a event to an ··· 5538 5541 struct hw_perf_event *hwc; 5539 5542 long err; 5540 5543 5544 + if ((unsigned)cpu >= nr_cpu_ids) { 5545 + if (!task || cpu != -1) 5546 + return ERR_PTR(-EINVAL); 5547 + } 5548 + 5541 5549 event = kzalloc(sizeof(*event), GFP_KERNEL); 5542 5550 if (!event) 5543 5551 return ERR_PTR(-ENOMEM); ··· 5591 5589 5592 5590 if (!overflow_handler && parent_event) 5593 5591 overflow_handler = parent_event->overflow_handler; 5594 - 5592 + 5595 5593 event->overflow_handler = overflow_handler; 5596 5594 5597 5595 if (attr->disabled) ··· 6496 6494 6497 6495 raw_spin_lock_irqsave(&parent_ctx->lock, flags); 6498 6496 parent_ctx->rotate_disable = 0; 6499 - raw_spin_unlock_irqrestore(&parent_ctx->lock, flags); 6500 6497 6501 6498 child_ctx = child->perf_event_ctxp[ctxn]; 6502 6499 ··· 6503 6502 /* 6504 6503 * Mark the child context as a clone of the parent 6505 6504 * context, or of whatever the parent is a clone of. 6506 - * Note that if the parent is a clone, it could get 6507 - * uncloned at any point, but that doesn't matter 6508 - * because the list of events and the generation 6509 - * count can't have changed since we took the mutex. 6505 + * 6506 + * Note that if the parent is a clone, the holding of 6507 + * parent_ctx->lock avoids it from being uncloned. 6510 6508 */ 6511 - cloned_ctx = rcu_dereference(parent_ctx->parent_ctx); 6509 + cloned_ctx = parent_ctx->parent_ctx; 6512 6510 if (cloned_ctx) { 6513 6511 child_ctx->parent_ctx = cloned_ctx; 6514 6512 child_ctx->parent_gen = parent_ctx->parent_gen; ··· 6518 6518 get_ctx(child_ctx->parent_ctx); 6519 6519 } 6520 6520 6521 + raw_spin_unlock_irqrestore(&parent_ctx->lock, flags); 6521 6522 mutex_unlock(&parent_ctx->mutex); 6522 6523 6523 6524 perf_unpin_context(parent_ctx);