Re: [PATCH v11 01/19] dyndbg: add _DPRINTK_FLAGS_ENABLED

jim.cromie
2022-01-17T22:34:01Z

On Fri, Jan 14, 2022 at 4:57 AM Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> On Fri, Jan 07, 2022 at 06:29:24AM +0100, Jim Cromie wrote:
> > #ifdef CONFIG_JUMP_LABEL
> > - if (dp->flags & _DPRINTK_FLAGS_PRINT) {
> > - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT))
> > + if (dp->flags & _DPRINTK_FLAGS_ENABLED) {
> > + if (!(modifiers->flags & _DPRINTK_FLAGS_ENABLED))
> > static_branch_disable(&dp->key.dd_key_true);
> > - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT)
> > + } else if (modifiers->flags & _DPRINTK_FLAGS_ENABLED)
> > static_branch_enable(&dp->key.dd_key_true);
> > #endif
> > dp->flags = newflags;
> > --
> > 2.33.1
> >
>
> I haven't tested it so I could be mistaken, but when
> _DPRINTK_FLAGS_ENABLED gets two flags in the next patch, it looks like
> this code still has the problem which I mentioned in
> https://lore.kernel.org/lkml/20211209150910.GA23668@axis.com/?
>

Yes, thanks for noticing. I missed that detail.
Apriori, I dont know why bit-and of bit-or'd flags doesnt cover it,
but I will take a careful look.

> | I noticed a bug inside the CONFIG_JUMP_LABEL handling (also present
> | in the last version I posted) which should be fixed as part of the
> | diff below (I've added a comment).
> | [...]
> | #ifdef CONFIG_JUMP_LABEL
> | - if (dp->flags & _DPRINTK_FLAGS_PRINT) {
> | - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT))
> | + if (dp->flags & _DPRINTK_FLAGS_ENABLE) {
> | + /*
> | + * The newflags check is to ensure that the
> | + * static branch doesn't get disabled in step
> | + * 3:
> | + *
> | + * (1) +pf
> | + * (2) +x
> | + * (3) -pf
> | + */
> | + if (!(modifiers->flags & _DPRINTK_FLAGS_ENABLE) &&
> | + !(newflags & _DPRINTK_FLAGS_ENABLE)) {
> | static_branch_disable(&dp->key.dd_key_true);
> | - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT)
> | + }
> | + } else if (modifiers->flags & _DPRINTK_FLAGS_ENABLE) {
> | static_branch_enable(&dp->key.dd_key_true);
> | + }
> | #endif