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:	Tue, 3 Nov 2009 19:16:26 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Stefani Seibold <stefani@...bold.net>
Cc:	linux-kernel <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Americo Wang <xiyou.wangcong@...il.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] update fix X86_64 procfs provide stack information for
	threads


* Stefani Seibold <stefani@...bold.net> wrote:

> Am Dienstag, den 03.11.2009, 09:28 +0100 schrieb Ingo Molnar:
> > > --- linux-2.6.32-rc5/arch/x86/include/asm/processor.h	2009-10-16 02:41:50.000000000 +0200
> > > +++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h	2009-11-02 10:39:47.177909657 +0100
> > > @@ -1000,7 +1001,13 @@
> > >  #define thread_saved_pc(t)	(*(unsigned long *)((t)->thread.sp - 8))
> > >  
> > >  #define task_pt_regs(tsk)	((struct pt_regs *)(tsk)->thread.sp0 - 1)
> > > -#define KSTK_ESP(tsk)		-1 /* sorry. doesn't work for syscall. */
> > > +
> > > +#ifdef CONFIG_IA32_EMULATION
> > > +extern unsigned long KSTK_ESP(struct task_struct *task);
> > > +#else
> > > +#define KSTK_ESP(task)		((task)->thread.usersp)
> > > +#endif
> > > +
> > >  #endif /* CONFIG_X86_64 */
> > >  
> > >  extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
> > > --- linux-2.6.32-rc5/arch/x86/kernel/process_64.c	2009-10-16 02:41:50.000000000 +0200
> > > +++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c	2009-11-02 10:48:23.614936810 +0100
> > > @@ -664,3 +669,11 @@
> > >  	return do_arch_prctl(current, code, addr);
> > >  }
> > >  
> > > +#ifdef CONFIG_IA32_EMULATION
> > > +unsigned long KSTK_ESP(struct task_struct *task)
> > > +{
> > > +	return (test_tsk_thread_flag(task, TIF_IA32)) ? \
> > > +			(task_pt_regs(task)->sp) : \
> > > +			((task)->thread.usersp);
> > > +}
> > > +#endif
> > 
> > That's quite ugly. The KSTK_ESP() function should be unconditional and 
> > the #ifdef should be eliminated. If CONFIG_IA32_EMULATION is turned off 
> > (whichis rare) then TIF_IA32 wont be set so the function should work 
> > fine.
> > 
> > Thanks,
> > 
> > 	Ingo
> 
> Hi Ingo,
> 
> come on, thats not fair. [...]

(Hacking the kernel is rarely 'fair' in the way you seem to be defining 
it.)

> [...] This would be not the only piece of ugly code in the x86_64 
> implementation. It is much better than the previous hack where 
> KSTK_ESP always returns a wrong hard coded value. That is really 
> ugly!!!!
> 
> It took me 6 hours to analyze the x64_64 code, most of them written in 
> assembler. I think it is a first solution, which makes the procfs 
> stack information work on this architecture and that was the goal.
> 
> I will remove the #ifdef's and repost the patch. Please accept this 
> patch, which make the KSTP_ESP thing on x86_64 better as before.
> 
> I am not a x64_64 bit hacker, i have not the knowledge to make a 
> perfect solution for this architecture. Also i am not a full time 
> kernel hacker, i have customers who wait for their projects.

The cleanup isnt really that hard at all, writng your mail probably took 
more time. I didnt see you complain when we merged your original procfs 
patch that introduced/exposed this whole issue:

 d899bf7: procfs: provide stack information for threads

Fixing followup issues is standard part of the work-with-upstream 
fairness equation.

	Ingo
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ