From patchwork Thu Jul 16 15:19:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 235650 Delivered-To: patches@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp888635ilg; Thu, 16 Jul 2020 08:20:09 -0700 (PDT) X-Received: by 2002:adf:f20a:: with SMTP id p10mr5849347wro.41.1594912808869; Thu, 16 Jul 2020 08:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594912808; cv=none; d=google.com; s=arc-20160816; b=M51kijLsfAw79tLSEr84zSwdgskY2qpSSvvKiefc3g1/CnUsLUAZz2rTntrW2Nmrum 9uD61lRanfHE9Plej/KV6oXbuSXWZRg/eUx2Sv2o63eKxPphibNchEK+cToQn843ZG+c GBKmZeuXFP3yj3MQNDIUuH98uVrDMEj/wZFgArborYfGoNdH+/gZY2Na6XAqQOiUs7X5 nY/eudyn49Gmmdax3aQJyMQPQD5/R1GKK3VqfgQfYdRPEY4tBar0wHHapKL6wChqjNVI G2EUInWvtzKJSTwrgT6jOaptiNIHE17M/9zXnhae3PftTgfS6nQy43VKLJ18mGye3SU0 PuqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ay69b5loZmqipTP77uDUcCD3CMZjdEh7hP0bruwli1k=; b=NirOrz1VZPlZ/LBnh+Gj8ZWWWQbM2Z6jG9HJWA54bTJeGiKWwdILUdUpsIehF6jlCg S/DEUa1BK7L1Js+q87iJSLtj3jJZnT9cMlEIjRnNoT926fEH/foNnGBtZM0Ye7o/9jzo 2KVDV8uGpQXTMgvdYjBf7kh5tuF86+rC0rYJkTf1MKtnMEGl998L6NnCuu2qza9LCeBD uiQVAzJbXYCEBX/pZe3q0xwj2KTrSAEyQHXnVlKgYON1c7kpFUrP5OoJ7vEhQZH9Y+pJ Ary0PeKzkfqQKdkFFP9l24OyMR6pIoS1RZgiXNlWpkEcjYmV/TBuk8fZi/3ZR927WU69 Ax8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d0RdbT8M; 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 74sor3124293wma.23.2020.07.16.08.20.08 for (Google Transport Security); Thu, 16 Jul 2020 08:20:08 -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=d0RdbT8M; 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ay69b5loZmqipTP77uDUcCD3CMZjdEh7hP0bruwli1k=; b=d0RdbT8MqbY1ZnJgHeIEd2m0zeXY1i+Lj+PmqGKQmqaLAJiZKpFm3oxosLkai3MZ0S 9GSppOaArDiTYBQvupivke+FSk3+Cg0P1TwPggyBEFA8P2wxtI30qV6Y7JyAOlakSWrI 7XT1YjyZjvfmUCiUFYRAy0BjbJXCYgz1uFTdgl7DUv/IAVH7i1uRm+edatyqJ7NVoblc JvKimwXgxv4KzksqAgPh/JXDw+DSf64M4xeWMlQ9bYXHSivCfwoxQFDZJLmqnaay/7Vk 4zxaoCVUrydKo2k8oILHDbWI30tA8KvW6RT2eovrOz6JbQEb01y+dmuMDVMqA/Je4xhZ aoXQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ay69b5loZmqipTP77uDUcCD3CMZjdEh7hP0bruwli1k=; b=jI0rek8PFPpYgQLykGhwDzQckAPJbM/xzXuCCYjhNGp8NQ8tjzM3f5ptAtTb3UMeD1 p2Bc04lfvW39hgqkrQZQVZ0vH/P43ThWvdf+aN3pSVnZwlLNoltknJmmoUo50siaEaTx rAQknWbDCGW4W3RM36xi2ovCJdR844YScedyvnvIEmDn5p1KQoypH7OwMD/O5j82HybW UoQh6l/MsBS4VF6yAbSI41sN4pmr+A1f8v2k4c69Nsaev9PothfSNTuaTg0iELJ/TFnq Ey6R10JJl+WTQWLi3+pevMMM6n9uef1TJsZPUOJJsMxLDTOo5c9w6gt0IQoNdasYj02C Z78Q== X-Gm-Message-State: AOAM532eS2Mob+mtxF1SqQOpKK8d3gYBvl3aSjkNw/SmPbMIk4H3iA2o J8fyn0/oQ7VEisERVE2dyg0hYeyc X-Google-Smtp-Source: ABdhPJytl8835REhXfZSH+IBujrm7NkmVewsF6kxmqbPplKu/iOWB6yHc9BFpHQOHY51qHxdg66EWQ== X-Received: by 2002:a7b:c208:: with SMTP id x8mr4851699wmi.49.1594912808280; Thu, 16 Jul 2020 08:20:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 08:20:07 -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 3/3] kgdb: Add NOKPROBE labels on the trap handler functions Date: Thu, 16 Jul 2020 16:19:43 +0100 Message-Id: <20200716151943.2167652-4-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200716151943.2167652-1-daniel.thompson@linaro.org> References: <20200716151943.2167652-1-daniel.thompson@linaro.org> MIME-Version: 1.0 Currently kgdb honours the kprobe blocklist but doesn't place its own trap handling code on the list. Add labels to discourage attempting to use kgdb to debug itself. These changes do not make it impossible to provoke recursive trapping since they do not cover all the calls that can be made on kgdb's entry logic. However going much further whilst we are sharing the kprobe blocklist risks reducing the capabilities of kprobe and this would be a bad trade off (especially so given kgdb's users are currently conditioned to avoid recursive traps). Signed-off-by: Daniel Thompson --- kernel/debug/debug_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.25.4 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 4b59bcc90c5d..b056afb1beec 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -183,6 +183,7 @@ int __weak kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return copy_to_kernel_nofault((char *)bpt->bpt_addr, (char *)bpt->saved_instr, BREAK_INSTR_SIZE); } +NOKPROBE_SYMBOL(kgdb_arch_remove_breakpoint); int __weak kgdb_validate_break_address(unsigned long addr) { @@ -315,6 +316,7 @@ static void kgdb_flush_swbreak_addr(unsigned long addr) /* Force flush instruction cache if it was outside the mm */ flush_icache_range(addr, addr + BREAK_INSTR_SIZE); } +NOKPROBE_SYMBOL(kgdb_flush_swbreak_addr); /* * SW breakpoint management: @@ -405,6 +407,7 @@ int dbg_deactivate_sw_breakpoints(void) } return ret; } +NOKPROBE_SYMBOL(dbg_deactivate_sw_breakpoints); int dbg_remove_sw_break(unsigned long addr) { @@ -573,6 +576,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks) return 1; } +NOKPROBE_SYMBOL(kgdb_reenter_check); static void dbg_touch_watchdogs(void) { @@ -811,6 +815,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, return kgdb_info[cpu].ret_state; } +NOKPROBE_SYMBOL(kgdb_cpu_enter); /* * kgdb_handle_exception() - main entry point from a kernel exception @@ -855,6 +860,7 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) arch_kgdb_ops.enable_nmi(1); return ret; } +NOKPROBE_SYMBOL(kgdb_handle_exception); /* * GDB places a breakpoint at this function to know dynamically loaded objects. @@ -889,6 +895,7 @@ int kgdb_nmicallback(int cpu, void *regs) #endif return 1; } +NOKPROBE_SYMBOL(kgdb_nmicallback); int kgdb_nmicallin(int cpu, int trapnr, void *regs, int err_code, atomic_t *send_ready) @@ -914,6 +921,7 @@ int kgdb_nmicallin(int cpu, int trapnr, void *regs, int err_code, #endif return 1; } +NOKPROBE_SYMBOL(kgdb_nmicallin); static void kgdb_console_write(struct console *co, const char *s, unsigned count)