Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2761282ybh; Mon, 5 Aug 2019 06:26:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPEDjW1XP/qjd66ecfcCCZpZ08cHmS7d1BeFZ/TH4FENwBCz3dj78Kkz0v0d76MKMKIkiC X-Received: by 2002:a17:902:b591:: with SMTP id a17mr62232625pls.96.1565011575334; Mon, 05 Aug 2019 06:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011575; cv=none; d=google.com; s=arc-20160816; b=0GY/DDZ6odcncbbvk+WDbaxyODjvk2gSgHdTHQqfUUwINjrpt4nDq7KS7te6d76YKm S9ii4GYWWcR0DHsUA33tdLFukfyB3j9GizwiMSYe7tDiZk9Jey3lHO1aE0B5SHSt/vdW uu1Qae/emKIRbbaDqz4RCjixbc1cpvJY87UREkrq+9aEvZaavx7WhiXaLDfUzF+k1die nZdyAnPWKGw75hQRJAL4YQFrdtnZabS9cGhdG/6pf/lvruFXeQTF1OloD2bgy7cdWIEV i6q8z0UM7KBQo49jxyAIW2Nb2Fo/rAXbM13orPi8MMSEntormIHozDK29NBl6bWkp9+F p9LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Url6SoGMixvmfZWm13MW8UtSfvOA+CykVVrQkFjHPs=; b=Y0ICnOVuxxlgBiZflIPl9QJFpOss1Yn/YuUQQqwB7hzn34UFYl9PaaiU1l66cy42SH tge4uHy6OjAO8P0P82B5DBlEXOcgVuGk5iHUb0ldgBOsU2iuEPSSuR/8qdw4n0vgCUcK YWK5d1Q9V4yezaJuxAyvuwT8HVXKs7vBkYAF1XhGQE8UiPCZRc6EDFCnPu//x9MPKdKw CKPiw/Q25wQ5ijn55v0cG8bfZXOVHoSUj5tOH34qDz5eWcR/IenV2t2iouKlaM7G7CXx N0kmJg/j9R17jYyS7JsWX0B6V3wzygmPG/xBFSR9sbF/w1N0ZfKvmSZvvmerWLM5qGYm Fg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=woqr8ywi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si40397106plc.356.2019.08.05.06.26.00; Mon, 05 Aug 2019 06:26:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=woqr8ywi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731194AbfHENZR (ORCPT + 99 others); Mon, 5 Aug 2019 09:25:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:33756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730801AbfHENZQ (ORCPT ); Mon, 5 Aug 2019 09:25:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02A4E2067D; Mon, 5 Aug 2019 13:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011515; bh=A2eYit4iCgSv7faV4aJTnohGLCKHnrfaYjk0Q0752e4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woqr8ywiCxBh5hYaWDKdFVKqdNuFqMSqS4yMvE1+Xw1rkb1LkFqNhX+T+G0Pnb6SI LGp4mm+Ii+fzTfsnFvq7GHiuyt7N35AKwxh+Z/pGg98Tmc+9xu2fhqjoWJ16Abr2/Y uHhov6z9WuzEq/H0H+zOlbjKFxhuL1sa98C/ad2s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky , Jan Beulich , Konrad Rzeszutek Wilk Subject: [PATCH 5.2 118/131] xen/swiotlb: fix condition for calling xen_destroy_contiguous_region() Date: Mon, 5 Aug 2019 15:03:25 +0200 Message-Id: <20190805124959.859269321@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124951.453337465@linuxfoundation.org> References: <20190805124951.453337465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 50f6393f9654c561df4cdcf8e6cfba7260143601 upstream. The condition in xen_swiotlb_free_coherent() for deciding whether to call xen_destroy_contiguous_region() is wrong: in case the region to be freed is not contiguous calling xen_destroy_contiguous_region() is the wrong thing to do: it would result in inconsistent mappings of multiple PFNs to the same MFN. This will lead to various strange crashes or data corruption. Instead of calling xen_destroy_contiguous_region() in that case a warning should be issued as that situation should never occur. Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Jan Beulich Acked-by: Konrad Rzeszutek Wilk Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/swiotlb-xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -361,8 +361,8 @@ xen_swiotlb_free_coherent(struct device /* Convert the size to actually allocated. */ size = 1UL << (order + XEN_PAGE_SHIFT); - if (((dev_addr + size - 1 <= dma_mask)) || - range_straddles_page_boundary(phys, size)) + if (!WARN_ON((dev_addr + size - 1 > dma_mask) || + range_straddles_page_boundary(phys, size))) xen_destroy_contiguous_region(phys, order); xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs);