[PATCH v4] powerpc: Avoid signed to unsigned conversion in set_thread_tidr()

christophe lombard clombard at linux.vnet.ibm.com
Tue Nov 28 19:26:05 AEDT 2017


Le 28/11/2017 à 03:53, Vaibhav Jain a écrit :
> There is an unsafe signed to unsigned conversion in set_thread_tidr()
> that may cause an error value to be assigned to SPRN_TIDR register and
> used as thread-id.
> 
> The issue happens as assign_thread_tidr() returns an int and
> thread.tidr is an unsigned-long. So a negative error code returned
> from assign_thread_tidr() will fail the error check and gets assigned
> as tidr as a large positive value.
> 
> To fix this the patch assigns the return value of assign_thread_tidr()
> to a temporary int and assigns it to thread.tidr iff its '> 0'.
> 
> The patch shouldn't impact the calling convention of set_thread_tidr()
> i.e all -ve return-values are error codes and a return value of '0'
> indicates success.
> 
> Fixes: ec233ede4c86("powerpc: Add support for setting SPRN_TIDR")
> Signed-off-by: Vaibhav Jain <vaibhav at linux.vnet.ibm.com>
> 
> ---

sounds good for me
Thanks

Reviewed-by: Christophe Lombard clombard at linux.vnet.ibm.com



More information about the Linuxppc-dev mailing list