Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1239073ybm; Sat, 30 May 2020 02:59:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6G+jaD+VCmOb9yO6L0NRom/XWt9Inty7B4YhRnPbhg4nOlrmODWPYrXHXKHs/8Cp5CfqJ X-Received: by 2002:a17:906:69d1:: with SMTP id g17mr6854125ejs.521.1590832795673; Sat, 30 May 2020 02:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590832795; cv=none; d=google.com; s=arc-20160816; b=AUo9ToWAbpHk0TxlZ1AoZsy5vTnBSJe06aHC4GXZ1hbCFKREO1W/nmmGa79TDyBeFP ez86YQY1q7fuqD9Y2MjqL6+lLgmSkvAfqOZGj0x6z3oAA9sRK9S2IpEji9OoCNn8H/XZ RWmKtmGc1oPdj9oRVJpavaohRFJ1DXAzr8POfErksxsdpPiqS4AN9YkBuIENPTBo5ujJ 9X4wr6nEkucpCQKXVVumcCQHw7GGM0/p41m9kVwK7yLmgZ26Dyt//ADrNS+UVABurIyr sTmKc+G/8B3aeQatCG2us0jdeUdPnw6P+3B7VVc0skXmqEJAPeyNMXf9JG+tenna0sds c2sQ== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Lwy5FtHHy7FZr4Kv2l7BPB+EX0N1LmnJFXkySLdRUxY=; b=qjDVYpxxwWiHtwyBWxPx7Uncvv+0qImslb17leKNnWVOE3LR65I/1lbTcdtpOBPZnW NVe5K+eSAG8ywOk/6lz6r0YDrxra3bCjfd68qX0g+PfEVAPDMBrjiQtHFW8qe1ithUXL nYj69ri7ZgCbHscCX8EO/hMlWVt/glFQiaMcJOfAfYozuol/rV/V7dWkfi/o8zFSBRzu tMA99L9KDm/DYJcL0ER6xtcVuProBPHMCignX79ZObLdmBOzKPqurVDMIsPYdTG1O5qA nvCKCZb6J7TEw22h+pRF1fLKlMgiJ+NofBzCd82K0mp4wVXoFwGe1CDwb+Zntm4ml1fu NT5g== ARC-Authentication-Results: i=1; mx.google.com; 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 q19si6754330ejt.484.2020.05.30.02.59.32; Sat, 30 May 2020 02:59:55 -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; 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 S1729014AbgE3J5j (ORCPT + 99 others); Sat, 30 May 2020 05:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728971AbgE3J5a (ORCPT ); Sat, 30 May 2020 05:57:30 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7F1C08C5CA; Sat, 30 May 2020 02:57:30 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jeyF0-0002s9-FT; Sat, 30 May 2020 11:57:22 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 1FED31C032F; Sat, 30 May 2020 11:57:22 +0200 (CEST) Date: Sat, 30 May 2020 09:57:21 -0000 From: "tip-bot2 for Lai Jiangshan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/hw_breakpoint: Prevent data breakpoints on user_pcid_flush_mask Cc: Lai Jiangshan , "Peter Zijlstra (Intel)" , Thomas Gleixner , x86 , LKML In-Reply-To: <20200526014221.2119-5-laijs@linux.alibaba.com> References: <20200526014221.2119-5-laijs@linux.alibaba.com> MIME-Version: 1.0 Message-ID: <159083264193.17951.13800361200842101495.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: 87aa9b64e0ccb779db3970e2e9af1cc5930c2c3d Gitweb: https://git.kernel.org/tip/87aa9b64e0ccb779db3970e2e9af1cc5930c2c3d Author: Lai Jiangshan AuthorDate: Fri, 29 May 2020 23:27:32 +02:00 Committer: Thomas Gleixner CommitterDate: Sat, 30 May 2020 10:00:06 +02:00 x86/hw_breakpoint: Prevent data breakpoints on user_pcid_flush_mask The per-CPU user_pcid_flush_mask is used in the low level entry code. A data breakpoint can cause #DB recursion. Protect the full cpu_tlbstate structure for simplicity. Signed-off-by: Lai Jiangshan Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200526014221.2119-5-laijs@linux.alibaba.com Link: https://lkml.kernel.org/r/20200529213320.955117574@infradead.org --- arch/x86/kernel/hw_breakpoint.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c index f311bbf..fc1743a 100644 --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Per cpu debug control register value */ DEFINE_PER_CPU(unsigned long, cpu_dr7); @@ -264,6 +265,16 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end) (unsigned long)&per_cpu(cpu_tss_rw, cpu), sizeof(struct tss_struct))) return true; + + /* + * cpu_tlbstate.user_pcid_flush_mask is used for CPU entry. + * If a data breakpoint on it, it will cause an unwanted #DB. + * Protect the full cpu_tlbstate structure to be sure. + */ + if (within_area(addr, end, + (unsigned long)&per_cpu(cpu_tlbstate, cpu), + sizeof(struct tlb_state))) + return true; } return false;