Re: inline_hunter 0.2 and it's results

From: Denis Vlasenko
Date: Wed Apr 21 2004 - 01:37:19 EST


> disasm, diff of
> void inline_copy_from_user_3(void) { copy_from_user(0,0,0); }
> yields:
>
> --- copy_from_user_43 Tue Apr 20 23:40:07 2004
> +++ copy_from_user_56 Tue Apr 20 23:41:23 2004
> @@ -11,11 +11,16 @@
> 39 5a 18 cmp %ebx,0x18(%edx)
> 83 d9 00 sbb $0x0,%ecx
> 85 c9 test %ecx,%ecx
> - 75 0b jne XXXX <inline_copy_from_user_3+0x28>
> + 75 0d jne XXXX <inline_copy_from_user_3+0x2a>
> 31 c9 xor %ecx,%ecx
> 31 d2 xor %edx,%edx
> 31 c0 xor %eax,%eax
> e8 fc ff ff ff call XXXX <inline_copy_from_user_3+0x24>
> + eb 0b jmp XXXX <inline_copy_from_user_3+0x35>
> + 31 c9 xor %ecx,%ecx
> + 31 d2 xor %edx,%edx
> + 31 c0 xor %eax,%eax
> + e8 4f 01 00 00 call XXXX <__constant_c_and_count_memset>
> 5b pop %ebx
> c9 leave
> c3 ret
>
> oops... we've got files which do not honor 'inline' on
> __constant_c_and_count_memset()! For example,
>
> fs/open.c:
> ==========
> #include <linux/string.h>
> this pulls __constant_c_and_count_memset()
> #include <linux/mm.h>
> this pulls <compiler.h>, re#defining
> inline == __inline__ __attribute__((always_inline)).
> too late!
> #include <linux/utime.h>
>
> Will do patch tomorrow.

All affected files #include strings.h
This should fix it. Untested.
--
vdadiff -urN linux-2.6.5/include/linux/string.h linux-2.6.5.fixed_includes/include/linux/string.h
--- linux-2.6.5/include/linux/string.h Sun Apr 4 06:36:56 2004
+++ linux-2.6.5.fixed_includes/include/linux/string.h Wed Apr 21 09:17:32 2004
@@ -5,6 +5,7 @@

#ifdef __KERNEL__

+#include <linux/compiler.h> /* for inline */
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */