[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1D5BDE66-ABB3-41D9-ACB0-FBAC207D55DC@toblux.com>
Date: Thu, 30 May 2024 16:15:51 +0200
From: Thorsten Blum <thorsten.blum@...lux.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: markus.elfring@....de,
Shyam-sundar.S-k@....com,
hdegoede@...hat.com,
ilpo.jarvinen@...ux.intel.com,
kernel-janitors@...r.kernel.org,
linux-kernel@...r.kernel.org,
platform-driver-x86@...r.kernel.org
Subject: Re: [PATCH v2] platform/x86/amd/pmf: Use memdup_user()
Hi Dan,
On 27. May 2024, at 12:38, Dan Carpenter <dan.carpenter@...aro.org> wrote:
> Also this check isn't great:
>
> if (dev->policy_sz < header->length + 512)
>
> header->length is a u32 that comes from the user, so the addition can
> overflow. I can't immediately see how to exploit this though since we
> don't seem to use header->length after this (by itself).
How about
if (header->length > U32_MAX - 512 || dev->policy_sz < header->length + 512)
return -EINVAL;
to prevent a possible overflow?
header->length is used in the next line
dev->policy_sz = header->length + 512;
and if the addition overflows, we end up setting dev->policy_sz to an
invalid value.
Thanks,
Thorsten
Powered by blists - more mailing lists