From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755404Ab1HWQtW (ORCPT ); Tue, 23 Aug 2011 12:49:22 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57663 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959Ab1HWQtT (ORCPT ); Tue, 23 Aug 2011 12:49:19 -0400 Date: Tue, 23 Aug 2011 17:48:49 +0100 From: Al Viro To: Linus Torvalds Cc: "H. Peter Anvin" , Andrew Lutomirski , Borislav Petkov , Ingo Molnar , "user-mode-linux-devel@lists.sourceforge.net" , Richard Weinberger , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" Subject: Re: [uml-devel] SYSCALL, ptrace and syscall restart breakages (Re: [RFC] weird crap with vdso on uml/i386) Message-ID: <20110823164849.GF2203@ZenIV.linux.org.uk> References: <4E52D280.3010107@zytor.com> <20110823000314.GW2203@ZenIV.linux.org.uk> <4E52EF2A.8060608@zytor.com> <20110823010146.GY2203@ZenIV.linux.org.uk> <20110823011312.GZ2203@ZenIV.linux.org.uk> <20110823021717.GA2203@ZenIV.linux.org.uk> <20110823061531.GC2203@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 23, 2011 at 09:03:04AM -0700, Linus Torvalds wrote: > Suggested fixes: > > - instead of blindly doing SETREGS, just write the result registers > individually like you suggested Not enough. There is also a PITA with signal handlers. There we can't avoid modifying ebp on the way out of handler (i.e. by emulated sigreturn). And it lands us straight after syscall insn, with ebp "restored" to the wrong value. > OR (and perhaps preferably): > > - teach UML that when you do 'GETREGS' after a system call trapped, > we have switched things around to match the "official system call > order", and UML should just undo our swizzling, and do a "regs.ebp = > regs.ecx" to make it be what the actual original registers were (or > whatever the actual correct swizzle is - I didn't think that through > very much). Um... How would it know which syscall variant had that been, to start with? For int 0x80 it would need to use registers as-is. For SYSENTER it also could use them as-is - ebp will differ from what we put there when entering the sucker, but not critically so; on the way out of syscall we'll overwrite it anyway immediately (either by pop or mov). For SYSCALL... we don't really care about ecx contents prior to entering the kernel (and it'll be blown out anyway), and ebp one could be found in regs.ecx. So yes, we can do it that way, but... how to tell what variant had been triggered? Examining two bytes prior to user eip? Sounds bloody brittle... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QvuAF-0006nm-6E for user-mode-linux-devel@lists.sourceforge.net; Tue, 23 Aug 2011 16:49:23 +0000 Received: from zeniv.linux.org.uk ([195.92.253.2]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1QvuAB-0002kn-W1 for user-mode-linux-devel@lists.sourceforge.net; Tue, 23 Aug 2011 16:49:21 +0000 Date: Tue, 23 Aug 2011 17:48:49 +0100 From: Al Viro Message-ID: <20110823164849.GF2203@ZenIV.linux.org.uk> References: <4E52D280.3010107@zytor.com> <20110823000314.GW2203@ZenIV.linux.org.uk> <4E52EF2A.8060608@zytor.com> <20110823010146.GY2203@ZenIV.linux.org.uk> <20110823011312.GZ2203@ZenIV.linux.org.uk> <20110823021717.GA2203@ZenIV.linux.org.uk> <20110823061531.GC2203@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: The user-mode Linux development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: user-mode-linux-devel-bounces@lists.sourceforge.net Subject: Re: [uml-devel] SYSCALL, ptrace and syscall restart breakages (Re: [RFC] weird crap with vdso on uml/i386) To: Linus Torvalds Cc: Andrew Lutomirski , "user-mode-linux-devel@lists.sourceforge.net" , Richard Weinberger , "linux-kernel@vger.kernel.org" , Borislav Petkov , "mingo@redhat.com" , "H. Peter Anvin" , Ingo Molnar On Tue, Aug 23, 2011 at 09:03:04AM -0700, Linus Torvalds wrote: > Suggested fixes: > > - instead of blindly doing SETREGS, just write the result registers > individually like you suggested Not enough. There is also a PITA with signal handlers. There we can't avoid modifying ebp on the way out of handler (i.e. by emulated sigreturn). And it lands us straight after syscall insn, with ebp "restored" to the wrong value. > OR (and perhaps preferably): > > - teach UML that when you do 'GETREGS' after a system call trapped, > we have switched things around to match the "official system call > order", and UML should just undo our swizzling, and do a "regs.ebp = > regs.ecx" to make it be what the actual original registers were (or > whatever the actual correct swizzle is - I didn't think that through > very much). Um... How would it know which syscall variant had that been, to start with? For int 0x80 it would need to use registers as-is. For SYSENTER it also could use them as-is - ebp will differ from what we put there when entering the sucker, but not critically so; on the way out of syscall we'll overwrite it anyway immediately (either by pop or mov). For SYSCALL... we don't really care about ecx contents prior to entering the kernel (and it'll be blown out anyway), and ebp one could be found in regs.ecx. So yes, we can do it that way, but... how to tell what variant had been triggered? Examining two bytes prior to user eip? Sounds bloody brittle... ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel