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]
Date:   Thu, 12 Mar 2020 12:30:32 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     x86@...nel.org
Cc:     linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Vince Weaver <vincent.weaver@...ne.edu>,
        Dave Jones <dsj@...com>, Jann Horn <jannh@...gle.com>,
        Miroslav Benes <mbenes@...e.cz>,
        Andy Lutomirski <luto@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 13/14] x86/unwind/orc: Add more unwinder warnings

Make sure warnings are displayed for all error scenarios (except when
encountering an empty unwind hint).

Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
 arch/x86/kernel/unwind_orc.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
index 0ebc11a8bb45..4118013a574a 100644
--- a/arch/x86/kernel/unwind_orc.c
+++ b/arch/x86/kernel/unwind_orc.c
@@ -450,8 +450,15 @@ bool unwind_next_frame(struct unwind_state *state)
 
 	/* End-of-stack check for kernel threads: */
 	if (orc->sp_reg == ORC_REG_UNDEFINED) {
-		if (!orc->end)
+		if (!orc->end) {
+			/*
+			 * This is reported as an error for the caller, but
+			 * otherwise it isn't worth warning about.  In theory
+			 * it can only happen when hitting UNWIND_HINT_EMPTY in
+			 * entry code, close to a kernel exit point.
+			 */
 			goto err;
+		}
 
 		goto the_end;
 	}
@@ -515,8 +522,11 @@ bool unwind_next_frame(struct unwind_state *state)
 	}
 
 	if (indirect) {
-		if (!deref_stack_reg(state, sp, &sp))
+		if (!deref_stack_reg(state, sp, &sp)) {
+			orc_warn_current("can't access indirect SP at %pB\n",
+					 (void *)state->ip);
 			goto err;
+		}
 	}
 
 	/* Find IP, SP and possibly regs: */
@@ -524,8 +534,11 @@ bool unwind_next_frame(struct unwind_state *state)
 	case ORC_TYPE_CALL:
 		ip_p = sp - sizeof(long);
 
-		if (!deref_stack_reg(state, ip_p, &state->ip))
+		if (!deref_stack_reg(state, ip_p, &state->ip)) {
+			orc_warn_current("can't access call return IP (0x%lx) at %pB\n",
+					 ip_p, (void *)orig_ip);
 			goto err;
+		}
 
 		state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
 						  state->ip, (void *)ip_p);
@@ -577,13 +590,19 @@ bool unwind_next_frame(struct unwind_state *state)
 		break;
 
 	case ORC_REG_PREV_SP:
-		if (!deref_stack_reg(state, sp + orc->bp_offset, &state->bp))
+		if (!deref_stack_reg(state, sp + orc->bp_offset, &state->bp)) {
+			orc_warn_current("can't access BP (from SP) at %pB\n",
+					 (void *)orig_ip);
 			goto err;
+		}
 		break;
 
 	case ORC_REG_BP:
-		if (!deref_stack_reg(state, state->bp + orc->bp_offset, &state->bp))
+		if (!deref_stack_reg(state, state->bp + orc->bp_offset, &state->bp)) {
+			orc_warn_current("can't access BP at %pB\n",
+					 (void *)orig_ip);
 			goto err;
+		}
 		break;
 
 	default:
-- 
2.21.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ