Re: [PATCH v7 20/29] dyndbg: refactor param_set_dyndbg_classes and below
[email protected] Thu, 23 Jul 2026 12:44:27 -0600
| Newsgroups | org.kernel.vger.linux-modules,dev.linux.lists.sashiko-reviews,org.freedesktop.lists.dri-devel |
|---|---|
| Message-ID | <CAJfuBxzqPPui3TRsyncnbS_CLyyh6pU2=1mkO=JsPEVwa_v9Rg@mail.gmail.com> |
On Tue, Jul 21, 2026 at 3:11=E2=80=AFPM <[email protected]> wrote: > > Thank you for your contribution! Sashiko AI review found 1 potential issu= e(s) to consider: > - [Medium] The refactored `param_set_dyndbg_module_classes` is structural= ly incapable of correctly applying existing global classmap settings to new= ly loaded modules, and it corrupts the global state. > -- > > --- Patch [20]: [PATCH v7 20/29] dyndbg: refactor param_set_dyndbg_classe= s and below --- > commit fd7e6888285afde6b911cef67e7e2452e7180dba > Author: Jim Cromie <[email protected]> > > dyndbg: refactor param_set_dyndbg_classes and below > > This commit refactors the param_set_dyndbg_classes callchain to support > module-specific classmap updates, primarily intended for modprobe handlin= g. > It splits the function into upper and lower parts, threading a modname > parameter through to ddebug_exec_queries. It also adds a check in > ddebug_apply_class_bitmap to skip printing if bits haven't changed. > > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > > index f66e5373e61e2..a619cefd801f7 100644 > > --- a/lib/dynamic_debug.c > > +++ b/lib/dynamic_debug.c > [ ... ] > > @@ -625,7 +626,9 @@ static int ddebug_apply_class_bitmap(const struct d= debug_class_param *dcp, > > int matches =3D 0; > > int bi, ct; > > > > - v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); > > + if (*new_bits !=3D *old_bits) > > + v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_= bits, > > + *old_bits, query_modname ?: "'*'"); > > > > for (bi =3D 0; bi < map->length; bi++) { > > if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) > > continue; > > [Severity: Medium] > When applying the current global state to a newly probed module, will thi= s > continue statement incorrectly skip all configuration queries? this is a param callback. the modprobe has finished, and the modprobe args setting classmaps are already done. the param-callback only handles param updates > Since old_bits represents the global state, test_bit() will evaluate to t= rue > when applying the same global configuration to a new module, silently > skipping required query updates. > > > snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_n= ames[bi], > > test_bit(bi, new_bits) ? '+' : '-', dcp->flags); > > > [ ... ] > > @@ -683,8 +693,8 @@ int param_set_dyndbg_classes(const char *instr, con= st struct kernel_param *kp) > > KP_NAME(kp), inrep, CLASSMAP_BITMASK(map-= >length)); > > inrep &=3D CLASSMAP_BITMASK(map->length); > > } > > - v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); > > - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bi= ts); > > + v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*",= KP_NAME(kp)); > > + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bi= ts, mod_name); > > *dcp->bits =3D inrep; > > [Severity: Medium] > Does this code inadvertently corrupt the global state if a module-specifi= c > override is applied? the param belongs to a module, its not "global". and I dont know what override means here. the callback MUST update the internal state, or error out. > It appears that *dcp->bits (the global parameter state) is unconditionall= y > overwritten with inrep, even when a mod_name is provided. the param belongs to a module. so does the param state. > Should the state update be conditional on mod_name being NULL, to prevent > modprobe handling from modifying the global state? > > > break; > > case DD_CLASS_TYPE_LEVEL_NUM: > > @@ -697,7 +707,7 @@ int param_set_dyndbg_classes(const char *instr, con= st struct kernel_param *kp) > > old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); > > new_bits =3D CLASSMAP_BITMASK(inrep); > > v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, K= P_NAME(kp)); > > - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old= _bits); > > + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old= _bits, mod_name); > > *dcp->lvl =3D inrep; > > [Severity: Medium] > Similarly, is the global *dcp->lvl state unconditionally overwritten here > when a module-specific override is applied for LEVEL_NUM map types? the state belongs to the module. > > > break; > > default: > > -- > Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260721-dd-maint= [email protected]?part=3D20