Re: [RESEND PATCH v2] params: Annotate struct module_param_attrs with __counted_by()

From: Nathan Chancellor
Date: Fri Sep 13 2024 - 19:45:06 EST


On Sat, Sep 14, 2024 at 01:32:19AM +0200, Thorsten Blum wrote:
> Thanks for reporting this.
>
> Changing
>
> memset(&mk->mp->attrs[mk->mp->num - 1], 0, sizeof(mk->mp->attrs[0]));
>
> to
>
> memset(mk->mp->attrs + mk->mp->num - 1, 0, sizeof(mk->mp->attrs[0]));
>
> fixes the false-positive warning
>
> memset: detected buffer overflow: 32 byte write of buffer size 0
>
> even though the pointers have the same value. Does anyone know why?

Might be a good question for Bill? The full context is available
starting at:

https://lore.kernel.org/all/20240913164630.GA4091534@thelio-3990X/

I wonder if the krealloc() has something to do with it? I should try GCC
but I don't have a tip of tree copy handy at the moment and I am also
rushing at the end of my day to pack for my travels to LPC :)

Cheers,
Nathan