Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2725141imm; Mon, 10 Sep 2018 05:41:50 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbs/dHGcUELxnMAxHhSbV2fi9M77f56yiY3VFbLq9sISohDeTlLVIwFE3C+rDlyC6p9O2yV X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr21941587plk.127.1536583310435; Mon, 10 Sep 2018 05:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536583310; cv=none; d=google.com; s=arc-20160816; b=y1EPQYc8GXrfIL8ecNUB+wAIKrEblAOAJLAgsCzf4TlwHnQ8dgdHtF6fetqVtbARL/ rC0EWJS4GouzSGlLygS/M6Xvchr6+zWyiUIe1yA3swJZZKEzUj0x3nle5BPca1vmwQ4/ bTQiscZNBHwxdqMGxvJq6XOG8Ll2vJsp14KJ2o28H7ciKMA/PqMzO1+8GVa/XvPJuYM+ IdN4JebxeRzpEYbRD94E+mfNT+tJXSO+pbnZS/2w/EqvP2LlCG6NWCw0Ik1vzokq1F8M pxPgI5balK6QM9TADlw8sPkjIaMDkc8/6L+qkgC5sKtOT5e+gBfQ+QiweoPHD9nUwXMc 14CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=GAOKDOZqzbaVUsWeQPb/R9o7pF3O70ZAJG7FpzEERhw=; b=rairZzYBYiEEvpsD8RQmWdNvU13RU/cfqYvP/rYQRlk91mCJ96ZhzviNbOCpZvRVAF M6SwwrNmd2KF4u4ud788MWMxdnsdbTG6Z4jF5Bh9c5PH4Bfs1Tfk+G36j6LGg7FDB2y5 ZDFwc8OlDvHfkftjDqmq8wkYtu1mbfAPqBzmpkAj1r2g4Sz4lYMfBHMqi9HkIQgxr6h5 bwK9qsgvVMWsTIcYo95MHPKCZgokdvyTty+dmLax1+UG1gHLJlLL5Ms5WY0nCZkZBm4J U+yBsm2SfjtO3bAJyU5mZULWonbXL8u/3L1jJw+YICNq88WFn1A1IDlA5ePOPhanu5zj f9Tg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si17474355plm.117.2018.09.10.05.41.34; Mon, 10 Sep 2018 05:41: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; 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 S1728522AbeIJRd6 (ORCPT + 99 others); Mon, 10 Sep 2018 13:33:58 -0400 Received: from terminus.zytor.com ([198.137.202.136]:43333 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbeIJRd6 (ORCPT ); Mon, 10 Sep 2018 13:33:58 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8ACdd9F1846821 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Sep 2018 05:39:39 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8ACdd2o1846818; Mon, 10 Sep 2018 05:39:39 -0700 Date: Mon, 10 Sep 2018 05:39:39 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yabin Cui Message-ID: Cc: torvalds@linux-foundation.org, hpa@zytor.com, stable@vger.kernel.org, yabinc@google.com, peterz@infradead.org, linux-kernel@vger.kernel.org, namhyung@kernel.org, tglx@linutronix.de, jolsa@redhat.com, alexander.shishkin@linux.intel.com, mingo@kernel.org, acme@kernel.org Reply-To: acme@kernel.org, mingo@kernel.org, namhyung@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, yabinc@google.com, stable@vger.kernel.org, hpa@zytor.com, torvalds@linux-foundation.org In-Reply-To: <20180823225935.27035-1-yabinc@google.com> References: <20180823225935.27035-1-yabinc@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/core: Force USER_DS when recording user stack data Git-Commit-ID: 02e184476eff848273826c1d6617bb37e5bcc7ad X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 02e184476eff848273826c1d6617bb37e5bcc7ad Gitweb: https://git.kernel.org/tip/02e184476eff848273826c1d6617bb37e5bcc7ad Author: Yabin Cui AuthorDate: Thu, 23 Aug 2018 15:59:35 -0700 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 14:01:46 +0200 perf/core: Force USER_DS when recording user stack data Perf can record user stack data in response to a synchronous request, such as a tracepoint firing. If this happens under set_fs(KERNEL_DS), then we end up reading user stack data using __copy_from_user_inatomic() under set_fs(KERNEL_DS). I think this conflicts with the intention of using set_fs(KERNEL_DS). And it is explicitly forbidden by hardware on ARM64 when both CONFIG_ARM64_UAO and CONFIG_ARM64_PAN are used. So fix this by forcing USER_DS when recording user stack data. Signed-off-by: Yabin Cui Acked-by: Peter Zijlstra (Intel) Cc: Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 88b0193d9418 ("perf/callchain: Force USER_DS when invoking perf_callchain_user()") Link: http://lkml.kernel.org/r/20180823225935.27035-1-yabinc@google.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index abaed4f8bb7f..c80549bf82c6 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5943,6 +5943,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size, unsigned long sp; unsigned int rem; u64 dyn_size; + mm_segment_t fs; /* * We dump: @@ -5960,7 +5961,10 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size, /* Data. */ sp = perf_user_stack_pointer(regs); + fs = get_fs(); + set_fs(USER_DS); rem = __output_copy_user(handle, (void *) sp, dump_size); + set_fs(fs); dyn_size = dump_size - rem; perf_output_skip(handle, rem);