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] [day] [month] [year] [list]
Message-ID: <CAFP4FLo3=2J4pwn5nFCtbHon6ZSh+W1JUrgrGXNCpWG6=R+AuQ@mail.gmail.com>
Date:	Mon, 18 May 2015 17:52:04 +0800
From:	yalin wang <yalin.wang2010@...il.com>
To:	Russell King - ARM Linux <linux@....linux.org.uk>
Cc:	will.deacon@....com, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	viro@...iv.linux.org.uk, Neil.Gao@...ymobile.com
Subject: Re: [RFC V2] arm:consider THUMB and BE endian kernel build

2015-05-18 17:40 GMT+08:00 Russell King - ARM Linux <linux@....linux.org.uk>:
> On Mon, May 18, 2015 at 03:36:10PM +0800, yalin wang wrote:
>> this patch fix the function in kernel_thread(),
>> when kernel is build as THUMB2 or BE8 endian, we should
>> also set the correct bit in CPSR, so that kernel can return to
>> the correct state to execute.
>
> Why do you think any of this is needed?
>
> When a kernel thread is created via kernel_thread(), copy_thread() is
> called with the function pointer in stack_start, and the functions
> argument in stk_size.
>
> When the scheduler switches to the thread, it reads the register state
> from thread->cpu_context, thereby loading r4 and r5 with the function
> argument and function pointer, and directing the PC to ret_from_fork.
> (For normal user clones and forks, r4 and r5 in kernel space will be
> zero.)
>
> The scheduler switch preserves the CPSR from the previous task, so if
> we're running a T2 BE8 kernel, the new thread will have its ret_from_fork
> called in T2 BE8 mode.
>
> ret_from_fork checks for a non-zero r5, and if so, calls that function,
> which will also see the CPSR set appropriately for the kernel mode.
>
> Functions called from kernel_thread() are not permitted to return, so
> we will never read the "childregs" off the top of the kernel stack.
> Childregs are initialised because we expect them to be at the top of
> every kernel stack.
>
> Ergo, this patch is not needed at all.
Genius explanation,
i see your idea,
i really make a mistake about user thread / kernel thread return method .
it is really a trick for kernel thread return implemented like this.  :)

Thank you !
--
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