lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202208171036.B3obcm1M-lkp@intel.com>
Date:   Wed, 17 Aug 2022 10:19:10 +0800
From:   kernel test robot <lkp@...el.com>
To:     Chen Zhongjin <chenzhongjin@...wei.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-arch@...r.kernel.org
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        linux@...linux.org.uk, arnd@...db.de, linus.walleij@...aro.org,
        ardb@...nel.org, rmk+kernel@...linux.org.uk, rostedt@...dmis.org,
        nick.hawkins@....com, john@...ozen.org, mhiramat@...nel.org,
        chenzhongjin@...wei.com
Subject: Re: [PATCH] x86/unwind/orc: Add 'unwind_debug' cmdline option

Hi Chen,

I love your patch! Perhaps something to improve:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on clk/clk-next linus/master v6.0-rc1 next-20220816]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chen-Zhongjin/x86-unwind-orc-Add-unwind_debug-cmdline-option/20220815-190328
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git a1a5482a2c6e38a3ebed32e571625c56a8cc41a6
config: x86_64-randconfig-a012-20220815
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 6afcc4a459ead8809a0d6d9b4bf7b64bcc13582b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/3295e738f5b51f1f1f223bf52a8ecee2ab93fbca
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Chen-Zhongjin/x86-unwind-orc-Add-unwind_debug-cmdline-option/20220815-190328
        git checkout 3295e738f5b51f1f1f223bf52a8ecee2ab93fbca
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/kernel/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

   arch/x86/kernel/unwind_orc.c:17:2: error: expected identifier or '('
           if (state->task == current && !state->error)                    \
           ^
   arch/x86/kernel/unwind_orc.c:19:3: error: expected identifier or '('
                   if (unwind_debug && !dumped_before)                     \
                   ^
   arch/x86/kernel/unwind_orc.c:21:3: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
                   dumped_before = true;                                   \
                   ^
                   int
   arch/x86/kernel/unwind_orc.c:22:2: error: extraneous closing brace ('}')
           }                                                               \
           ^
   arch/x86/kernel/unwind_orc.c:22:11: error: extraneous closing brace ('}')
           }                                                               \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:23:2: error: expected identifier or '('
   })
    ^
   arch/x86/kernel/unwind_orc.c:219:21: error: use of undeclared identifier '__start_orc_unwind_ip'
                   return __orc_find(__start_orc_unwind_ip + start,
                                     ^
   arch/x86/kernel/unwind_orc.c:225:21: error: use of undeclared identifier '__start_orc_unwind_ip'
                   return __orc_find(__start_orc_unwind_ip, __start_orc_unwind,
                                     ^
   arch/x86/kernel/unwind_orc.c:226:30: error: use of undeclared identifier '__start_orc_unwind_ip'
                                     __stop_orc_unwind_ip - __start_orc_unwind_ip, ip);
                                                            ^
   arch/x86/kernel/unwind_orc.c:239:32: error: use of undeclared identifier '__start_orc_unwind_ip'
   static int *cur_orc_ip_table = __start_orc_unwind_ip;
                                  ^
   arch/x86/kernel/unwind_orc.c:314:62: error: use of undeclared identifier '__start_orc_unwind_ip'
           size_t orc_ip_size = (void *)__stop_orc_unwind_ip - (void *)__start_orc_unwind_ip;
                                                                       ^
   arch/x86/kernel/unwind_orc.c:336:20: error: use of undeclared identifier '__start_orc_unwind_ip'
                   orc = __orc_find(__start_orc_unwind_ip, __start_orc_unwind,
                                    ^
   arch/x86/kernel/unwind_orc.c:348:19: error: use of undeclared identifier '__start_orc_unwind_ip'
           orc = __orc_find(__start_orc_unwind_ip, __start_orc_unwind, num_entries,
                            ^
>> arch/x86/kernel/unwind_orc.c:531:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("missing R10 value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:535:3: error: expected ')'
                   break;
                   ^
   arch/x86/kernel/unwind_orc.c:531:4: note: to match this '('
                           orc_warn_current("missing R10 value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:539:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("missing R13 value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:543:3: error: expected ')'
                   break;
                   ^
   arch/x86/kernel/unwind_orc.c:539:4: note: to match this '('
                           orc_warn_current("missing R13 value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:547:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("missing RDI value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:551:3: error: expected ')'
                   break;
                   ^
   arch/x86/kernel/unwind_orc.c:547:4: note: to match this '('
                           orc_warn_current("missing RDI value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:555:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("missing DX value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:559:3: error: expected ')'
                   break;
                   ^
   arch/x86/kernel/unwind_orc.c:555:4: note: to match this '('
                           orc_warn_current("missing DX value at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:593:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("can't access registers at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:607:3: error: expected ')'
                   state->ip = unwind_recover_rethook(state, state->ip,
                   ^
   arch/x86/kernel/unwind_orc.c:593:4: note: to match this '('
                           orc_warn_current("can't access registers at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:617:4: warning: unused variable 'dumped_before' [-Wunused-variable]
                           orc_warn_current("can't access iret registers at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   arch/x86/kernel/unwind_orc.c:622:3: error: expected ')'
                   state->ip = unwind_recover_rethook(state, state->ip,
                   ^
   arch/x86/kernel/unwind_orc.c:617:4: note: to match this '('
                           orc_warn_current("can't access iret registers at %pB\n",
                           ^
   arch/x86/kernel/unwind_orc.c:14:39: note: expanded from macro 'orc_warn_current'
   #define orc_warn_current(args...)                                       \
                                                                           ^
   arch/x86/kernel/unwind_orc.c:665:3: warning: unused variable 'dumped_before' [-Wunused-variable]
                   orc_warn_current("stack going in the wrong direction? at %pB\n",
                   ^
   arch/x86/kernel/unwind_orc.c:16:14: note: expanded from macro 'orc_warn_current'
           static bool dumped_before;
                       ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   7 warnings and 20 errors generated.


vim +/dumped_before +531 arch/x86/kernel/unwind_orc.c

81b67439d14767 Josh Poimboeuf   2020-04-25  462  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  463  bool unwind_next_frame(struct unwind_state *state)
ee9f8fce996408 Josh Poimboeuf   2017-07-24  464  {
81b67439d14767 Josh Poimboeuf   2020-04-25  465  	unsigned long ip_p, sp, tmp, orig_ip = state->ip, prev_sp = state->sp;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  466  	enum stack_type prev_type = state->stack_info.type;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  467  	struct orc_entry *orc;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  468  	bool indirect = false;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  469  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  470  	if (unwind_done(state))
ee9f8fce996408 Josh Poimboeuf   2017-07-24  471  		return false;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  472  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  473  	/* Don't let modules unload while we're reading their ORC data. */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  474  	preempt_disable();
ee9f8fce996408 Josh Poimboeuf   2017-07-24  475  
d31a580266eeb1 Josh Poimboeuf   2018-05-18  476  	/* End-of-stack check for user tasks: */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  477  	if (state->regs && user_mode(state->regs))
d31a580266eeb1 Josh Poimboeuf   2018-05-18  478  		goto the_end;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  479  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  480  	/*
ee9f8fce996408 Josh Poimboeuf   2017-07-24  481  	 * Find the orc_entry associated with the text address.
ee9f8fce996408 Josh Poimboeuf   2017-07-24  482  	 *
372a8eaa05998c Josh Poimboeuf   2020-07-17  483  	 * For a call frame (as opposed to a signal frame), state->ip points to
372a8eaa05998c Josh Poimboeuf   2020-07-17  484  	 * the instruction after the call.  That instruction's stack layout
372a8eaa05998c Josh Poimboeuf   2020-07-17  485  	 * could be different from the call instruction's layout, for example
372a8eaa05998c Josh Poimboeuf   2020-07-17  486  	 * if the call was to a noreturn function.  So get the ORC data for the
372a8eaa05998c Josh Poimboeuf   2020-07-17  487  	 * call instruction itself.
ee9f8fce996408 Josh Poimboeuf   2017-07-24  488  	 */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  489  	orc = orc_find(state->signal ? state->ip : state->ip - 1);
ae6a45a0868986 Josh Poimboeuf   2019-06-26  490  	if (!orc) {
ae6a45a0868986 Josh Poimboeuf   2019-06-26  491  		/*
ae6a45a0868986 Josh Poimboeuf   2019-06-26  492  		 * As a fallback, try to assume this code uses a frame pointer.
ae6a45a0868986 Josh Poimboeuf   2019-06-26  493  		 * This is useful for generated code, like BPF, which ORC
ae6a45a0868986 Josh Poimboeuf   2019-06-26  494  		 * doesn't know about.  This is just a guess, so the rest of
ae6a45a0868986 Josh Poimboeuf   2019-06-26  495  		 * the unwind is no longer considered reliable.
ae6a45a0868986 Josh Poimboeuf   2019-06-26  496  		 */
ae6a45a0868986 Josh Poimboeuf   2019-06-26  497  		orc = &orc_fp_entry;
ae6a45a0868986 Josh Poimboeuf   2019-06-26  498  		state->error = true;
ae6a45a0868986 Josh Poimboeuf   2019-06-26  499  	}
d31a580266eeb1 Josh Poimboeuf   2018-05-18  500  
d31a580266eeb1 Josh Poimboeuf   2018-05-18  501  	/* End-of-stack check for kernel threads: */
d31a580266eeb1 Josh Poimboeuf   2018-05-18  502  	if (orc->sp_reg == ORC_REG_UNDEFINED) {
d31a580266eeb1 Josh Poimboeuf   2018-05-18  503  		if (!orc->end)
d31a580266eeb1 Josh Poimboeuf   2018-05-18  504  			goto err;
d31a580266eeb1 Josh Poimboeuf   2018-05-18  505  
d31a580266eeb1 Josh Poimboeuf   2018-05-18  506  		goto the_end;
d31a580266eeb1 Josh Poimboeuf   2018-05-18  507  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  508  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  509  	/* Find the previous frame's stack: */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  510  	switch (orc->sp_reg) {
ee9f8fce996408 Josh Poimboeuf   2017-07-24  511  	case ORC_REG_SP:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  512  		sp = state->sp + orc->sp_offset;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  513  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  514  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  515  	case ORC_REG_BP:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  516  		sp = state->bp + orc->sp_offset;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  517  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  518  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  519  	case ORC_REG_SP_INDIRECT:
87ccc826bf1c9e Peter Zijlstra   2021-02-03  520  		sp = state->sp;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  521  		indirect = true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  522  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  523  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  524  	case ORC_REG_BP_INDIRECT:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  525  		sp = state->bp + orc->sp_offset;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  526  		indirect = true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  527  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  528  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  529  	case ORC_REG_R10:
81b67439d14767 Josh Poimboeuf   2020-04-25  530  		if (!get_reg(state, offsetof(struct pt_regs, r10), &sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25 @531  			orc_warn_current("missing R10 value at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  532  					 (void *)state->ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  533  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  534  		}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  535  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  536  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  537  	case ORC_REG_R13:
81b67439d14767 Josh Poimboeuf   2020-04-25  538  		if (!get_reg(state, offsetof(struct pt_regs, r13), &sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25  539  			orc_warn_current("missing R13 value at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  540  					 (void *)state->ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  541  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  542  		}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  543  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  544  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  545  	case ORC_REG_DI:
81b67439d14767 Josh Poimboeuf   2020-04-25  546  		if (!get_reg(state, offsetof(struct pt_regs, di), &sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25  547  			orc_warn_current("missing RDI value at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  548  					 (void *)state->ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  549  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  550  		}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  551  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  552  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  553  	case ORC_REG_DX:
81b67439d14767 Josh Poimboeuf   2020-04-25  554  		if (!get_reg(state, offsetof(struct pt_regs, dx), &sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25  555  			orc_warn_current("missing DX value at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  556  					 (void *)state->ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  557  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  558  		}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  559  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  560  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  561  	default:
b08418b5483125 Josh Poimboeuf   2020-04-25  562  		orc_warn("unknown SP base reg %d at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  563  			 orc->sp_reg, (void *)state->ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  564  		goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  565  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  566  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  567  	if (indirect) {
ee9f8fce996408 Josh Poimboeuf   2017-07-24  568  		if (!deref_stack_reg(state, sp, &sp))
d31a580266eeb1 Josh Poimboeuf   2018-05-18  569  			goto err;
87ccc826bf1c9e Peter Zijlstra   2021-02-03  570  
87ccc826bf1c9e Peter Zijlstra   2021-02-03  571  		if (orc->sp_reg == ORC_REG_SP_INDIRECT)
87ccc826bf1c9e Peter Zijlstra   2021-02-03  572  			sp += orc->sp_offset;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  573  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  574  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  575  	/* Find IP, SP and possibly regs: */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  576  	switch (orc->type) {
ee819aedf34a8f Julien Thierry   2020-09-04  577  	case UNWIND_HINT_TYPE_CALL:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  578  		ip_p = sp - sizeof(long);
ee9f8fce996408 Josh Poimboeuf   2017-07-24  579  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  580  		if (!deref_stack_reg(state, ip_p, &state->ip))
d31a580266eeb1 Josh Poimboeuf   2018-05-18  581  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  582  
19138af1bd880d Masami Hiramatsu 2021-09-14  583  		state->ip = unwind_recover_ret_addr(state, state->ip,
19138af1bd880d Masami Hiramatsu 2021-09-14  584  						    (unsigned long *)ip_p);
ee9f8fce996408 Josh Poimboeuf   2017-07-24  585  		state->sp = sp;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  586  		state->regs = NULL;
81b67439d14767 Josh Poimboeuf   2020-04-25  587  		state->prev_regs = NULL;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  588  		state->signal = false;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  589  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  590  
ee819aedf34a8f Julien Thierry   2020-09-04  591  	case UNWIND_HINT_TYPE_REGS:
b02fcf9ba12110 Josh Poimboeuf   2017-12-04  592  		if (!deref_stack_regs(state, sp, &state->ip, &state->sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25  593  			orc_warn_current("can't access registers at %pB\n",
b08418b5483125 Josh Poimboeuf   2020-04-25  594  					 (void *)orig_ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  595  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  596  		}
19138af1bd880d Masami Hiramatsu 2021-09-14  597  		/*
19138af1bd880d Masami Hiramatsu 2021-09-14  598  		 * There is a small chance to interrupt at the entry of
f3a112c0c40dd9 Masami Hiramatsu 2022-03-26  599  		 * arch_rethook_trampoline() where the ORC info doesn't exist.
f3a112c0c40dd9 Masami Hiramatsu 2022-03-26  600  		 * That point is right after the RET to arch_rethook_trampoline()
19138af1bd880d Masami Hiramatsu 2021-09-14  601  		 * which was modified return address.
f3a112c0c40dd9 Masami Hiramatsu 2022-03-26  602  		 * At that point, the @addr_p of the unwind_recover_rethook()
19138af1bd880d Masami Hiramatsu 2021-09-14  603  		 * (this has to point the address of the stack entry storing
19138af1bd880d Masami Hiramatsu 2021-09-14  604  		 * the modified return address) must be "SP - (a stack entry)"
19138af1bd880d Masami Hiramatsu 2021-09-14  605  		 * because SP is incremented by the RET.
19138af1bd880d Masami Hiramatsu 2021-09-14  606  		 */
f3a112c0c40dd9 Masami Hiramatsu 2022-03-26  607  		state->ip = unwind_recover_rethook(state, state->ip,
19138af1bd880d Masami Hiramatsu 2021-09-14  608  				(unsigned long *)(state->sp - sizeof(long)));
ee9f8fce996408 Josh Poimboeuf   2017-07-24  609  		state->regs = (struct pt_regs *)sp;
81b67439d14767 Josh Poimboeuf   2020-04-25  610  		state->prev_regs = NULL;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  611  		state->full_regs = true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  612  		state->signal = true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  613  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  614  
ee819aedf34a8f Julien Thierry   2020-09-04  615  	case UNWIND_HINT_TYPE_REGS_PARTIAL:
b02fcf9ba12110 Josh Poimboeuf   2017-12-04  616  		if (!deref_stack_iret_regs(state, sp, &state->ip, &state->sp)) {
b08418b5483125 Josh Poimboeuf   2020-04-25  617  			orc_warn_current("can't access iret registers at %pB\n",
b08418b5483125 Josh Poimboeuf   2020-04-25  618  					 (void *)orig_ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  619  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  620  		}
19138af1bd880d Masami Hiramatsu 2021-09-14  621  		/* See UNWIND_HINT_TYPE_REGS case comment. */
f3a112c0c40dd9 Masami Hiramatsu 2022-03-26  622  		state->ip = unwind_recover_rethook(state, state->ip,
19138af1bd880d Masami Hiramatsu 2021-09-14  623  				(unsigned long *)(state->sp - sizeof(long)));
ee9f8fce996408 Josh Poimboeuf   2017-07-24  624  
81b67439d14767 Josh Poimboeuf   2020-04-25  625  		if (state->full_regs)
81b67439d14767 Josh Poimboeuf   2020-04-25  626  			state->prev_regs = state->regs;
b02fcf9ba12110 Josh Poimboeuf   2017-12-04  627  		state->regs = (void *)sp - IRET_FRAME_OFFSET;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  628  		state->full_regs = false;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  629  		state->signal = true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  630  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  631  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  632  	default:
b08418b5483125 Josh Poimboeuf   2020-04-25  633  		orc_warn("unknown .orc_unwind entry type %d at %pB\n",
58c3862b521ead Josh Poimboeuf   2017-10-20  634  			 orc->type, (void *)orig_ip);
a0f81bf2688804 Josh Poimboeuf   2020-04-25  635  		goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  636  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  637  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  638  	/* Find BP: */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  639  	switch (orc->bp_reg) {
ee9f8fce996408 Josh Poimboeuf   2017-07-24  640  	case ORC_REG_UNDEFINED:
81b67439d14767 Josh Poimboeuf   2020-04-25  641  		if (get_reg(state, offsetof(struct pt_regs, bp), &tmp))
81b67439d14767 Josh Poimboeuf   2020-04-25  642  			state->bp = tmp;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  643  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  644  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  645  	case ORC_REG_PREV_SP:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  646  		if (!deref_stack_reg(state, sp + orc->bp_offset, &state->bp))
d31a580266eeb1 Josh Poimboeuf   2018-05-18  647  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  648  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  649  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  650  	case ORC_REG_BP:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  651  		if (!deref_stack_reg(state, state->bp + orc->bp_offset, &state->bp))
d31a580266eeb1 Josh Poimboeuf   2018-05-18  652  			goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  653  		break;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  654  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  655  	default:
58c3862b521ead Josh Poimboeuf   2017-10-20  656  		orc_warn("unknown BP base reg %d for ip %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  657  			 orc->bp_reg, (void *)orig_ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  658  		goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  659  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  660  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  661  	/* Prevent a recursive loop due to bad ORC data: */
ee9f8fce996408 Josh Poimboeuf   2017-07-24  662  	if (state->stack_info.type == prev_type &&
ee9f8fce996408 Josh Poimboeuf   2017-07-24  663  	    on_stack(&state->stack_info, (void *)state->sp, sizeof(long)) &&
ee9f8fce996408 Josh Poimboeuf   2017-07-24  664  	    state->sp <= prev_sp) {
b08418b5483125 Josh Poimboeuf   2020-04-25  665  		orc_warn_current("stack going in the wrong direction? at %pB\n",
ee9f8fce996408 Josh Poimboeuf   2017-07-24  666  				 (void *)orig_ip);
d31a580266eeb1 Josh Poimboeuf   2018-05-18  667  		goto err;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  668  	}
ee9f8fce996408 Josh Poimboeuf   2017-07-24  669  
ee9f8fce996408 Josh Poimboeuf   2017-07-24  670  	preempt_enable();
ee9f8fce996408 Josh Poimboeuf   2017-07-24  671  	return true;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  672  
d31a580266eeb1 Josh Poimboeuf   2018-05-18  673  err:
d31a580266eeb1 Josh Poimboeuf   2018-05-18  674  	state->error = true;
d31a580266eeb1 Josh Poimboeuf   2018-05-18  675  
d31a580266eeb1 Josh Poimboeuf   2018-05-18  676  the_end:
ee9f8fce996408 Josh Poimboeuf   2017-07-24  677  	preempt_enable();
ee9f8fce996408 Josh Poimboeuf   2017-07-24  678  	state->stack_info.type = STACK_TYPE_UNKNOWN;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  679  	return false;
ee9f8fce996408 Josh Poimboeuf   2017-07-24  680  }
ee9f8fce996408 Josh Poimboeuf   2017-07-24  681  EXPORT_SYMBOL_GPL(unwind_next_frame);
ee9f8fce996408 Josh Poimboeuf   2017-07-24  682  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (151937 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ