Re: [PATCH] hppa: Avoid manipulating function pointers from a traced process.

2009-09-14 Thread Dmitry V. Levin
On Wed, Sep 09, 2009 at 02:13:19PM -0400, Carlos O'Donell wrote:
 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.

The change looks harmless for other architectures, so OK for me.


-- 
ldv


pgpgV6AbMeCNa.pgp
Description: PGP signature
--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH] hppa: Avoid manipulating function pointers from a traced process.

2009-09-09 Thread Carlos O'Donell
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);
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel