From patchwork Wed Sep 21 12:41:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 9343479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8E24601C2 for ; Wed, 21 Sep 2016 12:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB6C929FF6 for ; Wed, 21 Sep 2016 12:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFF452A62E; Wed, 21 Sep 2016 12:43:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6FB229FF6 for ; Wed, 21 Sep 2016 12:43:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmgq0-0002MA-1v; Wed, 21 Sep 2016 12:41:20 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmgpy-0002M4-Hr for xen-devel@lists.xen.org; Wed, 21 Sep 2016 12:41:18 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 11/1E-15404-DEF72E75; Wed, 21 Sep 2016 12:41:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsUSfTxjoe7b+kf hBjeahSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyGufuZCh6xVxzsvcLWwNjK1sXIwSEk4CHx /6JcFyMXkLmWUeLJxcXMEM41Rolze7YDFXGCFU3f850VIrGfUWLt82MsIAk2AUOJ1RtbwIpEB KQlrn2+zAhiMwvUSsx+exjMFhZwltj+/w5YDYuAqsSFywuYQWxeAU+Jlt6tYLaEgJzEyWOTWS HsHIll/T3sINdJCEhJ/G9Vggj3sEj8+C0AYctIPJp4k20Co8ACRoZVjBrFqUVlqUW6hkZ6SUW Z6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBYcUABDsYL28MOMQoycGkJMr73PFRuBBf Un5KZUZicUZ8UWlOavEhRhkODiUJXmFgmAoJFqWmp1akZeYAAxwmLcHBoyTCu7wOKM1bXJCYW 5yZDpE6xajLseDH7bVMQix5+XmpUuK8j0GKBECKMkrz4EbAou0So6yUMC8j0FFCPAWpRbmZJa jyrxjFORiVhHkNQS7hycwrgdv0CugIJqAjtvx8AHJESSJCSqqBUYV3U9iL6zU1n7yLmEOvyFg dnHlkB1/wy232vD8cFgj8f3DtVPHUlqBbEyLbVP9fCb+ke9RdYL0H8yS+OAPhSKUJ2/6z7ZQ9 ypq+xFhsgvxZwdanni+cNiUZ5m74LBdm+1Fy8Sfbkms6e2Xf2C7gWle1WrPGetLkrnvTk57kb dwvq7rF9+7NGiWW4oxEQy3mouJEAKz2dwaxAgAA X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1474461676!34308030!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.9 required=7.0 tests=SUBJ_HAS_UNIQ_ID X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64215 invoked from network); 21 Sep 2016 12:41:17 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-5.tower-21.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 21 Sep 2016 12:41:17 -0000 Received: (qmail 22803 invoked from network); 21 Sep 2016 15:41:15 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 21 Sep 2016 15:41:15 +0300 Received: from smtp01.buh.bitdefender.com (smtp.bitdefender.biz [10.17.80.75]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id A7C7C7FBD2 for ; Wed, 21 Sep 2016 15:41:15 +0300 (EEST) Received: (qmail 19034 invoked from network); 21 Sep 2016 15:41:15 +0300 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp01.buh.bitdefender.com with AES128-SHA256 encrypted SMTP; 21 Sep 2016 15:41:15 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Wed, 21 Sep 2016 15:41:04 +0300 Message-Id: <1474461664-32624-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp01.buh.bitdefender.com, sigver: 7.67317 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 433037, Stamp: 3], Multi: [Enabled, t: (0.000009, 0.001387)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.001986), Flags: 85D2ED72; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.008075)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.024673), Hit: No, Details: v2.3.11; Id: 2m1ghm1.1aspl1oom.255s0], total: 0(775) X-BitDefender-CF-Stamp: none Cc: george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Razvan Cojocaru , jbeulich@suse.com Subject: [Xen-devel] [PATCH V2] x86/mm: Fix Coverity issues 1373105 and 1373106 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Added missing error checks in p2m_set_mem_access_multi(). Signed-off-by: Razvan Cojocaru Reviewed-by: George Dunlap --- Changes since V1: - Returning -EFAULT instead of -EINVAL. - Replaced stray TAB with spaces. --- xen/arch/x86/mm/p2m.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b16e563..9526fff 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1936,8 +1936,12 @@ long p2m_set_mem_access_multi(struct domain *d, uint8_t access; uint64_t gfn_l; - copy_from_guest_offset(&gfn_l, pfn_list, start, 1); - copy_from_guest_offset(&access, access_list, start, 1); + if ( copy_from_guest_offset(&gfn_l, pfn_list, start, 1) || + copy_from_guest_offset(&access, access_list, start, 1) ) + { + rc = -EFAULT; + break; + } if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) {