Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2746165ybh; Mon, 5 Aug 2019 06:12:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzebyA8bAAJFNTtVlSQK7Myzxq9lI0tCnjtdyNxtbD7nKcnrqQVAuxVHY6cElBVOXncmQNR X-Received: by 2002:a63:7e17:: with SMTP id z23mr137680676pgc.14.1565010770184; Mon, 05 Aug 2019 06:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010770; cv=none; d=google.com; s=arc-20160816; b=bHSK2nraJUM5dZPC8ddtWQ8yGjyfyRZU9vaSjpZoXdOTIHz29IwYSIz0phzWAIbcT9 KCkit6QV6pkKmLWsPsWQXY1AwpZC6MDmBtPQ9XwpP8QvguSXRLHVHn3rmTKaesOFL96U rSx3+t4Ib1at6WI0I4NAnXzvO/byQOaj9oS2WALZQ1okeaXxqou5SY9i8QlM5GRzUYRA UV4T6lqjhCMFif/JSZgpG+JNerqtA+wHz79aWGyQKr1sqcjUFAeRKQNWtibarznLhDBF Q8pUuBubFSlVR8RGtR2YYRj9S6jYeegK8n3McbEvhlirKUiW3xJQsoA/F6R9jiIjoV9C Y1HA== 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=Why749DPhmewcWBBolsO8+AZb02wlcEPZ3u7JKL7VcE=; b=UocBViooba7UrP4W1X9h5QVRYSATj/T2Qa9TJUgyLhYV8/CZWK25Y/62zQuVgP8A0b 4v47+WdrrMNe10e6q1RobP+U86jgwmFcD4c8LOKqGWHLkJtrdGkxfI4dStzhjF+azcx3 vI1RdbQdWTbvvmrznqOmi1ZKOwwOAdUQoc4cbAM/6U5lVwHMrOuCXbdz9w7pWLVhf7H6 9e65aMwcpT1UCDasUPZapY/ktnqrnvG+lVx0KiVdTwMbIEid3joH1tX+hove8pQiosT5 yHTVGC3xAB1ragKLbnX71FijMqW+Tn+ZMDwzP0qxxZa/yOlig6gmLqpo5xktZO3oq8Kq Odcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cyOvs+cb; 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 w1si43634780pfn.129.2019.08.05.06.12.34; Mon, 05 Aug 2019 06:12:50 -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=cyOvs+cb; 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 S1729913AbfHENLS (ORCPT + 99 others); Mon, 5 Aug 2019 09:11:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730498AbfHENLP (ORCPT ); Mon, 5 Aug 2019 09:11:15 -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 7C9EC21738; Mon, 5 Aug 2019 13:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010675; bh=Pa4wSFVkCPxyf5+NSU1pVrZRiZUO5m60ZRYSvyppvxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cyOvs+cbmoo9x2IThMPMvF+gU7JBmk+gDVhoihBXb9vLN1Tazf/AaVcFCJ/TySiTB H0ek9TOpMAO5q4hFTUqgiQZ8Am4/YOTgLZCwU0BA4KI2n82RPULiHJMGpBtkpQa5MG dmosag/3GDqZyxM8bfGzgomY7hemFZf9wa8on6Js= 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 4.19 61/74] xen/swiotlb: fix condition for calling xen_destroy_contiguous_region() Date: Mon, 5 Aug 2019 15:03:14 +0200 Message-Id: <20190805124940.763241980@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124935.819068648@linuxfoundation.org> References: <20190805124935.819068648@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 @@ -357,8 +357,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);