From patchwork Wed Sep 9 18:13:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 46422 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n89IDL2B018893 for ; Wed, 9 Sep 2009 18:13:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753642AbZIISNS (ORCPT ); Wed, 9 Sep 2009 14:13:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753805AbZIISNS (ORCPT ); Wed, 9 Sep 2009 14:13:18 -0400 Received: from mail-bw0-f219.google.com ([209.85.218.219]:55719 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753642AbZIISNR (ORCPT ); Wed, 9 Sep 2009 14:13:17 -0400 Received: by bwz19 with SMTP id 19so622253bwz.37 for ; Wed, 09 Sep 2009 11:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=q2I4FUv58S47f6S7tvTSrCGwpQtOUDmWR/KMBb94Osc=; b=bRUWDdK9meOuE/QyVogiuRtQNhpgeRlc9iqk2m4gsC64AFzfkYHZW264+fNcmM/OvM 9+CrMc927LfeptO2Rl0JMeoA4SOR8RR0+EZ1oTbUbS28bHVqqEncMknEJ1H/n+qYB63a rKRzYK9MZ8rsVJyD8DjzIOrTGk3H5y06Oujvo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=K8GnoX3Q6HAyVDgcIEUDt6eK/QARSYUCEZBQqIuVNW+Wz/wmF6NzV0CqEtRW0fRqMX ZvF6X9pKiHBOOK38VtUGF+u4j0jUUE+WBASpHwkjfNNrF+rqDzEMSfnQZCk4y9nCerRf /sh8qWILa4aIw1Q7Rn1fiNPFiBBAkXHz98Y0o= MIME-Version: 1.0 Received: by 10.204.34.9 with SMTP id j9mr36103bkd.10.1252519999522; Wed, 09 Sep 2009 11:13:19 -0700 (PDT) Date: Wed, 9 Sep 2009 14:13:19 -0400 X-Google-Sender-Auth: 0797e1ed57a0a34b Message-ID: <119aab440909091113jc5dc5f0m33f3be60bdd13eb5@mail.gmail.com> Subject: [PATCH] hppa: Avoid manipulating function pointers from a traced process. From: "Carlos O'Donell" To: strace-devel@lists.sourceforge.net, linux-parisc Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org Architectures using function pointers, like hppa, may need to manipulate the function pointer to compute the result of a comparison. However, the SA_HANDLER function pointer exists only in the address space of the traced process, and can't be manipulated by strace. In order to prevent the compiler from generating code to manipulate SA_HANDLER we cast the function pointers to long. Please apply. Cheers, Carlos. ~~~ Fix function pointer comparison for hppa. * signal.c (sys_sigaction): Cast function pointers to long. (sys_rt_sigaction): Cast function pointers to long. diff --git a/signal.c b/signal.c index 76504f6..7ce4809 100644 --- a/signal.c +++ b/signal.c @@ -1121,11 +1121,19 @@ struct tcb *tcp; else if (umove(tcp, addr, &sa) < 0) tprintf("{...}"); else { - if (sa.SA_HANDLER == SIG_ERR) + /* Architectures using function pointers, like + * hppa, may need to manipulate the function pointer + * to compute the result of a comparison. However, + * the SA_HANDLER function pointer exists only in + * the address space of the traced process, and can't + * be manipulated by strace. In order to prevent the + * compiler from generating code to manipulate + * SA_HANDLER we cast the function pointers to long. */ + if ((long)sa.SA_HANDLER == (long)SIG_ERR) tprintf("{SIG_ERR, "); - else if (sa.SA_HANDLER == SIG_DFL) + else if ((long)sa.SA_HANDLER == (long)SIG_DFL) tprintf("{SIG_DFL, "); - else if (sa.SA_HANDLER == SIG_IGN) { + else if ((long)sa.SA_HANDLER == (long)SIG_IGN) { #ifndef USE_PROCFS if (tcp->u_arg[0] == SIGTRAP) { tcp->flags |= TCB_SIGTRAPPED; @@ -1931,12 +1939,19 @@ sys_rt_sigaction(struct tcb *tcp) tprintf("{...}"); goto after_sa; } - - if (sa.__sa_handler == SIG_ERR) + /* Architectures using function pointers, like + * hppa, may need to manipulate the function pointer + * to compute the result of a comparison. However, + * the SA_HANDLER function pointer exists only in + * the address space of the traced process, and can't + * be manipulated by strace. In order to prevent the + * compiler from generating code to manipulate + * SA_HANDLER we cast the function pointers to long. */ + if ((long)sa.__sa_handler == (long)SIG_ERR) tprintf("{SIG_ERR, "); - else if (sa.__sa_handler == SIG_DFL) + else if ((long)sa.__sa_handler == (long)SIG_DFL) tprintf("{SIG_DFL, "); - else if (sa.__sa_handler == SIG_IGN) + else if ((long)sa.__sa_handler == (long)SIG_IGN) tprintf("{SIG_IGN, "); else tprintf("{%#lx, ", (long) sa.__sa_handler);