From: Ralf Baechle <ralf@linux-mips.org>
To: Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: [PATCH] MIPS: fix forced successful syscalls
Date: Tue, 8 Oct 2013 09:42:15 +0200 [thread overview]
Message-ID: <20131008074215.GG1615@linux-mips.org> (raw)
In-Reply-To: <524D84EB.8060102@efixo.com>
On Thu, Oct 03, 2013 at 04:53:31PM +0200, Tanguy Bouzeloc wrote:
> On 10/02/2013 11:19 AM, Ralf Baechle wrote:
> >To my personal embarassment I have to admit that I knew about this since the
> >day the syscall wrapper was written - but was considering it an acceptable
> >bug ...
> >
> >Where it really bits is sigreturn and similar which use the following
> >stunt:
> >
> > /*
> > * Don't let your children do this ...
> > */
> > __asm__ __volatile__(
> > "move\t$29, %0\n\t"
> > "j\tsyscall_exit"
> > :/* no outputs */
> > :"r" (®s));
> > /* Unreached */
> >
> >to keep the syscall return path from tampering with the return value.
> >
> >The scall*.S part of your patch is clearing TIF_NOERROR using a non-atomic
> >LW/SW sequence. This needs to be done atomically or the thread's flags
> >variable might get corrupted. This is complicated by MIPS I, R5900 and
> >afair some older oddball not-quite MIPS II CPUs lacking LL/SC rsp. LLD/SCD.
> >
> > Ralf
> >
>
> I discover the issue when changing the HZ of the kernel to 100HZ, in
> this case the jiffies returned to the userland are the same as the
> kernel ticks and it'll wrap after 5 minutes of uptime. With kernel
> HZ at 250 or 1000H it'll make happen the ticks wrap after 230~260j.
>
> Unfortunately programs relying on ticks (they shouldn't but that
> happens) have unpredictable behavior for 11.3s before the wrap.
>
> I can update the patch in order to access atomically the thread
> flags, the point is ... it'll make the kernel incompatible with old
> hardware.
The price to pay: an ifdef ...
#include <asm/sgidefs.H>
...
#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
... LL/SC code goes here
#else
... LL/SC-less code goes here
#endif
But I'm wondering if we can move this hopefully relativly rare special
case into do_notify_resume() and handle it in plain C there.
Ralf
prev parent reply other threads:[~2013-10-08 7:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 14:22 [PATCH] MIPS: fix forced successful syscalls Tanguy Bouzeloc
2013-10-02 9:19 ` Ralf Baechle
2013-10-03 14:53 ` Tanguy Bouzeloc
2013-10-08 7:42 ` Ralf Baechle [this message]
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=20131008074215.GG1615@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=linux-mips@linux-mips.org \
--cc=tanguy.bouzeloc@efixo.com \
/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