Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp526420ybl; Fri, 23 Aug 2019 04:38:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3KtUkJXZijiG4s+lxJlz0tczYAjr8X7pMjAqRtPU4PTh+VLnPR+c4n1/7yybXa3/SbHVW X-Received: by 2002:aa7:842f:: with SMTP id q15mr4731233pfn.250.1566560333770; Fri, 23 Aug 2019 04:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566560333; cv=none; d=google.com; s=arc-20160816; b=QUKKQMkC1mQRRccp0U1iyb3NNN0ePaCagJDRla5DE+a4P6z1jDWnKhEbaPa/2QcX4m ElTugTj+kN6G4ZR8nLTKbF8C9DdzTqvqiIDyYgz4h4yqsyWqtbo8vTk41R7YtkcypyOu 47F8yLR559ym1zfQRkG5TZsCPr0UVrcj2R3IVfZyXtevSSv/OIJ4QLZ9Ud/NApvstMLz svnN19y2U0tUpU4QZRGqbCpgphwA+OiTQ9osjj6Jaiynpxbn7Cx/Tf7OgxNekf8vOLHZ vkNlx/fuyrhBqIvOqNrRH9ik52XeYW4fGEFxXWfsvq29rI5sB9ZmC1ZwdxhIyZFAbIDO 9XCg== 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=TDjBSIbizE8Pftu0SgN9CMg6YMxBjvDPbq8RxnrTz2M=; b=tptYn3/PgxeneUKKlmnNrw0thamQ3G7kPydrVQ9DNLq2LAb6YLxnY5dM+jHmWNOAwk 1GKIvbAaKqfGKkUwQ7OYwmKiQd4WZySGtf7mcS4zhsLEvYZmnIMrhposgcMAI7HXaOPU JtESFEy1UZWghbXpEpLTy+JMoxfjY4wXU8I7iaITQftZVENSX3o5ndZPK+m/xvm3XBHS 6IMwCI5L4lpAUI8ObkvYxUoYjm3bCH6Zz6K7AEdSOUnXvzrvNpQG6Z2DYWJCXEGJD7BJ glJFGtNztKXDYOykU4efwPl9VToW6lQ0jQEla71QIANVB/VwgXZnRUvkHUQhkAm1pLHf nyMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kHfsy0Gv; 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 r24si2330131pfh.257.2019.08.23.04.38.38; Fri, 23 Aug 2019 04:38:53 -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=kHfsy0Gv; 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 S2405467AbfHVRnI (ORCPT + 99 others); Thu, 22 Aug 2019 13:43:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:43580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391504AbfHVRXd (ORCPT ); Thu, 22 Aug 2019 13:23:33 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (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 BF5062341A; Thu, 22 Aug 2019 17:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494611; bh=JZ6Sf3a+pIFF1SIbjHDeFrhCvQM0pZiPYq1z2S42460=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHfsy0GvaRnJpJsJ6jnp7PmJZn9tYyf/zgRvj9bNwZoGb1TI1ilmSfRC+Rbh5RhlL 9woUkH+0H9cwR16ubPznSfw6kpezKcUi6KZ9Dp2gV3yaCZ095TDWxvk9Pc9NkUDCbI rBFDaZ8TZdAoKTEP+faSB2KNjKUCPwP2QmMvEPgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Thomas Gleixner , Dave Hansen Subject: [PATCH 4.9 006/103] mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() Date: Thu, 22 Aug 2019 10:17:54 -0700 Message-Id: <20190822171728.887859917@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171728.445189830@linuxfoundation.org> References: <20190822171728.445189830@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: Joerg Roedel commit 3f8fd02b1bf1d7ba964485a56f2f4b53ae88c167 upstream. On x86-32 with PTI enabled, parts of the kernel page-tables are not shared between processes. This can cause mappings in the vmalloc/ioremap area to persist in some page-tables after the region is unmapped and released. When the region is re-used the processes with the old mappings do not fault in the new mappings but still access the old ones. This causes undefined behavior, in reality often data corruption, kernel oopses and panics and even spontaneous reboots. Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to all page-tables in the system before the regions can be re-used. Fixes: 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F') Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Reviewed-by: Dave Hansen Link: https://lkml.kernel.org/r/20190719184652.11391-4-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- mm/vmalloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1708,6 +1708,12 @@ void *__vmalloc_node_range(unsigned long return NULL; /* + * First make sure the mappings are removed from all page-tables + * before they are freed. + */ + vmalloc_sync_all(); + + /* * In this function, newly allocated vm_struct has VM_UNINITIALIZED * flag. It means that vm_struct is not fully initialized. * Now, it is fully initialized, so remove this flag here. @@ -2243,6 +2249,9 @@ EXPORT_SYMBOL(remap_vmalloc_range); /* * Implement a stub for vmalloc_sync_all() if the architecture chose not to * have one. + * + * The purpose of this function is to make sure the vmalloc area + * mappings are identical in all page-tables in the system. */ void __weak vmalloc_sync_all(void) {