Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2936018ybk; Mon, 18 May 2020 11:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysNTczENCADcYft6iYU9ylrzxD9Pmz13FV13sosNC4QKN37xlF4odxDIvEakfOFblYrY7Q X-Received: by 2002:a17:906:90c1:: with SMTP id v1mr15306519ejw.322.1589826658951; Mon, 18 May 2020 11:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589826658; cv=none; d=google.com; s=arc-20160816; b=wrCdZFd2OzbeZRZjquAMh6bA6PFjvpPUV3goE6n0Cnf+lU2+vA6YK/huIjp3AEjjvy bB7Ph7sUVz98DIJcljRLRLO/xUNFcODhXk25VPrQlUPcxR7VQO+cqRbOoTnFZ764YUWx w8ucy6VQ/beYuh1SRwE2NtbwZ+vQRqTbeBtwpFutF6ZhCFzls+03pDtUSplhF3jjN+fK mlZO/sd5kqwsn+Df3eRidUyArrQGqsms8Fl9cJ/kXSuOdslW0dBUi14iKHjMmAQB+QWX 00EmPdNo4cITXckZ8MRYU0Sz8RHTcNpsbTzRNJTxVPZe31VIpluvwaUmo0h1e3cfVZmq Gw5Q== 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=xH/If32BjwRV8u09SENP5PlFz9MnD5dcxYq0ycriWEE=; b=ryN5FKBRmM/0L4AC5Ur6DQYd1kvl8XfwlUURP5XsubdjwCeMX/8DoDxsGf2/V9LaDI 2LL7Ga2YYyH2/hupAajDRRHUDIdZ3YDac5O4nR6XARyj3ZX8qTztKdDmc0JyeoI/ZI7S l9IVH2t4yCRstb2jXpYc/N+PDZ8Vxpd3HELpl1H9Kp7UtU+ZlBMM9/kkzZYj76OBkJCX VXHn5GpyCRNuZ4yceYdQl1xduhAXisAUOQ6GIEl+Lf4Zm9wG7vaSV2q47emlfonU7H9M W3Ew3VCEP+e3YKI17JjHhK2MrxZ9Dfyt6etT2Gv1mI797l3XLDlyRu1TG17woH4+QG5W lPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OnWslDzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si7513940edj.333.2020.05.18.11.30.35; Mon, 18 May 2020 11:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OnWslDzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgERRme (ORCPT + 99 others); Mon, 18 May 2020 13:42:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728830AbgERRmT (ORCPT ); Mon, 18 May 2020 13:42:19 -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 85CCC20657; Mon, 18 May 2020 17:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823739; bh=yKwxbu0ssZHksUJJ8DfAuGLrwFXRBVCuaG65HeQ1Mrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnWslDzmTkVZltiqYLAsLHOngorH2ZJKoa1HJNqrpQ1ZGDTQbqb+K2bJqQt5aIENl I1PwU9BikTfCftJ+94S0CikaJDz6yt8IK4fKOIKOVe9Pyzem7IglcgMu4DmJ93NuD0 i/9ubWsG/ppzgAZb5gZk8mL5RnSCKvLZ5LAIBKWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Tzvetomir Stoyanov (VMware)" , Joerg Roedel , "Steven Rostedt (VMware)" Subject: [PATCH 4.9 17/90] tracing: Add a vmalloc_sync_mappings() for safe measure Date: Mon, 18 May 2020 19:35:55 +0200 Message-Id: <20200518173454.769765722@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@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: Steven Rostedt (VMware) commit 11f5efc3ab66284f7aaacc926e9351d658e2577b upstream. x86_64 lazily maps in the vmalloc pages, and the way this works with per_cpu areas can be complex, to say the least. Mappings may happen at boot up, and if nothing synchronizes the page tables, those page mappings may not be synced till they are used. This causes issues for anything that might touch one of those mappings in the path of the page fault handler. When one of those unmapped mappings is touched in the page fault handler, it will cause another page fault, which in turn will cause a page fault, and leave us in a loop of page faults. Commit 763802b53a42 ("x86/mm: split vmalloc_sync_all()") split vmalloc_sync_all() into vmalloc_sync_unmappings() and vmalloc_sync_mappings(), as on system exit, it did not need to do a full sync on x86_64 (although it still needed to be done on x86_32). By chance, the vmalloc_sync_all() would synchronize the page mappings done at boot up and prevent the per cpu area from being a problem for tracing in the page fault handler. But when that synchronization in the exit of a task became a nop, it caused the problem to appear. Link: https://lore.kernel.org/r/20200429054857.66e8e333@oasis.local.home Cc: stable@vger.kernel.org Fixes: 737223fbca3b1 ("tracing: Consolidate buffer allocation code") Reported-by: "Tzvetomir Stoyanov (VMware)" Suggested-by: Joerg Roedel Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -7032,6 +7032,19 @@ static int allocate_trace_buffers(struct */ allocate_snapshot = false; #endif + + /* + * Because of some magic with the way alloc_percpu() works on + * x86_64, we need to synchronize the pgd of all the tables, + * otherwise the trace events that happen in x86_64 page fault + * handlers can't cope with accessing the chance that a + * alloc_percpu()'d memory might be touched in the page fault trace + * event. Oh, and we need to audit all other alloc_percpu() and vmalloc() + * calls in tracing, because something might get triggered within a + * page fault trace event! + */ + vmalloc_sync_mappings(); + return 0; }