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  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:	Tue, 27 Oct 2009 00:57:05 +0800
From:	Wu Zhangjin <wuzhangjin@...il.com>
To:	rostedt@...dmis.org
Cc:	linux-mips@...ux-mips.org, linux-kernel@...r.kernel.org,
	Thomas Gleixner <tglx@...utronix.de>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Nicholas Mc Guire <der.herr@...r.at>,
	Richard Sandiford <rdsandiford@...glemail.com>,
	David Daney <ddaney@...iumnetworks.com>,
	Adam Nemet <anemet@...iumnetworks.com>,
	Patrik Kluba <kpajko79@...il.com>
Subject: Re: [PATCH -v5 10/11] tracing: add function graph tracer support
 for MIPS

Hi,

[...] 
> 
> Yeah, and probably not as important in the mips world, as it is used
> more with embedded devices than desktops. We must always take the
> "paranoid" approach for tracing. At least in PPC and x86, we assume
> everything is broken ;-)  And we want to be as robust as possible. If
> something goes wrong, we want to detect it ASAP and report it. And keep
> the system from crashing.
> 
> At least with MIPS we don't need to worry about crashing Linus's
> desktop. With is the #1 priority we have on x86 ... "Don't crash Linus's
> desktop!".
> 
> If Linus sees a warning, he'll bitch at us. If we crash his box, and he
> was to lose any information, he'll strip out our code!
> 

Okay, a new patch for all of the exception handling will go into -v7.

> 
> > 
> > So, we just need to replace this:
> > 
> > 		if ((code & MOV_FP_SP) == MOV_FP_SP)
> > 			return parent_addr;	
> > 	
> > by
> > 
> > #define S_INSN	(0xafb0 << 16)
> > 
> > 		if ((code & S_INSN) != S_INSN)
> > 			return parent_addr;
> 
> I would be even more paranoid, and make sure each of those stores, store
> into sp.

get it :-)

(I need to be more paranoid too, otherwise, Steven will not accept my
patches!)

> 
> > 
> > > 
> > > > +
> > > > +	sp = fp + (code & STACK_OFFSET_MASK);
> > > > +	ra = *(unsigned long *)sp;
> > > 
> > > Also might want to make the above into a asm with exception handling.
> > > 
> > > > +
> > > > +	if (ra == parent)
> > > > +		return sp;
> > > > +
> > > > +	ftrace_graph_stop();
> > > > +	WARN_ON(1);
> > > > +	return parent_addr;
> > > 
> > > Hmm, may need to do more than this. See below.
> > > 
[...]
> > > > +
> > > > +	old = *parent;
> > > > +
> > > > +	parent = (unsigned long *)ftrace_get_parent_addr(self_addr, old,
> > > > +							 (unsigned long)parent,
> > > > +							 fp);
> > > > +
> > > > +	*parent = return_hooker;
> > > 
> > > Although you may have turned off fgraph tracer in
> > > ftrace_get_parent_addr, nothing stops the below from messing with the
> > > stack. The return stack may get off sync and break later. If you fail
> > > the above, you should not be calling the push function below.
> > > 
> > 
> > We need to really stop before ftrace_push_return_trace to avoid messing
> > with the stack :-) but if we have stopped the tracer, is it important to
> > mess with the stack or not?
> 
> The ftrace_push_return_trace does not test if the trace stopped, that is
> expected to be done by the caller. If you mess with the stack set up,
> you will crash the box. Remember, before the failure, you could have
> already replaced return jumps. Those will still be falling back to the
> return_to_handler. If you mess with the stack, but don't update the
> return, the other returns will be out of sync and call the wrong return
> address.
> 

As you can see, after stopping the function graph tracer(here the function is non-leaf)
with ftrace_graph_stop() in ftrace_get_parent_addr(), I return the old parent_addr,
this is only the stack address in the stack space of ftrace_graph_caller, which means
that, I never touch the real stack address of the non-leaf function, and it will not trap
into the return_to_handler hooker 'Cause the non-leaf function will load it's own normal
return address from it's own stack, and then just return back normally.
	-- This is another trick :-)

Regards,
	Wu Zhangjin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists