Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4178485pxb; Mon, 8 Feb 2021 09:43:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfaqTqbF65GZhIwrCYL00NuQoZlKPx6n+ilFeLH/bfg1cDRt4HffAFKVl5vn4BKt+r2Hpm X-Received: by 2002:a50:fe11:: with SMTP id f17mr17968396edt.88.1612806196245; Mon, 08 Feb 2021 09:43:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612806196; cv=none; d=google.com; s=arc-20160816; b=kiwY9RBMq6LzKsMVmNsrs4N+aQHkAd2YQNl/eHptOIaqV9Tq7jWuqEHWNL2mSjrQEp neW6LUSV59k6msK0hHO7GfKYlMA4nZun5TXdIBrBMWEmLm4rtxM3LZhYvBT7fQqfMQE2 gYjaieWtJr0b0bWEEKG3Fvn3dLEaWrgIApBZrsmwFhvRzLepYb3Erj7J0vWaaDzbrgrs 46vG/LiPXB4KvdWsWrDN3iR04ib5ZpLanbQ0uEXx4z4YTttK6P3SMvgQ239yaKgIxVTa GfZ0D0DyHs1B9DttboQNMUl5wv6fYyeqvOJ4N/f7PQmR2sdIRZRuD7ObxOHWDU29wMKJ hFMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/wS8+ek9gSU0zp702Cb+cfPyle+8LrslhN8ZkkwEF/0=; b=zRLGkxexlvUViNr5EJcn3UYepLTW5pScUvQarqucgLDd2igCfKR/Lva1tfzAX87IT8 jlf7jyQ45ToDCCV+WUyhVig240FF7Ij5XeRX5RNAL6b4CPbwsvLSTzj277p36fv/k0Bo DS3xn6uk7OqcNbDbHtITAr0TzrSZqaaEirR+EFeQzE30DtXp9QjoNTNBJNoINmwd7Qj7 xA30eg2tK+ktwkTWIQFJuAU+Avc4y/c+8dtpQewndVt2hbaBtBmHr1ZSWlkAjrPrZPLY H+13PHMGadeSelpBoBGX90du1xqdo9MmEvcB0koE3wOgajO7BUK5U/vIizfG3dtm7PMH ODWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="b/n/30C8"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs15si11423655ejb.579.2021.02.08.09.42.50; Mon, 08 Feb 2021 09:43:16 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b="b/n/30C8"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231235AbhBHRi5 (ORCPT + 99 others); Mon, 8 Feb 2021 12:38:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:37210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbhBHPaZ (ORCPT ); Mon, 8 Feb 2021 10:30:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51B6F64ED2; Mon, 8 Feb 2021 15:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797430; bh=1tgGhcLc+jYFzdUPphBAPSNPF7jH8HDiSa5BXeX4B2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/n/30C8iKjqzGjNtBKMD6tYC4uja6ht9bWs1NODi60gedURPdtcICfiE4X8me0eE hacaDqnLuTxjXzv2lHG0q3MHp+VKEtWaw8eouhWIJOZVKcdETKysnyGZftYYU9wLgQ jm1kDWj5a5FHq+0kjOPe+2uXpKEz+xyF7Zu+LtA0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lai Jiangshan , Thomas Gleixner Subject: [PATCH 5.10 108/120] x86/debug: Prevent data breakpoints on __per_cpu_offset Date: Mon, 8 Feb 2021 16:01:35 +0100 Message-Id: <20210208145822.689200218@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lai Jiangshan commit c4bed4b96918ff1d062ee81fdae4d207da4fa9b0 upstream. When FSGSBASE is enabled, paranoid_entry() fetches the per-CPU GSBASE value via __per_cpu_offset or pcpu_unit_offsets. When a data breakpoint is set on __per_cpu_offset[cpu] (read-write operation), the specific CPU will be stuck in an infinite #DB loop. RCU will try to send an NMI to the specific CPU, but it is not working either since NMI also relies on paranoid_entry(). Which means it's undebuggable. Fixes: eaad981291ee3("x86/entry/64: Introduce the FIND_PERCPU_BASE macro") Signed-off-by: Lai Jiangshan Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210204152708.21308-1-jiangshanlai@gmail.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/hw_breakpoint.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -269,6 +269,20 @@ static inline bool within_cpu_entry(unsi CPU_ENTRY_AREA_TOTAL_SIZE)) return true; + /* + * When FSGSBASE is enabled, paranoid_entry() fetches the per-CPU + * GSBASE value via __per_cpu_offset or pcpu_unit_offsets. + */ +#ifdef CONFIG_SMP + if (within_area(addr, end, (unsigned long)__per_cpu_offset, + sizeof(unsigned long) * nr_cpu_ids)) + return true; +#else + if (within_area(addr, end, (unsigned long)&pcpu_unit_offsets, + sizeof(pcpu_unit_offsets))) + return true; +#endif + for_each_possible_cpu(cpu) { /* The original rw GDT is being used after load_direct_gdt() */ if (within_area(addr, end, (unsigned long)get_cpu_gdt_rw(cpu),