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

[PATCH 2/3] xen/privcmd: fix error handling in mmap-resource processing


  • To: Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Sep 2021 12:17:48 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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; bh=or78mkWgiZ0tw8GzqU9/omJtttnIwfRDs2Aq8lzGU1U=; b=Bh9cC/Eybp/sXaq0Me5/3lkwwy1yg+YY1GdaRptkJWHjBn8N/n4qEQMdHtz/iWFRPawgyolq3PcNJK2S9oJr00CgEEl1sR6sMbI6GADZqqWp3komYglF2DJcWsRnDGoHw8AMdm1dXrCNEEWpAnPvs10V5fXYCpvKHeNxaavQAJd6pgVgES/75bJzZwGDTokP4XwPMlHOVqXI6ceUB+ilIf563CLbVp2H0dm/iESvC9DCQSvYCcyUUpaheUwfrv6ctfspK1BNtQ5iYs7H5nvYw/QZmtqJMfNmxjz7AZLg1RPQ7ifVJdaa+1yXa95xlvg64f6uW+0GKkny2tHPW7/tJw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pq42DDIJGOaxdlRTTXAtesDsX61o5He5iwNuSu1IvKWr0//tUA49NeO6CQT6mok2F9w2uUgT95mIo2bWc+QthDBNOZ9RrPgsE2ZZTcNaPxDLqhW6jvvpA+Xt9cB2/0kgIAIAV7BfZl7jwbxb0pDFBMTXmdXwYs2ZHCCWWg7ELb4EU+Ii+Vv7BGSh4ZXWQkt9qGbTEQU1A/MKN4z3PeAa2FDjlpu0G/fobBkaWR7fz2lLILbIHbkqBU1OzzdX54azdsqw77FJWvl28VtC7mcBxKxVcd71KoavNsSXo++W5HqPgMJl3EUngfT4PoRc1LTbyoJZuOPUXmJOPtih5bH4Yg==
  • Authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 22 Sep 2021 10:17:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

xen_pfn_t is the same size as int only on 32-bit builds (and not even
on Arm32). Hence pfns[] can't be used directly to read individual error
values returned from xen_remap_domain_mfn_array(); every other error
indicator would be skipped/ignored on 64-bit.

Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -803,11 +803,12 @@ static long privcmd_ioctl_mmap_resource(
                unsigned int domid =
                        (xdata.flags & XENMEM_rsrc_acq_caller_owned) ?
                        DOMID_SELF : kdata.dom;
-               int num;
+               int num, *errs = (int *)pfns;
 
+               BUILD_BUG_ON(sizeof(*errs) > sizeof(*pfns));
                num = xen_remap_domain_mfn_array(vma,
                                                 kdata.addr & PAGE_MASK,
-                                                pfns, kdata.num, (int *)pfns,
+                                                pfns, kdata.num, errs,
                                                 vma->vm_page_prot,
                                                 domid,
                                                 vma->vm_private_data);
@@ -817,7 +818,7 @@ static long privcmd_ioctl_mmap_resource(
                        unsigned int i;
 
                        for (i = 0; i < num; i++) {
-                               rc = pfns[i];
+                               rc = errs[i];
                                if (rc < 0)
                                        break;
                        }




 


Rackspace

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