Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1614873pxb; Mon, 11 Oct 2021 09:31:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0ws2TJQdCIpHyPWDyQBlg4UNW5shV6P0SeIVkXceQvL7+IdLO/ZrJrdhXxmg4+9Ocm/qH X-Received: by 2002:a17:902:b711:b029:11e:6480:258a with SMTP id d17-20020a170902b711b029011e6480258amr25247129pls.41.1633969900696; Mon, 11 Oct 2021 09:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969900; cv=none; d=google.com; s=arc-20160816; b=BDrUY7SnRp2oGHeVdiEXlg7csZqxx67+9nH6gCHS0nCoZstbNS4KWBk48Q6HBSV1tR o7OquQ009pvjNaMXODP0XFCRpMrBiLVrr3fA/FVRU74bJ4Uocl94EVxcHWWfL4k3uijw kIQF8v+X9ONI+dboTSQdt8Ccek45R2QFIngJH0B8YPeJO3rsnbtkq/zMlaMhcu1zk2BE xTYckT13NoZQY8hqcBQ+uGzevFWGE/7cBzYJJRv8lbGfC6fwn0Zo2I1ZbrX5D0ESqlRX ZUdLO3n1GAoEqXb0NBgvIY9mG7zkOObwj8g6OHJBQbiskV5eXyT4KCAKrqknvll+2a6G hXIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XRvVNGgAqOundcqJRt9wTkpzUZ74oheHzkaZ3L/UxVs=; b=ujD/mpwIQV32RKwfqGWSHrWb20DuPVdvZCRszbGNAtecY/n7NlvVoKUI79sSdtZVl2 Ptcsqy+ECoD0q0YimGlCo+e01XM8Ya30nIvEmAlUkbThzyAxxXV3ZKRmQPWpDtzoAOQ4 gUvSb0zAw5ZKmwBvhhhso8cEE6dgwET1sistzPcsQiCkqv2DAEkDlmtRTwoSR3nQ1Q6c Y++yyZ0S80EPJpm578wSGCcKdHtmihP7gKZ1TWFMVgI1V4KHBfbR3n0TmGQ4WTAYDVSa /9quJdej3Bjmz8Ym2bxUQR0OlmQPo06fGdrtRJWjO2BKLiSww4zQIZirA1Rs395yXMQy CVJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XBjN+VS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si12846952plx.191.2021.10.11.09.31.28; Mon, 11 Oct 2021 09:31:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XBjN+VS3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237956AbhJKN45 (ORCPT + 99 others); Mon, 11 Oct 2021 09:56:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:39696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237893AbhJKNzE (ORCPT ); Mon, 11 Oct 2021 09:55:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CADB461139; Mon, 11 Oct 2021 13:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960358; bh=k8Dfi/tsG487DiEhuAEZzV2hITLnU7ZWxivlI9YNBkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XBjN+VS3LQDgb28dsO+PPc+zrIYieYjzp+qrrVD+ujEfDGhtJ+96TaqLgzqjv5oeS Cr/+3JURQIfk8ebfke2znDQ4e+yEiIjaLUQHeD7LNlNQcEA8TP+NGT1KxDHX2FqeY0 LFQsD0Y8+RlEgxn7tUFVoBhUFhSmoZ6qxoSoGLr4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Beulich , Boris Ostrovsky , Juergen Gross Subject: [PATCH 5.10 07/83] xen/privcmd: fix error handling in mmap-resource processing Date: Mon, 11 Oct 2021 15:45:27 +0200 Message-Id: <20211011134508.604625026@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich commit e11423d6721dd63b23fb41ade5e8d0b448b17780 upstream. 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@vger.kernel.org Signed-off-by: Jan Beulich Reviewed-by: Boris Ostrovsky Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/aa6d6a67-6889-338a-a910-51e889f792d5@suse.com Signed-off-by: Juergen Gross --- drivers/xen/privcmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- 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; }