From patchwork Thu Jul 16 15:19:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 235647 Delivered-To: patches@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp888572ilg; Thu, 16 Jul 2020 08:20:05 -0700 (PDT) X-Received: by 2002:a5d:6202:: with SMTP id y2mr5402078wru.32.1594912805213; Thu, 16 Jul 2020 08:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594912805; cv=none; d=google.com; s=arc-20160816; b=zh0VtQ/47K7tlG2df0SqKOoCW3DZCwQQC02Sh6XrzwuDQe+Os9hhlzBuyyfT4VyOS8 BJDrVWyo3BPz4kmmE6h1IQYZ+xomqUPuaRVAVC4agHAMiY9pjaNBrLYhZluBFkXM/G2D 4PSfgVx6OKRff95DwXT+NKzxzsNj/os2FS5z3pG87Y3q9wbkQPIS+ULYDMCu9MjJkDfy 7W6esp6bX6+gi1a8UV/lbyJKCFBqUXqsq+lyKS/htZtOSk/5oA5XXw/6EMw2m1TbKH6e BhZhjz3+clrkqdj7aqPtDWjnf+E2qx2eOQ4kSKQalu/eFxxjVshnqU7RluvT3WyBdpeC SHcQ== 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=lvV+kZFJ+bicRAujhVqigbzFyFgwaE2AZB7+TjHL0wQ=; b=SaQDHPzeZYdlsxAKUFvD5QpkT3IekXWTJxgtQ0IfJYmf7j5LQGCNVJ1OD+OxX20NZI uZ+A0qbGF4exG8ppVIOJgbcFo4OHLSOyUqvRvXgPv2j+O8gqd/Q75zvClfbzxXfJgNMK PZQ/zWLlMbLp4kxHA6H11GD5mcsa+uqTZRp+MOeNoYloasDjZZLT/pJMsJwyEresYQ6l ADkHiJOYtohpxx7jsj+Bzh8RyIFbbQdGbhF3s9bDZEn9KEGldFKWEMhbIypc7Rz/rolQ xH1KyqpzIX1szmnDzmD6P2SorXBqlwDKNjsbl97mM1X88Im2gHuVy8oHr8Ib9MQEUmNT in5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EKI/7sa6"; 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 b11sor3301665wrw.10.2020.07.16.08.20.05 for (Google Transport Security); Thu, 16 Jul 2020 08:20:05 -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="EKI/7sa6"; 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=lvV+kZFJ+bicRAujhVqigbzFyFgwaE2AZB7+TjHL0wQ=; b=EKI/7sa6o0FAd3JpJEwHJfrgB5xUNL0OcbuVaKplDph58T1lYOzZjdBhP5dKoWmGYI sXeEjWOazGVnXWV0Yc0TQC4ZiOaCbPkx83Q9aJSunxrfALQeqcykNaJ9XSeMBNrgiRY+ LaM/JhelnlGBhQmf+ZTb+y4UJ9M8KgBkFRlwSxlbELIRG+M229S++tv1nUvFQdZdAHVX Agkwi2ecorBoRct3RZvOKHVpZXe6yVQIvgaWbKVjw0KWboDskHI/7dvFkx1eaE3z5KJa gOzvKZkPl3QT+rAtFg+vDZqX/Fd2qbPOQpMaA2NG274TTDPe8yevyQSl8ZNcUnicKilF 94RA== 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=lvV+kZFJ+bicRAujhVqigbzFyFgwaE2AZB7+TjHL0wQ=; b=TpLXoENWZ8W2/FrJ6oqcGXuZRIF2M7CGMyN9rSGSTot6UBdDD4om7q1UMxs/OZajnq HtWnpJ/bJtxpEdUmJMN7HZtt8XbIiJayHo5rsNGgUspAJLS9qcSqp3NjJo78MeX+D1P7 ZWyhz7486CdYXffPGbgPc698y1EQcjPYr8sRW4jPUFPJvLWpmzCJyr44WFgemJvbNqSq dcU2yxNx1MBQhQwOIup37GDZQuNSiNAS0bKdBdd8yo/2ZvKSh2SpIBxbjXaCbQRCJlEt r+DOEB4GX/48yv7/lwix3v9tynB372Ez4afB8GSeKgZaMnrZgnF6WsehNSh+N+P1IAWt v2vA== X-Gm-Message-State: AOAM5338n0jSOzDmJdAHjjS+DNTiupeRtmduSX7ZrJ6Wbfa5hfwcLNOW UOfYXmcIWJHwNh0MR0QOxZNHSbI2 X-Google-Smtp-Source: ABdhPJyrDSufKPQY0n9MIqAfHzqEFnuWTuX77ZT7VEwVUVOGP/zuzHSlc6Ko9MMqOb5l7XR70/gnnw== X-Received: by 2002:a5d:420b:: with SMTP id n11mr5493759wrq.91.1594912804657; Thu, 16 Jul 2020 08:20:04 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id u17sm9877687wrp.70.2020.07.16.08.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 08:20:03 -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 v2 0/3] kgdb: Honour the kprobe blacklist when setting breakpoints Date: Thu, 16 Jul 2020 16:19:40 +0100 Message-Id: <20200716151943.2167652-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(). Daniel Thompson (3): kgdb: Honour the kprobe blocklist when setting breakpoints kgdb: Use the kprobe blocklist to limit single stepping kgdb: Add NOKPROBE labels on the trap handler functions include/linux/kgdb.h | 19 +++++++++++++++++++ kernel/debug/debug_core.c | 25 +++++++++++++++++++++++++ kernel/debug/gdbstub.c | 10 +++++++++- kernel/debug/kdb/kdb_bp.c | 17 +++++++++++------ kernel/debug/kdb/kdb_main.c | 10 ++++++++-- lib/Kconfig.kgdb | 14 ++++++++++++++ 6 files changed, 86 insertions(+), 9 deletions(-) -- 2.25.4 Acked-by: Masami Hiramatsu