From: Andrew Morton <akpm@osdl.org>
To: Hirokazu Takata <takata@linux-m32r.org>
Cc: viro@ftp.linux.org.uk, linux-kernel@vger.kernel.org,
takata@linux-m32r.org
Subject: Re: [WTF?] sys_tas() on m32r
Date: Tue, 27 Dec 2005 05:22:14 -0800 [thread overview]
Message-ID: <20051227052214.0098e7bf.akpm@osdl.org> (raw)
In-Reply-To: <20051227.142739.599244061.takata.hirokazu@renesas.com>
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.
next prev parent reply other threads:[~2005-12-27 13:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-23 6:15 Al Viro
2005-12-23 7:50 ` liyu
2005-12-23 7:54 ` Al Viro
2005-12-23 13:55 ` Andrew Morton
2005-12-23 19:10 ` Lee Revell
2005-12-27 6:36 ` Hirokazu Takata
2005-12-27 9:34 ` Jesper Juhl
2005-12-27 5:27 ` Hirokazu Takata
2005-12-27 13:22 ` Andrew Morton [this message]
2005-12-28 0:36 ` Hirokazu Takata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051227052214.0098e7bf.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=takata@linux-m32r.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome