[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGG=3QWawMUJv83UBGFk0izrP1+FdftB7x7ZLSYx4NvcGPWyYg@mail.gmail.com>
Date: Mon, 16 Sep 2024 02:45:47 -0700
From: Bill Wendling <morbo@...gle.com>
To: Thorsten Blum <thorsten.blum@...lux.com>
Cc: Nathan Chancellor <nathan@...nel.org>, kees@...nel.org, gustavoars@...nel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, mcgrof@...nel.org,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH v2] params: Annotate struct module_param_attrs with __counted_by()
On Fri, Sep 13, 2024 at 5:23 PM Thorsten Blum <thorsten.blum@...lux.com> wrote:
>
> On 14. Sep 2024, at 01:44, Nathan Chancellor <nathan@...nel.org> wrote:
> > 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 :)
>
> I think the problem is with __builtin_dynamic_object_size().
>
> memset(p,,) calls __struct_size(p), which calls
> __builtin_dynamic_object_size(p, 0) and this behaves weirdly:
>
> __builtin_dynamic_object_size(&mk->mp->attrs[mk->mp->num - 1], 0);
>
> evaluates to 0, but
>
> __builtin_dynamic_object_size(mk->mp->attrs + mk->mp->num - 1, 0);
>
> evaluates to 4294967295.
>
> Both values are wrong, but the latter doesn't trigger the
> false-positive warning.
The 4294967295 simply means "I don't know." There's probably a bug in
the size calculation. I'll look into it.
-bw
Powered by blists - more mailing lists