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: <20200514201340.GA14148@amd>
Date:   Thu, 14 May 2020 22:13:40 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Josh Poimboeuf <jpoimboe@...hat.com>
Cc:     Pavel Machek <pavel@...x.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Miroslav Benes <mbenes@...e.cz>,
        Ingo Molnar <mingo@...nel.org>,
        Andy Lutomirski <luto@...nel.org>, Dave Jones <dsj@...com>,
        Jann Horn <jannh@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Vince Weaver <vincent.weaver@...ne.edu>
Subject: Re: [PATCH 4.19 41/48] x86/unwind/orc: Prevent unwinding before ORC
 initialization

Hi!

> > > From: Josh Poimboeuf <jpoimboe@...hat.com>
> > > 
> > > commit 98d0c8ebf77e0ba7c54a9ae05ea588f0e9e3f46e upstream.
> > > 
> > > If the unwinder is called before the ORC data has been initialized,
> > > orc_find() returns NULL, and it tries to fall back to using frame
> > > pointers.  This can cause some unexpected warnings during boot.
> > > 
> > > Move the 'orc_init' check from orc_find() to __unwind_init(), so that it
> > > doesn't even try to unwind from an uninitialized state.
> > 
> > > @@ -563,6 +560,9 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
> > >  void __unwind_start(struct unwind_state *state, struct task_struct *task,
> > >  		    struct pt_regs *regs, unsigned long *first_frame)
> > >  {
> > > +	if (!orc_init)
> > > +		goto done;
> > > +
> > >  	memset(state, 0, sizeof(*state));
> > >  	state->task = task;
> > >  
> > 
> > As this returns the *state to the caller, should the "goto done" move
> > below the memset? Otherwise we are returning partialy-initialized
> > struct, which is ... weird.
> 
> Yeah, it is a little weird.  In most cases it should be fine, but there
> is an edge case where if there's a corrupt ORC table and this returns
> early, 'arch_stack_walk_reliable() -> unwind_error()' could check an
> uninitialized value.
> 
> Also the __unwind_start() error handling needs to set that error bit
> anyway, in its error cases.  I'll fix it up.

I did this in the mean time. It moves goto around memset, and I
believe that 8 in get_reg should have been sizeof(long) [not that it
matters, x86-32 is protected by build bug on.]

Signed-off-by: Pavel Machek <pavel@....cz>

Best regards,
								Pavel

diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
index 169b96492b7c..90cb3cb2b4f1 100644
--- a/arch/x86/kernel/unwind_orc.c
+++ b/arch/x86/kernel/unwind_orc.c
@@ -375,7 +375,7 @@ static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr
 static bool get_reg(struct unwind_state *state, unsigned int reg_off,
 		    unsigned long *val)
 {
-	unsigned int reg = reg_off/8;
+	unsigned int reg = reg_off/sizeof(long);
 
 	if (!state->regs)
 		return false;
@@ -589,12 +589,12 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
 void __unwind_start(struct unwind_state *state, struct task_struct *task,
 		    struct pt_regs *regs, unsigned long *first_frame)
 {
-	if (!orc_init)
-		goto done;
-
 	memset(state, 0, sizeof(*state));
 	state->task = task;
 
+	if (!orc_init)
+		goto done;
+	
 	/*
 	 * Refuse to unwind the stack of a task while it's executing on another
 	 * CPU.  This check is racy, but that's ok: the unwinder has other


-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ