Skip to content

Commit 310aa0a

Browse files
PeikanTsaiIngo Molnar
authored andcommitted
perf/hw_breakpoint: Fix arch_hw_breakpoint use-before-initialization
If we disable the compiler's auto-initialization feature, if -fplugin-arg-structleak_plugin-byref or -ftrivial-auto-var-init=pattern are disabled, arch_hw_breakpoint may be used before initialization after: 9a4903d ("perf/hw_breakpoint: Split attribute parse and commit") On our ARM platform, the struct step_ctrl in arch_hw_breakpoint, which used to be zero-initialized by kzalloc(), may be used in arch_install_hw_breakpoint() without initialization. Signed-off-by: Mark-PK Tsai <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alix Wu <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: YJ Chiang <[email protected]> Link: https://lkml.kernel.org/r/[email protected] [ Minor edits. ] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 0f4cd76 commit 310aa0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/events/hw_breakpoint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static int hw_breakpoint_parse(struct perf_event *bp,
413413

414414
int register_perf_hw_breakpoint(struct perf_event *bp)
415415
{
416-
struct arch_hw_breakpoint hw;
416+
struct arch_hw_breakpoint hw = { };
417417
int err;
418418

419419
err = reserve_bp_slot(bp);
@@ -461,7 +461,7 @@ int
461461
modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
462462
bool check)
463463
{
464-
struct arch_hw_breakpoint hw;
464+
struct arch_hw_breakpoint hw = { };
465465
int err;
466466

467467
err = hw_breakpoint_parse(bp, attr, &hw);

0 commit comments

Comments
 (0)