Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A simplified version of the patch follows (The original is 176df245 in linus’s git repository) Note that this patch was applied to v2.6.22 – These files have moved around, so pull out an older kernel if you’re trying to follow along at home:
- --- a/arch/x86_64/ia32/ia32entry.S
- +++ b/arch/x86_64/ia32/ia32entry.S
- @@ -38,6 +38,18 @@
- movq %rax,R8(%rsp)
- .endm
- + .macro LOAD_ARGS32 offset
- + movl \offset(%rsp),%r11d
- + movl \offset+8(%rsp),%r10d
- + movl \offset+16(%rsp),%r9d
- + movl \offset+24(%rsp),%r8d
- + movl \offset+40(%rsp),%ecx
- + movl \offset+48(%rsp),%edx
- + movl \offset+56(%rsp),%esi
- + movl \offset+64(%rsp),%edi
- + movl \offset+72(%rsp),%eax
- + .endm
- @@ -334,7 +346,7 @@ ia32_tracesys:
- movq $-ENOSYS,RAX(%rsp) /* really needed? */
- movq %rsp,%rdi /* &pt_regs -> arg1 */
- call syscall_trace_enter
- - LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
- + LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
- RESTORE_REST
- jmp ia32_do_syscall
- END(ia32_syscall)
- The patch defines the IA32_LOAD_ARGS macro, and replaces LOAD_ARGS with it in several places (I’ve only shown one for simplicity). LOAD_ARGS32 differs only slightly from the LOAD_ARGS macro that it is replacing, which is defined in include/asm-x86_64/calling.h:
- .macro LOAD_ARGS offset
- movq \offset(%rsp),%r11
- movq \offset+8(%rsp),%r10
- movq \offset+16(%rsp),%r9
- movq \offset+24(%rsp),%r8
- movq \offset+40(%rsp),%rcx
- movq \offset+48(%rsp),%rdx
- movq \offset+56(%rsp),%rsi
- movq \offset+64(%rsp),%rdi
- movq \offset+72(%rsp),%rax
- .endm
- As the name suggests, LOAD_ARGS32 loads the registers from the stack as 32-bit values, rather than 64-bit. Importantly, in doing so it takes advantage of a quirk in the x86_64 architecture, that causes the top 32 bits of the registers to be zeroed if you write to the 32-bit versions. LOAD_ARGS32 thus zero-extends the 32-bit values it loads into the 64-bit registers.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement