Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Unescaped spaces in module name break /proc/dynamic_debug/control 
space-delimited format
--

commit 545163420f0539e2fb3305855828cee4c4817daf
Author: Jim Cromie <[email protected]>

kbuild, dyndbg: clean up builtin module-name ambiguities

This commit changes dynamic debug to derive the module name from
KBUILD_DD_MODNAME for built-in modules to resolve ambiguities. It applies a
clean heuristic to generate subsystem namespaces based on the directory path
and module target.

> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 0a4fdd8bd975d..2d1544b30185f 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -23,6 +23,15 @@ modname_flags  = -DKBUILD_MODNAME=$(call 
> name-fix,$(modname)) \
>                -D__KBUILD_MODNAME=$(call name-fix-token,$(modname))
>  modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))
>  
> +# Dynamic debug subsystem modname with clean heuristic and Makefile override 
> support
> +dd_modname_override = $(firstword $(DD_MODNAME_$(target-stem).o) 
> $(DD_MODNAME))
> +dd_obj := $(patsubst drivers/%,%,$(obj))
> +dd_modname_default = $(if $(filter $(notdir 
> $(dd_obj)),$(__modname)),$(dd_obj),$(addprefix $(dd_obj)/,$(__modname)))
> +dd_modname = $(if 
> $(dd_modname_override),$(dd_modname_override),$(dd_modname_default))
> +dd_modname_flags = -DKBUILD_DD_MODNAME=$(call stringify,$(dd_modname))

[Severity: High]
Does this Makefile definition correctly handle spaces in $(__modname)?

When an object file is shared by multiple built-in modules, kbuild populates
$(__modname) with a space-separated list of module names (e.g., "mod1 mod2").
The dd_modname_default definition above prepends the path, resulting in a
string with spaces like "dir/mod1 dir/mod2".

Because dd_modname_flags directly stringifies this into KBUILD_DD_MODNAME
without substituting the spaces with colons or other safe characters, this
string gets printed directly into the /proc/dynamic_debug/control file by
ddebug_proc_show():

lib/dynamic_debug.c:ddebug_proc_show() {
    ...
    seq_printf(m, "%s:%u [%s]%s =%s \"",
               trim_prefix(dp->filename), dp->lineno,
               iter->table->mod_name, dp->function,
               ddebug_describe_flags(dp->flags, &flags));
    ...
}

Will this unescaped space add an extra column and break the documented
space-delimited format of /proc/dynamic_debug/control, causing ABI breakage
for userspace parsing tools?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=18

Reply via email to