mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix RELOC_HIDE miscompilation
@ 2002-09-01  9:42 Andi Kleen
  2002-09-02  2:11 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2002-09-01  9:42 UTC (permalink / raw)
  To: torvalds, linux-kernel, Paul.Russell


[resend due to mailer problems]

RELOC_HIDE got miscompiled on gcc3.1/x86-64 in the access to softirq.c's per 
cpu variables.  This patch fixes the problem.

Clearly to hide the relocation the addition needs to be done after the 
value obfuscation, not before.

I don't know if it triggers on other architectures (x86-64 is especially 
stressf here because it has negative kernel addresses), but seems like the 
right thing to do.

Also does the arithmetic in unsigned long to avoid undue assumptions of the 
comp for pointers.

-Andi

--- linux/include/linux/compiler.h-o	Sun Apr 14 21:18:44 2002
+++ linux/include/linux/compiler.h	Sun Sep  1 02:52:31 2002
@@ -16,7 +16,7 @@
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\
-  ({ __typeof__(ptr) __ptr;					\
-    __asm__ ("" : "=g"(__ptr) : "0"((void *)(ptr) + (off)));	\
-    __ptr; })
+  ({ unsigned long __ptr;					\
+    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+    (typeof(ptr)) (__ptr + (off)); })
 #endif /* __LINUX_COMPILER_H */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix RELOC_HIDE miscompilation
  2002-09-01  9:42 [PATCH] Fix RELOC_HIDE miscompilation Andi Kleen
@ 2002-09-02  2:11 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2002-09-02  2:11 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, linux-kernel

In message <20020901114242.21242@colin.muc.de> you write:
> 
> [resend due to mailer problems]
> 
> RELOC_HIDE got miscompiled on gcc3.1/x86-64 in the access to softirq.c's per 
> cpu variables.  This patch fixes the problem.
> 
> Clearly to hide the relocation the addition needs to be done after the 
> value obfuscation, not before.
> 
> I don't know if it triggers on other architectures (x86-64 is especially 
> stressf here because it has negative kernel addresses), but seems like the 
> right thing to do.

Yes, agreed.  Linus, please apply.

--- linux/include/linux/compiler.h-o	Sun Apr 14 21:18:44 2002
+++ linux/include/linux/compiler.h	Sun Sep  1 02:52:31 2002
@@ -16,7 +16,7 @@
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\
-  ({ __typeof__(ptr) __ptr;					\
-    __asm__ ("" : "=g"(__ptr) : "0"((void *)(ptr) + (off)));	\
-    __ptr; })
+  ({ unsigned long __ptr;					\
+    __asm__ ("" : "=g"(__ptr) : "0"(ptr));		\
+    (typeof(ptr)) (__ptr + (off)); })
 #endif /* __LINUX_COMPILER_H */

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-02  2:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-01  9:42 [PATCH] Fix RELOC_HIDE miscompilation Andi Kleen
2002-09-02  2:11 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®