From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vineet Gupta Subject: Re: pt_regs leak into userspace (was Re: [PATCH v3 20/71] ARC: Signal handling) Date: Mon, 11 Feb 2013 16:52:32 +0530 Message-ID: <5118D478.3010205@synopsys.com> References: <1359024639-21915-1-git-send-email-vgupta@synopsys.com> <1359024639-21915-9-git-send-email-vgupta@synopsys.com> <51189D2F.4030000@synopsys.com> <5118C458.2070205@synopsys.com> <5118C7B6.6040807@imgtec.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from us01smtp2.synopsys.com ([198.182.44.80]:50083 "EHLO kiruna.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755536Ab3BKLW5 (ORCPT ); Mon, 11 Feb 2013 06:22:57 -0500 In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jonas Bonn Cc: James Hogan , Arnd Bergmann , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Al Viro On Monday 11 February 2013 04:23 PM, Jonas Bonn wrote: > On 11 February 2013 11:28, James Hogan wrote: >> On 11/02/13 10:13, Vineet Gupta wrote: >>> On Monday 11 February 2013 03:06 PM, Jonas Bonn wrote: >>>> On 11 February 2013 08:26, Vineet Gupta wrote: >>>> >>>>> The only downside of this patch is that userspace signal stack grows in size, >>>>> since signal frame only cares about scratch regs (pt_regs), but has to accommodate >>>>> unused placeholder for callee regs too by virtue of using user_regs_struct. >>>> Is this really true? Don't setcontext and friends require that _all_ >>>> the registers be part of sigcontext? >>> >>> But for an ABI - callee saved regs will anyhow be saved/restored even in >>> setcontext case ! So collecting it for that purpose seems useless, or am I missing >>> something here. >> >> I think Jonas' point was that signals are asynchronous, i.e. you could >> get interrupted by a signal at virtually any time during the program's >> execution. > > No, I agree that the callee-saved regs don't need to be saved across a > signal handler invocation. It's really just the setcontext case that > wants to be able to swap out the callee-saved regs. I don't think that's needed either - and if thats mandated somewhere, it would seem a unnecessary mis-optimization IMHO. See, even a setcontext enabled control flow needs to be ABI compliant so that it plays nicely with other normal flows of execution. Thus e.g. it can't fudge a callee reg - it needs to save orig callee reg(s) and restore them in the end. And if we agree to those semantics - I don't see any value in swapping the callee reg context around usage of setcontext as it would be a wasted effort. -Vineet