Re: [PATCH] genksyms: Fix parsing a declarator with a preceding attribute

From: sun jian

Date: Wed Feb 25 2026 - 23:36:26 EST


On Thu, Feb 26, 2026 at 6:07 AM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> After commit 07919126ecfc ("netfilter: annotate NAT helper hook pointers
> with __rcu"), genksyms fails to parse the __rcu annotation when building
> with CONFIG_DEBUG_INFO_BTF=y, CONFIG_PAHOLE_HAS_BTF_TAG=y, and a version
> of clang that supports btf_type_tag.

Hi Nathan,

Thanks for tracking this down and for the minimal reproducer.

I've noticed the same thing while building on my laptop during MODPOST
Module.symvers:

WARNING: modpost: EXPORT symbol "nf_nat_ftp_hook" [vmlinux] version
generation failed, symbol will not be versioned.
Is "nf_nat_ftp_hook" prototyped in <asm/asm-prototypes.h>?
WARNING: modpost: EXPORT symbol "nf_nat_irc_hook" [vmlinux] version
generation failed, symbol will not be versioned.
Is "nf_nat_irc_hook" prototyped in <asm/asm-prototypes.h>?

>
> diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
> index efdcf07c4eb6..cabcd146f3aa 100644
> --- a/scripts/genksyms/parse.y
> +++ b/scripts/genksyms/parse.y
> @@ -325,8 +325,8 @@ direct_declarator:
> { $$ = $4; }
> | direct_declarator BRACKET_PHRASE
> { $$ = $2; }
> - | '(' declarator ')'
> - { $$ = $3; }
> + | '(' attribute_opt declarator ')'
> + { $$ = $4; }
> ;
>

Your grammar tweak to allow an optional attribute before the nested
declarator looks correct to me.

Best regards,
Sun Jian