From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 3/5] mips: sanitize restart logics Date: Fri, 8 Oct 2010 06:36:56 +0100 Message-ID: <20101008053656.GU19804@ZenIV.linux.org.uk> References: <4CA38538.8000007@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: "Maciej W. Rozycki" Cc: David Daney , Al Viro , ralf@linux-mips.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Maciej W. Rozycki" List-Id: linux-arch.vger.kernel.org On Thu, Sep 30, 2010 at 02:50:17AM +0100, Maciej W. Rozycki wrote: > On Wed, 29 Sep 2010, David Daney wrote: > Not exactly. These GNU C library functions rely on the magic value of > "1" there to recognise contexts they created themselves and which must > therefore be handled by themselves internally (these contexts are not > complete and only preserve the call-saved registers as specified by the > respective MIPS ABIs, and are therefore unsafe to be passed to the > rt_sigreturn(2) syscall). All the other values, including of course "0", > are not treated specially and the context is passed to rt_sigreturn(2) as > usually. This only matters in cases where e.g. setcontext(3) is used to > exit from or return to a signal handler. Nothing has changed in that respect; setup_sigcontext() (and its counterparts) do _not_ use regs->regs[0]. Note err |= __put_user(0, &sc->sc_regs[0]); for (i = 1; i < 32; i++) err |= __put_user(regs->regs[i], &sc->sc_regs[i]); in there. The whole point of ->regs[0] uses (both original and modified) is that $0 is constant 0 and thus the kernel is free to use that member of pt_regs to indicate that syscall restart might be needed. So's libc, for that matter (to distinguish between sigreturn and setcontext ones). When sigframe is created we still discard the value - the fragment above is not modified at all. BTW, with original code regs->regs[0] *can* be 1, if you are leaving syscall with -EINVAL. It won't reach the userland, though.