From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27314 invoked by alias); 29 Jan 2013 19:04:44 -0000 Received: (qmail 27304 invoked by uid 22791); 29 Jan 2013 19:04:43 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_SPAMHAUS_DROP X-Spam-Check-By: sourceware.org Received: from arrakis.dune.hu (HELO eddie.linux-mips.org) (78.24.191.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Jan 2013 19:04:35 +0000 Received: from localhost.localdomain ([127.0.0.1]:43404 "EHLO linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S6824769Ab3A2TEeAeHmp (ORCPT ); Tue, 29 Jan 2013 20:04:34 +0100 Received: from scotty.linux-mips.net (localhost.localdomain [127.0.0.1]) by scotty.linux-mips.net (8.14.5/8.14.4) with ESMTP id r0TJ4Lqa032204; Tue, 29 Jan 2013 20:04:21 +0100 Received: (from ralf@localhost) by scotty.linux-mips.net (8.14.5/8.14.5/Submit) id r0TJ4InF032197; Tue, 29 Jan 2013 20:04:18 +0100 Date: Tue, 29 Jan 2013 19:04:00 -0000 From: Ralf Baechle To: "Maciej W. Rozycki" Cc: Mike Frysinger , libc-ports@sourceware.org Subject: Re: [PATCH][BZ #15054] MIPS: Fix syscall wrappers for syscall restart support Message-ID: <20130129190418.GC24911@linux-mips.org> References: <201301230009.23864.vapier@gentoo.org> <201301231317.34359.vapier@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00076.txt.bz2 On Tue, Jan 29, 2013 at 06:12:07PM +0000, Maciej W. Rozycki wrote: > > > > > We have an issue with the INTERNAL_SYSCALL_NCS wrapper in that it does > > > > > not respect the kernel's syscall restart convention. > > > > > > > > > > That convention requires the instruction immediately preceding SYSCALL > > > > > to initialize $v0 with the syscall number. Then if a restart triggers, > > > > > $v0 will have been clobbered by the syscall interrupted, and needs to > > > > > be reinititalized. The kernel will decrement the PC by 4 before > > > > > switching back to the user mode so that $v0 has been reloaded before > > > > > SYSCALL is executed again. This implies the place $v0 is loaded from > > > > > must be preserved across a syscall, e.g. an immediate, static > > > > > register, stack slot, etc. > > > > > > > > naïvely, but why can't the mips kernel paths take care of the reload > > > > itself ? other arches have scratch space in their pt_regs for doing just > > > > this (a bunch of arches use the orig_ convention). > > > > > > I agree it would be the most reasonable approach if designing from > > > scratch; unfortunately what we have is how the ABI has been set back in > > > 1994. You won't be able to patch up all the kernel binaries out there, > > > sigh... > > > > sure, you won't be able to retroactively fixing kernels. but you'll be able to > > make future kernels more robust against shady userlands. as you've pointed > > out, this is an extremely subtle bug that can easily go unnoticed for a long > > time which simply injects random flakiness into the runtime system. > > That's not unreasonable, I agree. Ralf, what do you think? Kernel commit 8f5a00eb422ed86e77bb8f67e08b9fe6d30f679a [MIPS: Sanitize restart logics] dated September 28, 2010 has already fixed this issue for Linux 2.6.36. The linux-mips.org kernel tree contains backports of this patch to all -stable branches all the way back to 2.6.16. Ralf