public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* arch/powerpc/kernel/hw_breakpoint.c:715 hw_breakpoint_handler() error: uninitialized symbol 'ea'.
@ 2021-05-03 10:12 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-05-03 10:12 UTC (permalink / raw)
  To: kbuild, Ravi Bangoria; +Cc: lkp, kbuild-all, linux-kernel, Michael Ellerman

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9f67672a817ec046f7554a885f0fe0d60e1bf99f
commit: f6780ce619f8daa285760302d56e95892087bd1f powerpc/watchpoint: Fix DAWR exception constraint
config: powerpc-randconfig-m031-20210501 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
arch/powerpc/kernel/hw_breakpoint.c:715 hw_breakpoint_handler() error: uninitialized symbol 'ea'.

vim +/ea +715 arch/powerpc/kernel/hw_breakpoint.c

03465f899bdac7 Nicholas Piggin  2016-09-16  677  int hw_breakpoint_handler(struct die_args *args)
5aae8a53708025 K.Prasad         2010-06-15  678  {
74c6881019b7d5 Ravi Bangoria    2020-05-14  679  	bool err = false;
5aae8a53708025 K.Prasad         2010-06-15  680  	int rc = NOTIFY_STOP;
74c6881019b7d5 Ravi Bangoria    2020-05-14  681  	struct perf_event *bp[HBP_NUM_MAX] = { NULL };
5aae8a53708025 K.Prasad         2010-06-15  682  	struct pt_regs *regs = args->regs;
74c6881019b7d5 Ravi Bangoria    2020-05-14  683  	struct arch_hw_breakpoint *info[HBP_NUM_MAX] = { NULL };
74c6881019b7d5 Ravi Bangoria    2020-05-14  684  	int i;
74c6881019b7d5 Ravi Bangoria    2020-05-14  685  	int hit[HBP_NUM_MAX] = {0};
74c6881019b7d5 Ravi Bangoria    2020-05-14  686  	int nr_hit = 0;
74c6881019b7d5 Ravi Bangoria    2020-05-14  687  	bool ptrace_bp = false;
74c6881019b7d5 Ravi Bangoria    2020-05-14  688  	struct ppc_inst instr = ppc_inst(0);
74c6881019b7d5 Ravi Bangoria    2020-05-14  689  	int type = 0;
74c6881019b7d5 Ravi Bangoria    2020-05-14  690  	int size = 0;
f6780ce619f8da Ravi Bangoria    2020-07-23  691  	unsigned long ea;
5aae8a53708025 K.Prasad         2010-06-15  692  
5aae8a53708025 K.Prasad         2010-06-15  693  	/* Disable breakpoints during exception handling */
9422de3e953d0e Michael Neuling  2012-12-20  694  	hw_breakpoint_disable();
574cb24899d35e Paul Mackerras   2010-06-23  695  
5aae8a53708025 K.Prasad         2010-06-15  696  	/*
5aae8a53708025 K.Prasad         2010-06-15  697  	 * The counter may be concurrently released but that can only
5aae8a53708025 K.Prasad         2010-06-15  698  	 * occur from a call_rcu() path. We can then safely fetch
5aae8a53708025 K.Prasad         2010-06-15  699  	 * the breakpoint, use its callback, touch its counter
5aae8a53708025 K.Prasad         2010-06-15  700  	 * while we are in an rcu_read_lock() path.
5aae8a53708025 K.Prasad         2010-06-15  701  	 */
5aae8a53708025 K.Prasad         2010-06-15  702  	rcu_read_lock();
5aae8a53708025 K.Prasad         2010-06-15  703  
74c6881019b7d5 Ravi Bangoria    2020-05-14  704  	if (!IS_ENABLED(CONFIG_PPC_8xx))
f6780ce619f8da Ravi Bangoria    2020-07-23  705  		get_instr_detail(regs, &instr, &type, &size, &ea);

No else path.

74c6881019b7d5 Ravi Bangoria    2020-05-14  706  
74c6881019b7d5 Ravi Bangoria    2020-05-14  707  	for (i = 0; i < nr_wp_slots(); i++) {
74c6881019b7d5 Ravi Bangoria    2020-05-14  708  		bp[i] = __this_cpu_read(bp_per_reg[i]);
74c6881019b7d5 Ravi Bangoria    2020-05-14  709  		if (!bp[i])
74c6881019b7d5 Ravi Bangoria    2020-05-14  710  			continue;
74c6881019b7d5 Ravi Bangoria    2020-05-14  711  
74c6881019b7d5 Ravi Bangoria    2020-05-14  712  		info[i] = counter_arch_bp(bp[i]);
74c6881019b7d5 Ravi Bangoria    2020-05-14  713  		info[i]->type &= ~HW_BRK_TYPE_EXTRANEOUS_IRQ;
74c6881019b7d5 Ravi Bangoria    2020-05-14  714  
f6780ce619f8da Ravi Bangoria    2020-07-23 @715  		if (check_constraints(regs, instr, ea, type, size, info[i])) {
                                                                                                   ^^
Passing uninitialized data to a function will trigger a KUBSan warning
at runtime regardless of whether or not the parameter is used.  (Unless
the compiler inlines the function then it would be fine).

74c6881019b7d5 Ravi Bangoria    2020-05-14  716  			if (!IS_ENABLED(CONFIG_PPC_8xx) &&
74c6881019b7d5 Ravi Bangoria    2020-05-14  717  			    ppc_inst_equal(instr, ppc_inst(0))) {
74c6881019b7d5 Ravi Bangoria    2020-05-14  718  				handler_error(bp[i], info[i]);
74c6881019b7d5 Ravi Bangoria    2020-05-14  719  				info[i] = NULL;
74c6881019b7d5 Ravi Bangoria    2020-05-14  720  				err = 1;
74c6881019b7d5 Ravi Bangoria    2020-05-14  721  				continue;
74c6881019b7d5 Ravi Bangoria    2020-05-14  722  			}
74c6881019b7d5 Ravi Bangoria    2020-05-14  723  
74c6881019b7d5 Ravi Bangoria    2020-05-14  724  			if (is_ptrace_bp(bp[i]))

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-03 10:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-03 10:12 arch/powerpc/kernel/hw_breakpoint.c:715 hw_breakpoint_handler() error: uninitialized symbol 'ea' Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox