Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2150571pxk; Mon, 14 Sep 2020 06:09:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaDBs6QprLixQIOGhhjNi5pKhyq7IBxXMNuTC9r6JMm6A8hzJ/bUnRldiQuGP8rWQkjaKJ X-Received: by 2002:a17:906:11d2:: with SMTP id o18mr14269764eja.420.1600088978848; Mon, 14 Sep 2020 06:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600088978; cv=none; d=google.com; s=arc-20160816; b=pfv77NO1R7QkzkORYQMGMFu6YCWqWENo4mVVAMu7CA8h4o/l6eCYiMU6/VMkvSJA0o 5kjWS63D7ZcQ9X6KlswK2SnXMEzzL4MmrY5Pqe6bthnRfUKc3lEg36/anjMYN45ynIth 1onU3JFc7r8OKfVgSYAJ2Ukxm3wMYC0vOp4+AvZvq+QbLqGIiiT/2USa4qlbQnSfNS1o z5R7LfuvDt6GWInKvb+4j+2QvXL9//+gcjkiOvhxmEad/DH1pJru3QZ747JMv+GY2pY5 OfQE+MoyVmzUjZPEHc3hQFxL8IpKBSF0Nc+0fZy4awP0qxrUF73XP8rSV5NDTFMSUD9h 1zIQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=j11jZizj6KykwFnlMpZUSmD4ixbxGJ3f+H4sr6REKAc=; b=rwpzLtt8m+itJe5Ma8pvSCV8rXjHUU/gj2uhlNohssCVVYQA4y2+u7+ugnoCVvMq3K wZ78Yf36hrGE/G2onArm8f+JWh3DU6nXA8QO2qFj2ircCc+3NVykOwcXu5EwMUe371Oz FpDzdblhpzzajsEn7Vu9hkYONaSOvWmaL7yUEzYEWbeV0i7Vx6v6XfL1BzMsNXYcxNEH QpuwJGVTGLrm8HKHt2kMtfCkHpiQIoEzDlw1fJxY24VMuC66O6HNep6hk0/8QbfnkQd5 /NbjYduxvYfDiX+oBrB4eIuUEpalBJ9mBBSx2N7OL9Hj3u9NlZzHh+IGfF/1Zeb+UIXN uz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U5sDUJFQ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr7si7082073ejc.447.2020.09.14.06.09.16; Mon, 14 Sep 2020 06:09:38 -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=@linaro.org header.s=google header.b=U5sDUJFQ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbgINNIK (ORCPT + 99 others); Mon, 14 Sep 2020 09:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgINNCF (ORCPT ); Mon, 14 Sep 2020 09:02:05 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C705AC06174A for ; Mon, 14 Sep 2020 06:02:02 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id z9so11182410wmk.1 for ; Mon, 14 Sep 2020 06:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j11jZizj6KykwFnlMpZUSmD4ixbxGJ3f+H4sr6REKAc=; b=U5sDUJFQGkIzR4rv2WYyCEAIfiTmifUAhGXlILPOKVoorTjbw4oLiuAFTBoRzYx0ri l7SDFvtolHpXNL6iGcVzBS1H5jSmDDlXbOqJLF1J3WwIKyFl/PPtRvncDFLus+y/CNCx o0zx8DAEFW8VIa/cwUBx81/a2fGm/vK1WaCRlHaisfadEfW6aw0YCHLQiVMXINzoytlN bDIxdwbbxzRWs7QYkW3jWldNDCu7xcwWyvbxUR1iFefkpyTfJpOrSIgaGEwJanBvHVPL u1DlClDDd/bHNPtXcaBW0N9CiYQdMp/5YFjqcwgcTab8jL0X12Qg6kGCqu0DeHiknJ3O KLpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j11jZizj6KykwFnlMpZUSmD4ixbxGJ3f+H4sr6REKAc=; b=YBYY7FqZBkaRoIJfHnwexgKwVe16rPNhHDo6ne1/V4kaGpl0AE9lmaDRcdDmVjZhZ5 9sehXxcrYxlraEVoKOOxIScn144S1ef8Lo+O5s3fP3RTic2y7nG3U8f8ZmIYVFSoc0Yg cKiSG1D8gc8L1TIQ1d4wXmhpifncI+YAvA48nEBumCCYsThqIO1WZ3jfWcEirW1O05Hi Ms+bU3kRKSXyXO85Ef4jALRdfgzMhPtPbzwDDCqpvmtW4yUmVMnt6kPQsCsLk3imCQSK TcPBoeZxmABguueMPjtDe1eqQoqYRtItc+OEYX8V+DleNB4CDwem4fR2TQpR3FSnV+lo Kiaw== X-Gm-Message-State: AOAM533SHOUUmff1nZja9eszMLYZ0E7njTYUNTU6QmJlGqdQnN20O65H q6IK6sQkpMqYtJ+yssxCuAfoUA== X-Received: by 2002:a1c:7502:: with SMTP id o2mr14623468wmc.29.1600088521467; Mon, 14 Sep 2020 06:02:01 -0700 (PDT) Received: from wychelm.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id t6sm23420983wre.30.2020.09.14.06.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 06:02:00 -0700 (PDT) From: Daniel Thompson To: Jason Wessel , Douglas Anderson Cc: Daniel Thompson , Peter Zijlstra , sumit.garg@linaro.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, will@kernel.org, Masami Hiramatsu , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v3 0/3] kgdb: Honour the kprobe blocklist when setting breakpoints Date: Mon, 14 Sep 2020 14:01:40 +0100 Message-Id: <20200914130143.1322802-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kgdb has traditionally adopted a no safety rails approach to breakpoint placement. If the debugger is commanded to place a breakpoint at an address then it will do so even if that breakpoint results in kgdb becoming inoperable. A stop-the-world debugger with memory peek/poke intrinsically provides its operator with the means to hose their system in all manner of exciting ways (not least because stopping-the-world is already a DoS attack ;-) ). Nevertheless the current no safety rail approach is difficult to defend, especially given kprobes can provide us with plenty of machinery to mark the parts of the kernel where breakpointing is discouraged. This patchset introduces some safety rails by using the existing kprobes infrastructure and ensures this will be enabled by default on architectures that implement kprobes. At present it does not cover absolutely all locations where breakpoints can cause trouble but it will block off several avenues, including the architecture specific parts that are handled by arch_within_kprobe_blacklist(). v3: * Dropped the single step blocklist checks. It is not proven that the code was actually reachable without triggering the catastrophic failure flag (which inhibits resume already). * Update patch description for ("kgdb: Add NOKPROBE labels...") and added symbols that are called during trap exit * Added a new patch to push the breakpoint activation later in the flow and ensure the I/O functions are not called with breakpoints activated. v2: * Reworked after initial RFC to make honouring the blocklist require CONFIG_KPROBES. It is not optional but the blocklist will be enabled by default for architectures that CONFIG_HAVE_KPROBES Daniel Thompson (3): kgdb: Honour the kprobe blocklist when setting breakpoints kgdb: Add NOKPROBE labels on the trap handler functions kernel: debug: Centralize dbg_[de]activate_sw_breakpoints include/linux/kgdb.h | 18 ++++++++++++++++++ kernel/debug/debug_core.c | 17 +++++++++++++++++ kernel/debug/gdbstub.c | 1 - kernel/debug/kdb/kdb_bp.c | 9 +++++++++ kernel/debug/kdb/kdb_debugger.c | 2 -- lib/Kconfig.kgdb | 14 ++++++++++++++ 6 files changed, 58 insertions(+), 3 deletions(-) -- 2.25.4