[lkml]   [2011]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [BUG] broken ebba638ae723d8a8fc2f7abce5ec18b688b791d7
On 01/27/2011 03:00 PM, Kees Cook wrote:
> Yikes, good catch.
> arch/x86/kernel/trampoline_64.S uses:
> movw $(trampoline_stack_end - r_base), %sp
> arch/x86/boot/compressed/head_64.S uses:
> movl $boot_stack_end, %eax
> addl %ebp, %eax
> movl %eax, %esp
> what would be safe for arch/x86/kernel/head_32.S ? It uses "stack_start",
> but later after paging set-up. Is the following sane to solve this?

To run it before paging is set up, you can't use stack, start; you have
to use a pointer based on physical address. You have two problems with
using stack_start: you're using a linear address to access stack_start,
and stack_start itself contains a linear address.

It's not entirely clear to me why we don't initialize %ss to __BOOT_DS
with the other segment registers, but it would make most sense to me:

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index fc293dc..c10f9ba 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -99,7 +99,12 @@ ENTRY(startup_32)
movl %eax,%es
movl %eax,%fs
movl %eax,%gs
+ movl %eax,%ss
+ * Set up an initial stack
+ */
+ movl $pa(init_thread_union+THREAD_SIZE), %esp

* Clear BSS first so that there are no surprises...

 \ /
  Last update: 2011-01-28 03:27    [W:0.094 / U:37.724 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site