Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2751977ybh; Mon, 5 Aug 2019 06:17:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZBagNQBf6APqjK7iJXTtoLOWz24nCjzp9vqN2Crya4+GN6Nz/4SZQ3s4FVO31kpVEhCm9 X-Received: by 2002:a63:1749:: with SMTP id 9mr47899214pgx.0.1565011055709; Mon, 05 Aug 2019 06:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011055; cv=none; d=google.com; s=arc-20160816; b=A1hTNGi7WZm4/KpDh2xBSli3VckEpHbEXKbrTB/L980Deyy4VYVDd41XNFwxvvH5Pb GToyuOdJv/YjZ3gvCOWKy4x4wL8DaV3Ywj3XeFUZK3volYkt8/wT8UXYWAb03M/okszl pl/hm/pk/yTM6LzElKfknmePKibNHpoz4C+diIFNNkxJheXHw0jJ7HKrq3pPaRCmB30t Pg+IcMy0WFTB3MgFdtUZG4BTMAJfPpWPByvd7q6V8MUa4YByFZrbN6gbl4ImKeUPidNT ZI7hLY6dL2ZCvuJAN3xa/fAxDB7lBWNEGsHYTfM4TUnUKU+0BI5usvhrsvIaO6GfHHY3 3TEg== 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=xIssGeR0jhzG+vs4xzB/G+rVV0qSN0bU7vHE5QrEexQ=; b=JNxPNoq8zLFCaLlTwS/9JfYJ9ZdelKN54lxVI3ZmW+Ss56AZF5xuLQ8c4iIm8T6ZfI BPctmOwwlr/w5irWJBREd1AQ8EXq0dMa+Ju4ocRkQWcA7n+MQkul9L9+ER+hZIC1ofmP WkrqXzQsG/T+Xp8/pQEZTAn2g8k+DnD+uDDMswTgneKqO98+PXyoSE1pcLuiVrnFRQdQ GKSP90oi+02VjgHJQ9ukHCVj2tC+grEv6u/TDcdMRJo1TBR29WRMwG7I8iRleGxsn3XT MxMWg24sH0G1WjQWJ0H+LcaReC3QD7taGjtyzUDloeeliF0SZj3ziWUnjQeVXEx+KKBw m8NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CyBoN0jh; 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 b18si46045004pgl.52.2019.08.05.06.17.20; Mon, 05 Aug 2019 06:17:35 -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=CyBoN0jh; 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 S1729438AbfHENF4 (ORCPT + 99 others); Mon, 5 Aug 2019 09:05:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:42146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729421AbfHENFy (ORCPT ); Mon, 5 Aug 2019 09:05:54 -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 54EBB206C1; Mon, 5 Aug 2019 13:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010353; bh=HI8Bcj0/Y78Lr5nke/yKwlk1lz1igip0lnZrf8wQm2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CyBoN0jhKJ1MncLNxpknfZpaJ9lsOPQ2NS/B26B4AO2coLRlS9sCoCE9xTOrgvKdS d80ljS8Hik4dDwEVxoNr/Kk25OmF0g2TQz9OrWNZtfvx+P1xlRzD/XXCo+ruHk7KYW mh93np7lXHXvi5Ee1C8+N0YWa7Jsg9Daq8Zbv+zA= 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.9 33/42] xen/swiotlb: fix condition for calling xen_destroy_contiguous_region() Date: Mon, 5 Aug 2019 15:02:59 +0200 Message-Id: <20190805124928.876315536@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124924.788666484@linuxfoundation.org> References: <20190805124924.788666484@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 @@ -365,8 +365,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);