[ This is old. Sorry. -dan ]
tree: git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git perf/core
head: 0627aac7ab333a3b64ef65ea0a56f2710f3c849a
commit: a252a46ef066332f600aefee50489f1bb085153a [19/27] perf, x86: track
number of events that use LBR callstack
arch/x86/kernel/cpu/perf_event_intel_lbr.c:231 intel_pmu_lbr_enable() warn:
variable dereferenced before check 'event->ctx' (see line 227)
arch/x86/kernel/cpu/perf_event_intel_lbr.c:257 intel_pmu_lbr_disable() error:
we previously assumed 'event->ctx' could be null (see line 249)
git remote add peterz-queue
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git
git remote update peterz-queue
git checkout a252a46ef066332f600aefee50489f1bb085153a
vim +231 arch/x86/kernel/cpu/perf_event_intel_lbr.c
caff2bef Peter Zijlstra 2010-03-03 221 /*
b83a46e7 Peter Zijlstra 2010-03-08 222 * Reset the LBR stack if we
changed task context to
b83a46e7 Peter Zijlstra 2010-03-08 223 * avoid data leaks.
caff2bef Peter Zijlstra 2010-03-03 224 */
b83a46e7 Peter Zijlstra 2010-03-08 225 if (event->ctx->task &&
cpuc->lbr_context != event->ctx) {
^^^^^^^^^^^^^^^^
Old dereference.
caff2bef Peter Zijlstra 2010-03-03 226 intel_pmu_lbr_reset();
caff2bef Peter Zijlstra 2010-03-03 @227 cpuc->lbr_context =
event->ctx;
caff2bef Peter Zijlstra 2010-03-03 228 }
3e702ff6 Stephane Eranian 2012-02-09 229 cpuc->br_sel =
event->hw.branch_reg.reg;
caff2bef Peter Zijlstra 2010-03-03 230
a252a46e Yan, Zheng 2014-11-04 @231 if
(branch_user_callstack(cpuc->br_sel) && event->ctx &&
^^^^^^^^^^
New check for NULL.
a252a46e Yan, Zheng 2014-11-04 232
event->ctx->task_ctx_data) {
a252a46e Yan, Zheng 2014-11-04 233 task_ctx =
event->ctx->task_ctx_data;
a252a46e Yan, Zheng 2014-11-04 234
task_ctx->lbr_callstack_users++;
a252a46e Yan, Zheng 2014-11-04 235 }
a252a46e Yan, Zheng 2014-11-04 236
caff2bef Peter Zijlstra 2010-03-03 237 cpuc->lbr_users++;
bf0fd1da Yan, Zheng 2014-11-04 238
perf_sched_cb_inc(event->ctx->pmu);
caff2bef Peter Zijlstra 2010-03-03 239 }
caff2bef Peter Zijlstra 2010-03-03 240
de0428a7 Kevin Winchester 2011-08-30 241 void intel_pmu_lbr_disable(struct
perf_event *event)
caff2bef Peter Zijlstra 2010-03-03 242 {
89cbc767 Christoph Lameter 2014-08-17 243 struct cpu_hw_events *cpuc =
this_cpu_ptr(&cpu_hw_events);
a252a46e Yan, Zheng 2014-11-04 244 struct x86_perf_task_context
*task_ctx;
caff2bef Peter Zijlstra 2010-03-03 245
caff2bef Peter Zijlstra 2010-03-03 246 if (!x86_pmu.lbr_nr)
caff2bef Peter Zijlstra 2010-03-03 247 return;
caff2bef Peter Zijlstra 2010-03-03 248
a252a46e Yan, Zheng 2014-11-04 @249 if
(branch_user_callstack(cpuc->br_sel) && event->ctx &&
^^^^^^^^^^
Check.
a252a46e Yan, Zheng 2014-11-04 250
event->ctx->task_ctx_data) {
a252a46e Yan, Zheng 2014-11-04 251 task_ctx =
event->ctx->task_ctx_data;
a252a46e Yan, Zheng 2014-11-04 252
task_ctx->lbr_callstack_users--;
a252a46e Yan, Zheng 2014-11-04 253 }
a252a46e Yan, Zheng 2014-11-04 254
caff2bef Peter Zijlstra 2010-03-03 255 cpuc->lbr_users--;
b83a46e7 Peter Zijlstra 2010-03-08 256 WARN_ON_ONCE(cpuc->lbr_users <
0);
bf0fd1da Yan, Zheng 2014-11-04 @257
perf_sched_cb_dec(event->ctx->pmu);
^^^^^^^^^^^^^^^
Unchecked dereference.
2df202bf Peter Zijlstra 2010-03-06 258
60ce0fbd Stephane Eranian 2012-02-09 259 if (cpuc->enabled &&
!cpuc->lbr_users) {
2df202bf Peter Zijlstra 2010-03-06 260
__intel_pmu_lbr_disable();
---
0-DAY kernel test infrastructure Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
_______________________________________________
kbuild mailing list
[email protected]
https://lists.01.org/mailman/listinfo/kbuild
_______________________________________________
kbuild mailing list
[email protected]
https://lists.01.org/mailman/listinfo/kbuild