Re: [PATCH] powerpc: do_notify_resume can be called with bad thread_info flags argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Sorry, this got auto cc'ed to stable@ via git send-email. Please
disregard for now, we will get it merged upstream and at that point it
should flow into the stable trees via the usual means.

Anton

> Back in 7230c5644188 ("powerpc: Rework lazy-interrupt handling") we
> added a call out to restore_interrupts() (written in c) before we
> call do_notify_resume:
> 
>         bl      restore_interrupts
>         addi    r3,r1,STACK_FRAME_OVERHEAD
>         bl      do_notify_resume
> 
> Unfortunately do_notify_resume takes two arguments, the second one
> being the thread_info flags:
> 
> void do_notify_resume(struct pt_regs *regs, unsigned long
> thread_info_flags)
> 
> We do populate r4 earlier, but restore_interrupts() is free to muck
> it up all it wants. My guess is the gcc compiler gods shone down on
> us and its register allocator never used r4. Sometimes, rarely, luck
> is on our side.
> 
> Signed-off-by: Anton Blanchard <anton@xxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
>  arch/powerpc/kernel/entry_64.S | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/entry_64.S
> b/arch/powerpc/kernel/entry_64.S index 9caab69..add42d0 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -661,6 +661,13 @@ _GLOBAL(ret_from_except_lite)
>  	bl	save_nvgprs
>  	bl	restore_interrupts
>  	addi	r3,r1,STACK_FRAME_OVERHEAD
> +	/*
> +	 * restore_interrupts() is written in c and could clobber all
> +	 * volatile registers. We need to reload our thread_info
> flags
> +	 * in r4 for do_notify_resume().
> +	 */
> +	CURRENT_THREAD_INFO(r9, r1)
> +	ld	r4,TI_FLAGS(r9)
>  	bl	do_notify_resume
>  	b	ret_from_except
>  

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]