Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4093178ybi; Fri, 19 Jul 2019 14:51:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhIFaJOkhnFzEUMxF304ISQgQPhr2vJyMj5UYOATBxn8NS8Boh+IwSB5yKSv1KYPv9eZw6 X-Received: by 2002:a17:902:583:: with SMTP id f3mr59006349plf.137.1563573100913; Fri, 19 Jul 2019 14:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563573100; cv=none; d=google.com; s=arc-20160816; b=iLW6s4a2AFyQ8bgZ4Y2AfmdAocPfNqALaFpyON7XhJxtPXTIyw+TGRwVPdx9UASz6Q w8mZKtkOFD97YZRX7CXJ7dx2qcqbNAOcCjXJD/Oazibbi/4oeNA9HgJf+59VgyAU6eZL c3hjWI3DbyrW2ZSLYwngzDSg/TeLIXaOIZ9X0zt1dZ0Y4sxAkRtYYsLxBu+BtUblDxbt l2sQBYG9id0vsYJrrEnciBc/ZWjJeBFPsW8I3nq3eJUwg39lsKUC0QaeLvGwgSC2f4t/ MKeysXoTHR7v2q14Dmul1Jq3jDkbwf51vMgoQcDAYQHzTkpsX4F/nLOvZglnVgECBHEX b8lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=uCDkeNVbjDAM8yrLHlMPqnxhh17i0B5p0qCieHpy4M0=; b=nBeqiEO31RGQBVdCwXeaRYll2K4jYaAd1FPz7vkipZ9bBK99aOqafXn4gV2/50SXTi lbhXd/yrTVvkZl9B2yakaWiDcBxEbLx+x2uYyTOVFgYkXtOD/ehgf3nLKX2PRNd1HCa6 BQkW8pemLTi5P5gCSJryH279kcsF9rZvWs/p7cHY5UmA3ar/Z1YhyfW6OihhvRfn/AC9 jO2PRaEJKoiNB/H2OdwjgAscwTQBoC8nvzitTzmDCuAB0x18bPrZaIj6WiaBtsmPbjO5 BILkWULixZxKT108x7XyztNFYuXmwWRit3CtcV6j26aEuVfNApLNjksllVxpwk8XCEVH Gm4g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si1862387pjb.13.2019.07.19.14.51.25; Fri, 19 Jul 2019 14:51:40 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732251AbfGSSrA (ORCPT + 99 others); Fri, 19 Jul 2019 14:47:00 -0400 Received: from 8bytes.org ([81.169.241.247]:36144 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732096AbfGSSq4 (ORCPT ); Fri, 19 Jul 2019 14:46:56 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id D322026B; Fri, 19 Jul 2019 20:46:54 +0200 (CEST) From: Joerg Roedel To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joerg Roedel Subject: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range() Date: Fri, 19 Jul 2019 20:46:52 +0200 Message-Id: <20190719184652.11391-4-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719184652.11391-1-joro@8bytes.org> References: <20190719184652.11391-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel 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. References: https://bugzilla.suse.com/show_bug.cgi?id=1118689 Reviewed-by: Dave Hansen Fixes: 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F') Signed-off-by: Joerg Roedel --- mm/vmalloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4fa8d84599b0..e0fc963acc41 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1258,6 +1258,12 @@ static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end) if (unlikely(valist == NULL)) return false; + /* + * First make sure the mappings are removed from all page-tables + * before they are freed. + */ + vmalloc_sync_all(); + /* * TODO: to calculate a flush range without looping. * The list can be up to lazy_max_pages() elements. @@ -3038,6 +3044,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) { -- 2.17.1