]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
genksyms: fix syntax error for attribute after 'struct'
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 13 Jan 2025 15:00:52 +0000 (00:00 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 18 Jan 2025 00:11:47 +0000 (09:11 +0900)
commit82db1c29103ebf581484c0b30805e68726121dcb
treefb7f1c95b4ffbd4e89246a67a752d8b60b1ee0dc
parent2ac068cb0b366c61e7aebaccf0240eae8b2c1b43
genksyms: fix syntax error for attribute after 'struct'

A longstanding issue with genksyms is that it has hidden syntax errors.

When a syntax error occurs, yyerror() is called. However,
error_with_pos() is a no-op unless the -w option is provided.

You can observe syntax errors by manually passing the -w option.

For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:

    $ make -s KCFLAGS=-D__GENKSYMS__ arch/x86/kernel/cpu/mshyperv.i
    $ cat arch/x86/kernel/cpu/mshyperv.i | scripts/genksyms/genksyms -w
        [ snip ]
    ./arch/x86/include/asm/svm.h:122: syntax error

The syntax error occurs in the following code in arch/x86/include/asm/svm.h:

    struct __attribute__ ((__packed__)) vmcb_control_area {
            [ snip ]
    };

The issue arises from __attribute__ immediately after the 'struct'
keyword.

This commit allows the 'struct' keyword to be followed by attributes.

The lexer must be adjusted because dont_want_brace_phase should not be
decremented while processing attributes.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Nicolas Schier <n.schier@avm.de>
scripts/genksyms/lex.l
scripts/genksyms/parse.y