From: sashiko-bot@kernel.org
To: "Jim Cromie" <jim.cromie@gmail.com>
Cc: linux-modules@vger.kernel.org
Subject: Re: [PATCH v2 19/24] dyndbg,module: make proper substructs in _ddebug_info
Date: Sat, 23 May 2026 07:45:08 +0000 [thread overview]
Message-ID: <20260523074509.543791F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260523-dd-maint-2-v2-19-b937312aa083@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Module loader searches for incorrectly named dynamic debug sections, completely disabling dynamic debug for all loadable modules.
- [High] Built-in modules without class maps erroneously inherit all global system-wide class maps due to missing state reset.
- [Low] Renaming `struct ddebug_class_param` breaks compilation of external users like the DRM subsystem.
--
commit 647ef6a50774bbbe7f638336c42ae9d912b4ca12
Author: Jim Cromie <jim.cromie@gmail.com>
dyndbg,module: make proper substructs in _ddebug_info
This commit recomposes struct _ddebug_info by moving the descriptors and class
maps fields into new sub-structures struct _ddebug_descs and struct
_ddebug_class_maps. It also normalizes all related struct names to use a
_ddebug_ prefix.
> diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> index a84dcc127e5a7..001bc84eadcab 100644
> --- a/include/linux/dynamic_debug.h
> +++ b/include/linux/dynamic_debug.h
[ ... ]
> @@ -81,21 +81,33 @@ struct ddebug_class_map {
> enum ddebug_class_map_type map_type;
> };
>
> -/* encapsulate linker provided built-in (or module) dyndbg data */
> +/*
> + * @_ddebug_info: gathers module/builtin dyndbg_* __sections together.
> + * For builtins, it is used as a cursor, with the inner structs
> + * marking sub-vectors of the builtin __sections in DATA.
> + */
> +struct _ddebug_descs {
> + struct _ddebug *start;
> + unsigned int len;
> +};
> +
> +struct _ddebug_class_maps {
> + struct _ddebug_class_map *start;
> + unsigned int len;
> +};
> +
> struct _ddebug_info {
> - struct _ddebug *descs;
> - struct ddebug_class_map *classes;
> - unsigned int num_descs;
> - unsigned int num_classes;
> + struct _ddebug_descs descs;
> + struct _ddebug_class_maps maps;
> };
>
> -struct ddebug_class_param {
> +struct _ddebug_class_param {
[Severity: Low]
Does renaming this structure break compilation for external users?
For example, the DRM subsystem directly references the old structure name in
drivers/gpu/drm/drm_print.c:
"static struct ddebug_class_param drm_debug_bitmap"
Failing to update these external users will result in a build failure for
configurations enabling DRM.
> union {
> u64 *bits;
> u64 *lvl;
> };
> char flags[8];
> - const struct ddebug_class_map *map;
> + const struct _ddebug_class_map *map;
> };
>
> /*
[ ... ]
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index 46dd8d25a6058..c2b6e70f2e773 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -2774,12 +2774,12 @@ static int find_module_sections(struct module *mod, struct load_info *info)
> pr_warn("%s: Ignoring obsolete parameters\n", mod->name);
>
> #ifdef CONFIG_DYNAMIC_DEBUG_CORE
> - mod->dyndbg_info.descs = section_objs(info, "__dyndbg",
> - sizeof(*mod->dyndbg_info.descs),
> - &mod->dyndbg_info.num_descs);
> - mod->dyndbg_info.classes = section_objs(info, "__dyndbg_classes",
> - sizeof(*mod->dyndbg_info.classes),
> - &mod->dyndbg_info.num_classes);
> + mod->dyndbg_info.descs.start = section_objs(info, "__dyndbg_descriptors",
> + sizeof(*mod->dyndbg_info.descs.start),
> + &mod->dyndbg_info.descs.len);
> + mod->dyndbg_info.maps.start = section_objs(info, "__dyndbg_class_maps",
> + sizeof(*mod->dyndbg_info.maps.start),
> + &mod->dyndbg_info.maps.len);
[Severity: High]
Does this correctly match the section names emitted by the linker?
It looks like the section names here were updated to "__dyndbg_descriptors"
and "__dyndbg_class_maps", but the macros like DECLARE_DYNDBG_CLASSMAP and
DEFINE_DYNAMIC_DEBUG_METADATA still emit to "__dyndbg" and "__dyndbg_classes".
Because the strings do not match, section_objs() will fail to find the
sections, setting their lengths to 0 and effectively discarding all
dynamic debug prints for loadable modules.
I see this regression is fixed later in the series by commit f9409a020a4bc
("dyndbg: improve section names").
> #endif
>
> return 0;
[ ... ]
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 580aa258f902f..169b94ff6f8ed 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
[ ... ]
> @@ -1202,10 +1203,10 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
> {
> struct ddebug_table *dt;
>
> - if (!di->num_descs)
> + if (!di->descs.len)
> return 0;
>
> - v3pr_info("add-module: %s %d sites\n", modname, di->num_descs);
> + v3pr_info("add-module: %s %d sites\n", modname, di->descs.len);
>
> dt = kzalloc_obj(*dt);
> if (dt == NULL) {
> @@ -1219,19 +1220,18 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
> * this struct ddebug_table.
> */
> dt->mod_name = modname;
> - dt->ddebugs = di->descs;
> - dt->num_ddebugs = di->num_descs;
> + dt->info = *di;
[Severity: High]
Does this code leave dt->info.maps initialized to the entire system-wide
class maps array if the built-in module has no class maps?
In dynamic_debug_init(), the global _ddebug_info di is initialized with
.maps spanning the entire __dyndbg_classes section.
When this is copied via dt->info = *di here, dt->info.maps also spans
the entire section.
If the module has no class maps, ddebug_attach_module_classes() will run, but
the local variable nc remains 0. The block if (nc) at the end is skipped,
and dt->info.maps is never updated to reflect 0 length.
As a result, built-in modules without class maps falsely match unrelated
class maps from other built-in modules.
I see this regression is fixed later in the series by commit 6fc0ea29f4f01
("dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module").
>
> INIT_LIST_HEAD(&dt->link);
>
> - if (di->classes && di->num_classes)
> + if (di->maps.len)
> ddebug_attach_module_classes(dt, di);
>
> mutex_lock(&ddebug_lock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260523-dd-maint-2-v2-0-b937312aa083@gmail.com?part=19
next prev parent reply other threads:[~2026-05-23 7:45 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 7:14 [PATCH v2 00/24] dynamic-debug cleanups refactors maintenance + alignment fix Jim Cromie
2026-05-23 7:14 ` [PATCH v2 01/24] docs/dyndbg: update examples \012 to \n Jim Cromie
2026-05-23 7:14 ` [PATCH v2 02/24] docs/dyndbg: explain flags parse 1st Jim Cromie
2026-05-23 7:14 ` [PATCH v2 03/24] vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h Jim Cromie
2026-05-23 7:14 ` [PATCH v2 04/24] vmlinux.lds.h: drop unused HEADERED_SECTION* macros Jim Cromie
2026-05-23 7:14 ` [PATCH v2 05/24] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 Jim Cromie
2026-05-23 7:42 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 06/24] vmlinux.lds.h: remove redundant ALIGN(8) directives Jim Cromie
2026-05-23 7:14 ` [PATCH v2 07/24] dyndbg.lds.S: fix lost dyndbg sections in modules Jim Cromie
2026-05-23 7:14 ` [PATCH v2 08/24] dyndbg: factor ddebug_match_desc out from ddebug_change Jim Cromie
2026-05-23 7:14 ` [PATCH v2 09/24] dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP Jim Cromie
2026-05-23 7:14 ` [PATCH v2 10/24] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Jim Cromie
2026-05-23 7:14 ` [PATCH v2 11/24] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Jim Cromie
2026-05-23 7:33 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 12/24] dyndbg: drop NUM_TYPE_ARGS Jim Cromie
2026-05-23 7:32 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 13/24] dyndbg: reduce verbose/debug clutter Jim Cromie
2026-05-23 7:30 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 14/24] dyndbg: refactor param_set_dyndbg_classes and below Jim Cromie
2026-05-23 7:14 ` [PATCH v2 15/24] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Jim Cromie
2026-05-23 7:14 ` [PATCH v2 16/24] dyndbg: replace classmap list with an array-slice Jim Cromie
2026-05-23 7:41 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 17/24] dyndbg: macrofy a 2-index for-loop pattern Jim Cromie
2026-05-23 7:14 ` [PATCH v2 18/24] dyndbg: Upgrade class param storage to u64 for 64-bit classmaps Jim Cromie
2026-05-23 7:42 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 19/24] dyndbg,module: make proper substructs in _ddebug_info Jim Cromie
2026-05-23 7:45 ` sashiko-bot [this message]
2026-05-23 7:14 ` [PATCH v2 20/24] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Jim Cromie
2026-05-23 7:14 ` [PATCH v2 21/24] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Jim Cromie
2026-05-23 7:45 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 22/24] selftests-dyndbg: add a dynamic_debug run_tests target Jim Cromie
2026-05-23 7:37 ` sashiko-bot
2026-05-23 7:14 ` [PATCH v2 23/24] dyndbg: change __dynamic_func_call_cls* macros into expressions Jim Cromie
2026-05-23 7:14 ` [PATCH v2 24/24] dyndbg: improve section names Jim Cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260523074509.543791F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jim.cromie@gmail.com \
--cc=linux-modules@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox