lkml.org 
[lkml]   [2005]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [WTF?] sys_tas() on m32r
Hirokazu Takata <takata@linux-m32r.org> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-27 14:25    [W:0.072 / U:1.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site