]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ksplice: Clear garbage data on the kernel stack when handling signals
authorSasha Levin <sasha.levin@oracle.com>
Thu, 15 Jan 2015 01:41:18 +0000 (20:41 -0500)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Mon, 29 Jun 2015 15:36:55 +0000 (08:36 -0700)
The garbage data can give false-positives for the Ksplice safety checks
making it difficult (or sometimes impossible) to apply the rebootless
updates.  Clear the garbage with 0-words to avoid this.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
arch/x86/kernel/entry_32.S
arch/x86/kernel/entry_64.S

index 1c309763e32197d255b72e3f976aa948ab67f431..9b0d1bd1d15a43192f281a92985f5e0f6ecec91c 100644 (file)
@@ -628,7 +628,7 @@ work_notifysig:                             # deal with pending signals and
        cmpb $USER_RPL, %bl
        jb resume_kernel
        xorl %edx, %edx
-       call do_notify_resume
+       call clear_stack_do_notify_resume
        jmp resume_userspace
 
 #ifdef CONFIG_VM86
@@ -642,6 +642,33 @@ work_notifysig_v86:
 #endif
 END(work_pending)
 
+    # Clear the stack before handling signals
+    ALIGN
+#define STACK_CLEAR_WORDS    0x80
+ENTRY(clear_stack_do_notify_resume)
+    testl $_TIF_SIGPENDING, %ecx
+    jnz do_notify_resume
+
+    push %eax
+    push %ecx
+    push %edi
+
+    movl %esp, %edi
+    subl $4, %edi
+    movl $STACK_CLEAR_WORDS, %ecx
+    xorl %eax, %eax
+
+    std
+    rep stosl
+    cld
+
+    pop %edi
+    pop %ecx
+    pop %eax
+
+    jmp do_notify_resume
+END(clear_stack_do_notify_resume)
+
        # perform syscall exit tracing
        ALIGN
 syscall_trace_entry:
index 02c2eff7478da6b5180eaf639010f93112e333c1..f9ba92ca936a27ccf95f4d43b2d7a208e15770fc 100644 (file)
@@ -401,7 +401,7 @@ int_signal:
        jz 1f
        movq %rsp,%rdi          # &ptregs -> arg1
        xorl %esi,%esi          # oldset -> arg2
-       call do_notify_resume
+       call clear_stack_do_notify_resume
 1:     movl $_TIF_WORK_MASK,%edi
 int_restore_rest:
        RESTORE_EXTRA_REGS
@@ -867,7 +867,7 @@ retint_signal:
        movq $-1,ORIG_RAX(%rsp)
        xorl %esi,%esi          # oldset
        movq %rsp,%rdi          # &pt_regs
-       call do_notify_resume
+       call clear_stack_do_notify_resume
        RESTORE_EXTRA_REGS
        DISABLE_INTERRUPTS(CLBR_NONE)
        TRACE_IRQS_OFF
@@ -1651,3 +1651,24 @@ ENTRY(ignore_sysret)
        CFI_ENDPROC
 END(ignore_sysret)
 
+    # Clear the stack before handling signals
+#define STACK_CLEAR_WORDS    0x80
+ENTRY(clear_stack_do_notify_resume)
+    testl $_TIF_SIGPENDING, %edx
+    jnz do_notify_resume
+
+    pushq %rdi
+
+    movq %rsp, %rdi
+    subq $8, %rdi
+    movl $STACK_CLEAR_WORDS, %ecx
+    xorq %rax, %rax
+
+    std
+    rep stosq
+    cld
+
+    popq %rdi
+
+    jmp do_notify_resume
+END(clear_stack_do_notify_resume)