Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261824AbUKUWeM (ORCPT ); Sun, 21 Nov 2004 17:34:12 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261825AbUKUWeM (ORCPT ); Sun, 21 Nov 2004 17:34:12 -0500 Received: from fw.osdl.org ([65.172.181.6]:481 "EHLO mail.osdl.org") by vger.kernel.org with ESMTP id S261824AbUKUWeB (ORCPT ); Sun, 21 Nov 2004 17:34:01 -0500 Date: Sun, 21 Nov 2004 14:33:32 -0800 (PST) From: Linus Torvalds To: Davide Libenzi cc: Daniel Jacobowitz , Eric Pouech , Roland McGrath , Mike Hearn , Linux Kernel Mailing List , Andrew Morton , wine-devel Subject: Re: ptrace single-stepping change breaks Wine In-Reply-To: Message-ID: References: <200411152253.iAFMr8JL030601@magilla.sf.frob.com> <419E42B3.8070901@wanadoo.fr> <419E4A76.8020909@wanadoo.fr> <419E5A88.1050701@wanadoo.fr> <20041119212327.GA8121@nevyn.them.org> <20041120214915.GA6100@tesore.ph.cox.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1482 Lines: 62 On Sun, 21 Nov 2004, Davide Libenzi wrote: > > I'd agree with Linus here. A signal handler is part of the application, so > it should be single stepped in the same way other application code does. > My original patch simply reenabled the flag before returning to userspace, > and this had the consequence to single step into signal handlers too. Hmmm.. I think I may have a test-case for the problem. Lookie here: #include #include void function(void) { printf("Copy protected: ok\n"); } void handler(int signo) { extern char smc; smc++; } #define TF 0x100 int main(int argc, char **argv) { void (*fnp)(void); signal(SIGTRAP, handler); mprotect((void *)(0xfffff000 & (unsigned long)main), 4096, PROT_READ | PROT_WRITE); asm volatile("pushfl ; orl %0,(%%esp) ; popfl" : :"i" (TF):"memory"); asm volatile("pushfl ; andl %0,(%%esp) ; popfl" : :"i" (~TF):"memory"); asm volatile("\nsmc:\n\t" ".byte 0xb7\n\t" ".long function" :"=d" (fnp)); fnp(); exit(1); } Compile it, run it, and it should say Copy protected: ok Now, try to "strace" it, or debug it with gdb, and see if you can repeat the behaviour. Roland? Think of it as a challenge, Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/