[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/privcmd: prevent integer overflow on 32 bit systems


  • To: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Fri, 15 Jul 2022 08:56:30 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ul4YRkWIBpTNfduzak5HQ9qlutYvL9Q30qHW4nlXxgk=; b=SCdm2lXJtwkeJU5qbmOuFjct6qwKP1f8vtV+6HjdpwrKUavI8PlMpMzg9n/QfthQWxVFx9rAbsApr3eMhHQnQqdYLbUWXwCyIw+Uvx20/4YzKch3VbJ3NFyJ2cGGTjT5L7akn+iQtcliu0+TEKK3i7iKFHAKDfjxSxAUg6w4sz40g7psJ5KoZ2PVVC8rf6u/CR4JZNpiE9Ab7kki/Uf4XgDby1/MEXVK8sjb2hgOL50LOsoCJjW5T6kPoLZPggSvOpD82AnBedbres/BHp3mPuf/4y2yu+xsHG9LJTtXaNVll2it4AEwr/6LQ4iDnWtiIK20WULJf2G/wcIXDKK40A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TjjPiJWCnyHnGLRhmP0pjDqQ3cDougDZWJmerU/mjLfhnxonnK4z35AlWIRLnjT4jSVqhE+s8j7mRIPyZuKOxtnvOec+8zwtiv7ZY98PBy9vxysyVXPY6HCKa/1CrmEkI6E1UpvhWrsqpJvF9+v30Xr1jKQM+oz4z2ojNa3F34S7q72G2oqaLizxSVtb83i/DKGwc/FG2SVBTTa9FJuKHawiSupxLRvfCVzq+/IrXX0w9MmXAowzMkm86Ix/wYnr0PZZAUxys8dYAxJds0pkGP5MAfu9sKKqNKTU36dJKJrE/nb9A9BKZg5n564QZ/QyfbAGIz15nh5OML7x317y7A==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Andres Lagar-Cavilla <andreslc@xxxxxxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, David Vrabel <david.vrabel@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "kernel-janitors@xxxxxxxxxxxxxxx" <kernel-janitors@xxxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Fri, 15 Jul 2022 08:56:50 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYmCjGqfExByPyt0K1yo9lRsWBCw==
  • Thread-topic: [PATCH] xen/privcmd: prevent integer overflow on 32 bit systems

On 15.07.22 11:20, Dan Carpenter wrote:


Hello Dan

> The "m.num * sizeof(*m.arr)" multiplication can have an integer overflow
> on 32 bit systems.  Probably no one really uses this software on 32 bit
> systems, but it's still worth fixing the bug if only to make the static
> checker happy.
>
> Fixes: ceb90fa0a800 ("xen/privcmd: add PRIVCMD_MMAPBATCH_V2 ioctl")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
>   drivers/xen/privcmd.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
> index ad17166b0ef6..1e59b76c618e 100644
> --- a/drivers/xen/privcmd.c
> +++ b/drivers/xen/privcmd.c
> @@ -456,6 +456,8 @@ static long privcmd_ioctl_mmap_batch(
>               if (copy_from_user(&m, udata, sizeof(struct privcmd_mmapbatch)))
>                       return -EFAULT;
>               /* Returns per-frame error in m.arr. */
> +             if (m.num > SIZE_MAX / sizeof(*m.arr))
> +                     return -EINVAL;
>               m.err = NULL;
>               if (!access_ok(m.arr, m.num * sizeof(*m.arr)))
>                       return -EFAULT;
> @@ -464,6 +466,8 @@ static long privcmd_ioctl_mmap_batch(
>               if (copy_from_user(&m, udata, sizeof(struct 
> privcmd_mmapbatch_v2)))
>                       return -EFAULT;
>               /* Returns per-frame error code in m.err. */
> +             if (m.num > SIZE_MAX / sizeof(*m.arr))

Looks like here we need to check against sizeof(*m.err) which is used in 
the multiplication below.


> +                     return -EINVAL;
>               if (!access_ok(m.err, m.num * (sizeof(*m.err))))
>                       return -EFAULT;
>               break;

-- 
Regards,

Oleksandr Tyshchenko

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.