Re: ptrace single-stepping change breaks Wine

From: Linus Torvalds (torvalds_at_osdl.org)
Date: 11/21/04

  • Next message: Linus Torvalds: "Re: sparse segfaults"
    Date:	Sun, 21 Nov 2004 14:33:32 -0800 (PST)
    To: Davide Libenzi <davidel@xmailserver.org>
    
    

    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 <signal.h>
            #include <sys/mman.h>

            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/


  • Next message: Linus Torvalds: "Re: sparse segfaults"

    Relevant Pages

    • Re: SiS ISA bridge IRQ routing on 2.6 ...
      ... On Mer, 2003-10-29 at 19:27, Davide Libenzi wrote: ... > Alan did not like my approach, so I'll let him post to Linus his work. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [patch] signal handler defaulting fix ...
      ... during the delivery disables the signal. ... Then when the signal handler ... again, the kernel does not honor the existing handler, but it reset to ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Add pselect, ppoll system calls.
      ... sure that the signal handler should be called. ... version of my program on Solaris 10 or the Unix-03 conversion of AIX ... I'd say the behaviour should in fact be like what sigsuspend() does. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] PPC32: cancel syscall restart on signal delivery
      ... > You're missing that the only thing that ever looks at restart_block is the ... that can get changed by the signal handler. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [BUG] in copy_siginfo_to_user32 on ppc64 (and others?) in 2.6.9/2.6.10
      ... the problems that I had tracking it down. ... different based on whether I used a signal handler in the regular way, ... then copied the results to the userspace struct using ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)