Re: [PATCH][RFC] platform/x86: dell-smbios-wmi: Avoid false-positive memcpy() warning

From: Andy Shevchenko
Date: Wed Aug 25 2021 - 12:32:52 EST


On Wed, Aug 25, 2021 at 09:07:49AM -0700, Kees Cook wrote:
> In preparation for FORTIFY_SOURCE performing compile-time and run-time
> field bounds checking for memcpy(), memmove(), and memset(), avoid
> intentionally writing across neighboring fields.
>
> Since all the size checking has already happened, use input.pointer
> (void *) so memcpy() doesn't get confused about how much is being
> written.
>
> Avoids this false-positive warning when run-time memcpy() strict
> bounds checking is enabled:
>
> memcpy: detected field-spanning write (size 4096) of single field (size 36)
> WARNING: CPU: 0 PID: 357 at drivers/platform/x86/dell/dell-smbios-wmi.c:74 run_smbios_call+0x110/0x1e0 [dell_smbios]

> Note: is there a missed kfree() in the marked error path?

Seems so.

* Note: The caller should use acpi_os_free to free this
* buffer created via ACPI_ALLOCATE_BUFFER.


--
With Best Regards,
Andy Shevchenko