[PATCH] fix bad syscall on ARM architecture

Denys Vlasenko dvlasenk at redhat.com
Fri Feb 20 22:20:40 UTC 2009


On Fri, 2009-02-20 at 13:23 +0100, Hans-Christian Egtvedt wrote:
> Hi,
> 
> The attached patch fixes a bad syscall on ARM architecture. I am not
> the author, but this patch has been living inside Buildroot [0] for a
> while, so IMHO should be added upstream if it actually fixes a problem.
> 
> The original commit message for the patch was "add fix for ARM fake
> syscall from execve.". Patch added by aldot at uclibc.org.

--- a/syscall.c
+++ b/syscall.c
@@ -1060,6 +1060,14 @@ get_scno(struct tcb *tcp)
                /*
                 * Note: we only deal with only 32-bit CPUs here.
                 */
+
+               if (!(tcp->flags & TCB_INSYSCALL) &&
+                   (tcp->flags & TCB_WAITEXECVE)) {
+                       /* caught a fake syscall from the execve's exit */
+                       tcp->flags &= ~TCB_WAITEXECVE;
+                       return 0;
+               }
+
                if (regs.ARM_cpsr & 0x20) {



But this is already checked a bit earlier. Here is a bigger fragment.
Look as the second "if":

        /*
         * We only need to grab the syscall number on syscall entry.
         */
        if (regs.ARM_ip == 0) {
                if (!(tcp->flags & TCB_INSYSCALL)) {
                        /* Check if we return from execve. */
                        if (tcp->flags & TCB_WAITEXECVE) {
                                tcp->flags &= ~TCB_WAITEXECVE;
                                return 0;
                        }
                }

                /*
                 * Note: we only deal with only 32-bit CPUs here.
                 */
                if (regs.ARM_cpsr & 0x20) {
                        /*
                         * Get the Thumb-mode system call number
                         */
                        scno = regs.ARM_r7;
                } else {
                        /*
                         * Get the ARM-mode system call number
                         */
                        errno = 0;
                        scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(regs.ARM_pc - 4), NULL);
                        if (errno)
                                return -1;

                        if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
                                tcp->flags &= ~TCB_WAITEXECVE;
                                return 0;
                        }


--
vda






More information about the Strace-devel mailing list