[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xen/privcmd: fix error exit of privcmd_ioctl_dm_op()
- To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>
- From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
- Date: Wed, 24 Aug 2022 17:50:43 +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=LM8kc3a0fmuHvGUBGoYLxN9QFvztpogZ8mFPitAQs/U=; b=ik3RoHnLl/Rz0US9u4ALdbDQAJQF5Iqg7Sf9SyN+ZLepj0scXpbG/lwzzmPnXFztA3hvqVs8NAleWLghAG0uxqAvKkbcvPb3vcu1MT5RXW2dT8FJTNVJ6INohVp7Kd7wnezzCIr+il+dkKio6Od0OD9tXzl+cC85/qxO0UQPI92Hrj81k9MMp3YH/QvvLV6OQIsimGGP21/56kSEnMMPbwOJSGT2QT2WN6CvaL0IWAJ+VVff97W+6fYz2BNFkU4D1ZJ1gEKKHRdvYFkogT4AvWrBIIrCcG9TY6+JgJzzaUrRdcLywqZctORJyrmjaJaqolCIlxalcWPJDmnBdicZ4w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFcw82MWSTnzXyi831dlFU//cr7Day3lJTLWqCdInZnJIJ/azHX6xFX3b7pIMLHOKtKzp1qxE8howkK4jTUD5RfsZIiTGvzT+FT7ktgC9BYp59J6TNUFphLvK2mjExZ1+MlEkduEnWughJ5IBbBUGUw6USGHebXO0orU/Sbobed7gibzBDHKNH1hhj6mLY0JsltTkvD9/7LMvuhWHmGyaytET8ISEjutGMESxx9CisemRD96cNGy/GSJcOhG+c+mKFRZCSqOKVdEHxwHWqJ1sovHcPkTkNhulZtF3moXRBojYBSmBIK71qdhylmKvdV03hHjibZN8S9sa3aYEB11vg==
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "stable@xxxxxxxxxxxxxxx" <stable@xxxxxxxxxxxxxxx>, Rustam Subkhankulov <subkhankulov@xxxxxxxxx>
- Delivery-date: Wed, 24 Aug 2022 17:51:27 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYt8WobNhf1hcK4Em8o6Kwco0uKK2+VHwA
- Thread-topic: [PATCH] xen/privcmd: fix error exit of privcmd_ioctl_dm_op()
On 24.08.22 17:26, Juergen Gross wrote:
Hello Juergen
> The error exit of privcmd_ioctl_dm_op() is calling unlock_pages()
> potentially with pages being NULL, leading to a NULL dereference.
>
> Fix that by calling unlock_pages only if lock_pages() was at least
> partially successful.
>
> Cc: <stable@xxxxxxxxxxxxxxx>
> Fixes: ab520be8cd5d ("xen/privcmd: Add IOCTL_PRIVCMD_DM_OP")
> Reported-by: Rustam Subkhankulov <subkhankulov@xxxxxxxxx>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> ---
> drivers/xen/privcmd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
> index 3369734108af..ec87968b4459 100644
> --- a/drivers/xen/privcmd.c
> +++ b/drivers/xen/privcmd.c
> @@ -679,7 +679,7 @@ static long privcmd_ioctl_dm_op(struct file *file, void
> __user *udata)
> rc = lock_pages(kbufs, kdata.num, pages, nr_pages, &pinned);
> if (rc < 0) {
> nr_pages = pinned;
> - goto out;
> + goto unlock;
> }
>
> for (i = 0; i < kdata.num; i++) {
> @@ -691,8 +691,9 @@ static long privcmd_ioctl_dm_op(struct file *file, void
> __user *udata)
> rc = HYPERVISOR_dm_op(kdata.dom, kdata.num, xbufs);
> xen_preemptible_hcall_end();
>
> -out:
> + unlock:
> unlock_pages(pages, nr_pages);
> + out:
> kfree(xbufs);
> kfree(pages);
> kfree(kbufs);
--
Regards,
Oleksandr Tyshchenko
|