From patchwork Sun Sep 27 21:15:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 313600 Delivered-To: patches@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp2819466ilg; Sun, 27 Sep 2020 14:16:14 -0700 (PDT) X-Received: by 2002:a1c:8115:: with SMTP id c21mr8532892wmd.153.1601241374826; Sun, 27 Sep 2020 14:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601241374; cv=none; d=google.com; s=arc-20160816; b=PIh6IzqyMNUi80zgZ8nJu7n6+XoeArcfXCyocBgBuUix/sEmizTAICczeTTOR6Wzqm sdT8kjYk9JJOxBy3IkM6V0yRKj2d8DGe68OU0mLB3WmXj/OG3KF+HGsG8CgdomJc/vUB vMHQPn2lQC/92pTHzPxmcWYP3xRk8vZ1qNVB5G6qqKNY13cPJ1HkMGE37F37lBrnQH47 78dZjL5Yn7w3dUJ5ESVOtEw0pbUH6HsAsSuyp9tGDBmO7UL+ovRtNyUETxl6t0YhqvWw hBu8T2lxHmiaSyW0QDJ7KiIvpqSKMsryOcxk/JJe34W9vBp6VMWAsZkP5+dPMTFeMiqN j/+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=yzXzJiEQzaPFqdy2MIXLtzA73Bjzgyzv9JbfCBicRRs=; b=t6eR1gFEcyNbATWSe7kApTyhbs5YPDywYyaCVkbUzTfdD3enueQ8UcznRwz4FaT7/e 7boebnQmaGItS40NAQpfkz1K01l8Je0mGMRbD6+/5UxIa0uoMNlSNI90WTpKTlRAPX3a wfyLYG4/+eSBhSlb8RTzF3e1EFj3x8BLUdDPHTqvyHokfX+GEhLu/IPI1htPvcOZG+st 0xXdOmCDZ/Ep+EUcdZp4EDAOhcC1VAzii+ZzAuNAS95/BGBq1gGNuYqO+1PTWekJ+nyz kWx2ThvcPZiTS1cilQlwgwvEzF31kRHu4Oo7wa1hnWWLEEEAGQ3W7BDsVez51a5nvztm YvuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=igyIzAGH; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z77sor2683786wmc.4.2020.09.27.14.16.14 for (Google Transport Security); Sun, 27 Sep 2020 14:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=igyIzAGH; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=yzXzJiEQzaPFqdy2MIXLtzA73Bjzgyzv9JbfCBicRRs=; b=igyIzAGHvljICFK+IdbUtULqLeHSPyp6JXzjwbaqe8JGlP/t81CSxr057hte0SgvqC s1GdSXzsLau3c8d8TvlZ2X6nHK+u489twWeKQCcjTLHtFmW8xAO/Sce0ReF+nHi4WMFp v8ym2R5v+4LFIuEyudixhrzuyMlww1UrKQETRlCpwXD9TvXM20ugVZfrn2viNTYhvCki oc6P14j/c2TrJP4jtnN9I3dF7FmkEc5HLL4Jj1ftXuXUjxZULyCrpzyg/nbjYMNj4bdw BnOi9r9TdbodLirQuJrahQhkVWaCOlph68bnak4hOwoXMgG6uMXksvEXXgZAMbVEwU3M IFBQ== 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=yzXzJiEQzaPFqdy2MIXLtzA73Bjzgyzv9JbfCBicRRs=; b=X7cpth6Dq3yW10EUc8GitLmh3ZsOPkpvRtSS231DlWttv7kTK4E1s9XMLF/Dbe0Q+k XCsqhtvR5NUW/dBaxL/iPBZVvRNoI4ns+X1ojYkYBDIhgSqfg9SkW3q9NmwGe/D7/Vo6 1lar/XWILIDD9scAMM6cspcB4YOkoNYoOAKXuLn1oSOJpq3x8sIRwwpUL3pW68vdjjPA cv6WWm30//XgKKDQB83GWzit4DpDWxn5oUo2+bE3yPDn0bod5IT6JQYY3bpQV1/u71s0 dfMtwin/0l4O8WAA5VCH1fspxPaUXd5S+b9p4tLaKYUzvyDRT2Ar9m7fXxIB5tUaahMS FCNw== X-Gm-Message-State: AOAM5323Ka5EotM3lBrKpVIFkVJwQjvHzCAdwWVc9Popki9l9omNumcw AKybJFjSMn0YQzcyc169UlrVs5QZGuHnY7WI X-Google-Smtp-Source: ABdhPJw6VoFcPo1scinS68irhUR+vggXWVATUkZHK+aYqRklkunCw9o1l/IXKGL2BA0qd2LyeF3Epw== X-Received: by 2002:a05:600c:2f8f:: with SMTP id t15mr8611991wmn.41.1601241374477; Sun, 27 Sep 2020 14:16:14 -0700 (PDT) Return-Path: 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 s17sm11396676wrr.40.2020.09.27.14.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 14:16:13 -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: Sun, 27 Sep 2020 22:15:28 +0100 Message-Id: <20200927211531.1380577-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 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(). v4: * Fixed KConfig dependencies for HONOUR_KPROBE_BLOCKLIST on kernels where MODULES=n * Add additional debug_core.c functions to the blocklist (thanks Doug) * Collected a few tags 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 now 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 | 22 ++++++++++++++++++++++ kernel/debug/gdbstub.c | 1 - kernel/debug/kdb/kdb_bp.c | 9 +++++++++ kernel/debug/kdb/kdb_debugger.c | 2 -- lib/Kconfig.kgdb | 15 +++++++++++++++ 6 files changed, 64 insertions(+), 3 deletions(-) -- 2.25.4