Re: [WTF?] sys_tas() on m32r

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

 



Hirokazu Takata <[email protected]> wrote:
>
> I tried the latter way as the following patch, but the result was not 
> so gratifying; some hangups/lockups or kernel panics happened unexpectedly.
> 
> Am I missing anything?
> Any more comments or suggestions will be greatly appreciated.
> 
> ...
> --- linux-2.6.15-rc7.orig/arch/m32r/kernel/sys_m32r.c	2005-12-27 10:33:05.301372856 +0900
> +++ linux-2.6.15-rc7/arch/m32r/kernel/sys_m32r.c	2005-12-27 10:33:10.222624712 +0900
> @@ -29,44 +29,31 @@
>  
>  /*
>   * sys_tas() - test-and-set
> - * linuxthreads testing version
>   */
> -#ifndef CONFIG_SMP
>  asmlinkage int sys_tas(int *addr)
>  {
>  	int oldval;
> -	unsigned long flags;
>  
>  	if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
>  		return -EFAULT;
> -	local_irq_save(flags);
> -	oldval = *addr;
> -	if (!oldval)
> -		*addr = 1;
> -	local_irq_restore(flags);
> -	return oldval;
> -}
> -#else /* CONFIG_SMP */
> -#include <linux/spinlock.h>
> -
> -static DEFINE_SPINLOCK(tas_lock);
> -
> -asmlinkage int sys_tas(int *addr)
> -{
> -	int oldval;
>  
> -	if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> -		return -EFAULT;
> -
> -	_raw_spin_lock(&tas_lock);
> -	oldval = *addr;
> -	if (!oldval)
> -		*addr = 1;
> -	_raw_spin_unlock(&tas_lock);
> +	for ( ; ; ) {
> +		get_user(oldval, addr);

We need to check for -EFAULT here and fail the syscall if a fault was
detected.  Without this we'll certainly get lockups if the user passed a
bad address.  But this doesn't seem sufficient to eplain the problems which
you've observed.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux