lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9804c32-9ba2-493b-bfb8-a6ac4f108175@intel.com>
Date: Thu, 11 Apr 2024 13:14:20 +0200
From: Przemek Kitszel <przemyslaw.kitszel@...el.com>
To: Alexander Lobakin <aleksander.lobakin@...el.com>, Jonathan Corbet
	<corbet@....net>
CC: Kees Cook <keescook@...omium.org>, Jakub Kicinski <kuba@...nel.org>, "Dan
 Williams" <dan.j.williams@...el.com>, "Gustavo A. R. Silva"
	<gustavoars@...nel.org>, Keith Packard <keithp@...thp.com>,
	<nex.sw.ncis.osdt.itp.upstreaming@...el.com>, <linux-doc@...r.kernel.org>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel-doc: fix struct_group_tagged() parsing

On 4/11/24 11:32, Alexander Lobakin wrote:
> From: Kees Cook <keescook@...omium.org>
> 
> kernel-doc emits a warning on struct_group_tagged() if you describe your
> struct group member:
> 
> include/net/libeth/rx.h:69: warning: Excess struct member 'fp' description in 'libeth_fq'
> 
> The code:
> 
> /**
>   * struct libeth_fq - structure representing a buffer queue
>   * @fp: hotpath part of the structure
>   * @pp: &page_pool for buffer management
> [...]
>   */
> struct libeth_fq {
> 	struct_group_tagged(libeth_fq_fp, fp,
> 		struct page_pool	*pp;
> [...]
> 	);
> 
> When a struct_group_tagged() is encountered, we need to build a
> `struct TAG NAME;` from it, so that it will be treated as a valid
> embedded struct.
> Decouple the regex and do the replacement there. As far as I can see,
> this doesn't produce any new warnings on the current mainline tree.
> 
> Reported-by: Jakub Kicinski <kuba@...nel.org>
> Closes: https://lore.kernel.org/netdev/20240405212513.0d189968@kernel.org
> Fixes: 50d7bd38c3aa ("stddef: Introduce struct_group() helper macro")
> Signed-off-by: Kees Cook <keescook@...omium.org>
> Co-developed-by: Alexander Lobakin <aleksander.lobakin@...el.com>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@...el.com>
> ---
>   scripts/kernel-doc | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 43a30f2de513..01ac8f794b30 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -1152,7 +1152,8 @@ sub dump_struct($$) {
>           # - first eat non-declaration parameters and rewrite for final match
>           # - then remove macro, outer parens, and trailing semicolon
>           $members =~ s/\bstruct_group\s*\(([^,]*,)/STRUCT_GROUP(/gos;
> -        $members =~ s/\bstruct_group_(attr|tagged)\s*\(([^,]*,){2}/STRUCT_GROUP(/gos;
> +        $members =~ s/\bstruct_group_attr\s*\(([^,]*,){2}/STRUCT_GROUP(/gos;
> +        $members =~ s/\bstruct_group_tagged\s*\(([^,]*),([^,]*),/struct $1 $2; STRUCT_GROUP(/gos;
>           $members =~ s/\b__struct_group\s*\(([^,]*,){3}/STRUCT_GROUP(/gos;
>           $members =~ s/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/$2/gos;
>   

I would complain on code that matches `[^,]*` part with 0 characters,
meaning no tag for struct_group_tagged(), or no attrs for
struct_group_attrs(). In such cases simpler struct_group() call should
be suggested. However, that issue was presented prior to your patch.

This is clearly an improvement, so:
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ