genksyms: Fix segfault with invalid declarations

commit d920f7c6628c63a390009c237fb80a203c2e400a upstream.

Do not try to recover too early and segfault when parsing invalid
declarations such as

echo 'int (int);' | scripts/genksyms/genksyms
echo 'int a, (int);' | scripts/genksyms/genksyms
echo 'extern void *__inline_memcpy((void *), (const void *), (__kernel_size_t));' | scripts/genksyms/genksyms

The last one was a real-life bug with
include/asm-generic/asm-prototypes.h on x86_64.

Reported-and-tested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Michal Marek <mmarek@suse.com>
[arnd: rebase to 4.4, regenerate parse.tab.{c,h}]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Michal Marek 2018-02-20 12:55:01 +01:00 committed by Greg Kroah-Hartman
parent 5381db24f6
commit d93cf73400
3 changed files with 848 additions and 959 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 2.7. */ /* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -30,89 +30,76 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED #ifndef YY_YY_PARSE_TAB_H_INCLUDED
# define YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED # define YY_YY_PARSE_TAB_H_INCLUDED
/* Enabling traces. */ /* Debug traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG 1 # define YYDEBUG 0
#endif #endif
#if YYDEBUG #if YYDEBUG
extern int yydebug; extern int yydebug;
#endif #endif
/* Tokens. */ /* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers enum yytokentype
know about them. */ {
enum yytokentype { ASM_KEYW = 258,
ASM_KEYW = 258, ATTRIBUTE_KEYW = 259,
ATTRIBUTE_KEYW = 259, AUTO_KEYW = 260,
AUTO_KEYW = 260, BOOL_KEYW = 261,
BOOL_KEYW = 261, CHAR_KEYW = 262,
CHAR_KEYW = 262, CONST_KEYW = 263,
CONST_KEYW = 263, DOUBLE_KEYW = 264,
DOUBLE_KEYW = 264, ENUM_KEYW = 265,
ENUM_KEYW = 265, EXTERN_KEYW = 266,
EXTERN_KEYW = 266, EXTENSION_KEYW = 267,
EXTENSION_KEYW = 267, FLOAT_KEYW = 268,
FLOAT_KEYW = 268, INLINE_KEYW = 269,
INLINE_KEYW = 269, INT_KEYW = 270,
INT_KEYW = 270, LONG_KEYW = 271,
LONG_KEYW = 271, REGISTER_KEYW = 272,
REGISTER_KEYW = 272, RESTRICT_KEYW = 273,
RESTRICT_KEYW = 273, SHORT_KEYW = 274,
SHORT_KEYW = 274, SIGNED_KEYW = 275,
SIGNED_KEYW = 275, STATIC_KEYW = 276,
STATIC_KEYW = 276, STRUCT_KEYW = 277,
STRUCT_KEYW = 277, TYPEDEF_KEYW = 278,
TYPEDEF_KEYW = 278, UNION_KEYW = 279,
UNION_KEYW = 279, UNSIGNED_KEYW = 280,
UNSIGNED_KEYW = 280, VOID_KEYW = 281,
VOID_KEYW = 281, VOLATILE_KEYW = 282,
VOLATILE_KEYW = 282, TYPEOF_KEYW = 283,
TYPEOF_KEYW = 283, EXPORT_SYMBOL_KEYW = 284,
EXPORT_SYMBOL_KEYW = 284, ASM_PHRASE = 285,
ASM_PHRASE = 285, ATTRIBUTE_PHRASE = 286,
ATTRIBUTE_PHRASE = 286, TYPEOF_PHRASE = 287,
TYPEOF_PHRASE = 287, BRACE_PHRASE = 288,
BRACE_PHRASE = 288, BRACKET_PHRASE = 289,
BRACKET_PHRASE = 289, EXPRESSION_PHRASE = 290,
EXPRESSION_PHRASE = 290, CHAR = 291,
CHAR = 291, DOTS = 292,
DOTS = 292, IDENT = 293,
IDENT = 293, INT = 294,
INT = 294, REAL = 295,
REAL = 295, STRING = 296,
STRING = 296, TYPE = 297,
TYPE = 297, OTHER = 298,
OTHER = 298, FILENAME = 299
FILENAME = 299 };
};
#endif #endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE; typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void); int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED */ #endif /* !YY_YY_PARSE_TAB_H_INCLUDED */

View file

@ -320,8 +320,6 @@ direct_declarator:
{ $$ = $2; } { $$ = $2; }
| '(' declarator ')' | '(' declarator ')'
{ $$ = $3; } { $$ = $3; }
| '(' error ')'
{ $$ = $3; }
; ;
/* Nested declarators differ from regular declarators in that they do /* Nested declarators differ from regular declarators in that they do