Hi, all

If the CONFIG_MODVERSIONS is selected, and kernel module looks like,
        /* hello.c */
        #include <linux/module.h>
        #include <linux/kernel.h>
        #include <linux/init.h>
        #include "foo.h"
        
        typedef int (*foo)(int);
        
        int test(void)
        {
                return 0;
        }
        EXPORT_SYMBOL(test);
                
        static int __init hello_init(void)
        {
                return 0;
        }
        
        static void __exit hello_exit(void)
        {
                return;
        }
        
        module_init(hello_init);
        module_exit(hello_exit);
        MODULE_LICENSE("GPL");

and foo.h is:
        /* foo.h */
        typedef int (*foo)(int);

When compiling, we get the following message:

/bin/sh: line 1: 100777 Done                    arm-linux-gnueabi-gcc -E 
-D__GENKSYMS__ -Wp,-MD,/home/shyodx/test/.hello.o.d -nostdinc \
-isystem 
/opt/x86_64-linux/usr/bin/arm-linux-gnueabi/../../lib/arm-linux-gnueabi/gcc/arm-linux-gnueabi/4.7.1/include
 \
-I/home/shyodx/kernel/arch/arm/include -Iarch/arm/include/generated -Iinclude 
-I/home/shyodx/kernel/arch/arm/include/uapi -Iarch/arm/include/generated/uapi \
-I/home/shyodx/kernel/include/uapi -Iinclude/generated/uapi -include 
/home/shyodx/kernel/include/linux/kconfig.h -D__KERNEL__ -mlittle-endian \
-Iarch/arm/mach-hisi/include -Iarch/arm/hal/include -Wall -Wundef 
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration -Wno-format-security 
-fno-delete-null-pointer-checks -DSVN_LAST_CHANGED_REV=0000 -Os 
-Wno-maybe-uninitialized \
-fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables 
-marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm \
-Wframe-larger-than=512 -fno-stack-protector -Wno-unused-but-set-variable 
-fomit-frame-pointer -fno-var-tracking-assignments -g \
-Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow 
-fconserve-stack -DCC_HAVE_ASM_GOTO -DMODULE -D"KBUILD_STR(s)=#s" \
-D"KBUILD_BASENAME=KBUILD_STR(hello)" -D"KBUILD_MODNAME=KBUILD_STR(hello)" 
/home/shyodx/test/hello.c
     100778 Segmentation fault      | scripts/genksyms/genksyms -r /dev/null > 
/home/shyodx/test/.tmp_hello.ver
make[2]: *** [/home/shyodx/test/hello.o] Error 139
make[1]: *** [_module_/home/shyodx/test/] Error 2
make[1]: Leaving directory `/home/shyodx/kernel'
make: *** [all] Error 2

>From the above error message, it's hard to tell what is wrong in the code.
This is caused in add_symbol(), whose first argument is NULL and type is
SYM_TYPEDEF, and the next crc32() will trigger segmentation fault. So we
check if the first argument is NULL before using it. Then we could get the
gcc error message.

Sheng Yong (1):
  genksyms: fix segmentation fault when parsing redefinition of typedef

 scripts/genksyms/genksyms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to