Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1409629pxk; Fri, 4 Sep 2020 08:42:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyulMvLzvsYQR/tfAjUiE1K/cEaT5tRjt9nMn3X2BpXFCQr/vucREJuQ9pf0TBPNZIDCXzP X-Received: by 2002:a17:906:aac7:: with SMTP id kt7mr7959130ejb.548.1599234126617; Fri, 04 Sep 2020 08:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599234126; cv=none; d=google.com; s=arc-20160816; b=NvfIBwbJYBbIQggOppRf8y4UUsBxsnlzqsjVeSeDQrZunVexfJ2pqw7DUqbEbLmOr1 q7BrqtpkRqAGp9MUcBYo2r+SvAC4oKFVcH1lVEXyR48gl28y/a3PQ+63JrC5W+Ozjf5A AycoRu+A2w6DZI4vOnV64Dcf/CkakXvRf7jrr8Tpnu8F7IgE8AF2EGR/XXkaD1yCopQt U75moadY/mxaOpn9SjixNcb7utoUgwiGBXkjpCsvThAKHVnS8T06OjURmMVEZAR92hPO FzL1vniruzp/kgEIRuFU0YpApN2TuaF+SfF+sEQkSnh1060e01Qhor55BmLEr+ytUCsO yAOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2TzoBat9rSOZ6f++r+CepUVmCJOu3zYkmgghF9mksEs=; b=emwzcu3uiRuI8WDlAsWleZspEZw/qSNWM2mHPYzU/EvrBaBiD/hm3GoF7GiTT5Xld/ X8ctzbkaCB4JaX6/hrVsDDhLTSSwcHTEwvxeWMZfd0fXXG+pHXmo3z6yf4Wu9el/nduD Ss0lnvsBwgwzK/B2FsLW62O8OtudEMzAu37EnQyfi/+9PE6JpGltx0uKP5eYsvnUknEM XosyeXVybRW0CDxc+gN2y6sUwl/VVHlyfIa6QhP01dCiL14fXph+80VC1ywazncu/zKx 7vXB8NAtQg1bptTO7samYNoar97CmNtPY78RRZ1XxCHD1MpopoM0wkLRxHs79mGK5lYX eQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YnlEN4f7; 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 p25si4053639edw.585.2020.09.04.08.41.43; Fri, 04 Sep 2020 08:42:06 -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=YnlEN4f7; 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 S1726340AbgIDPlE (ORCPT + 99 others); Fri, 4 Sep 2020 11:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgIDPlC (ORCPT ); Fri, 4 Sep 2020 11:41:02 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595A9C061244 for ; Fri, 4 Sep 2020 08:41:02 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id g4so7197564wrs.5 for ; Fri, 04 Sep 2020 08:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2TzoBat9rSOZ6f++r+CepUVmCJOu3zYkmgghF9mksEs=; b=YnlEN4f7iF+L8Q2CLkv0licnnoCK1sE20W+PiA6DQxq9uzUghg6CdEFLBuBsZab07N kWBC+5MR8a30w/2UZmUW0CFe9NU3v5xelGM/wUSAByE7li5cGhXYGk44PpEZLPP4ghCC LwI2/fuDs+iBM00pNEHsfT8B87WYLBzlRSgKnef+klltPoKq7QcUE49JhbE0Kc0x6dRe DLfLwu9x0k8ET5+QM7n/g0XxhdpsXtt31PonhoyMWQVABgWPqfLO+sjDxNOY3WmOYvul kKCGsCWVfLeYgoW6s9vHiHY0YOPYFSMlskcwTd8aa7j3IgT1u4s6B60J8mu2IpvwuVgD 5YXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2TzoBat9rSOZ6f++r+CepUVmCJOu3zYkmgghF9mksEs=; b=rxnW1+qNrgLir2R9YGk9BTqILLOqKLLHtBV5xenfDSzK7J3F6YUG0eKhofB9o82zvP BNs7FXulDpdYk5/kTz1QlLIiO3lR+cWo4c9jCNoFSLjaWEjUF642j/SPe9i1rxtjLJhd 0RvcQcRN3YF9ioTK19pstpU1oWAlmBS4n3CV6DCSRI4RhaETpELcBY0Fjc2C8oaEfjZm iaVXXqZqRMZzjZIc+0Ey7UsT5TkBIdQw6+sYu5ZhAiKUCxMmdbhV8XhmU78ups2kfIuh eDr8bJUwVXDDIVO2r0zSKENZ+6cqKxCANIfiy0kBi323tpUhy3DtiaO6GeKJRM6o98xR JNpw== X-Gm-Message-State: AOAM53102cXXf4aYoWtERis2YHVuQ2wjqmikH9uA2ybIq8Y+Kf2w4TCR XgKySsm5Bsuaa6DrVyXOUtF2cw== X-Received: by 2002:a5d:60c6:: with SMTP id x6mr8233226wrt.26.1599234060917; Fri, 04 Sep 2020 08:41:00 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id y5sm2733111wrh.6.2020.09.04.08.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 08:41:00 -0700 (PDT) Date: Fri, 4 Sep 2020 16:40:58 +0100 From: Daniel Thompson To: Doug Anderson Cc: Jason Wessel , Peter Zijlstra , Sumit Garg , Petr Mladek , Sergey Senozhatsky , Will Deacon , Masami Hiramatsu , kgdb-bugreport@lists.sourceforge.net, LKML , Patch Tracking Subject: Re: [PATCH v2 3/3] kgdb: Add NOKPROBE labels on the trap handler functions Message-ID: <20200904154058.qdrdkkctfs66ouw2@holly.lan> References: <20200716151943.2167652-1-daniel.thompson@linaro.org> <20200716151943.2167652-4-daniel.thompson@linaro.org> <20200720081323.5f3xojhu6v23jgqi@holly.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 21, 2020 at 02:22:08PM -0700, Doug Anderson wrote: > Hi, > > On Mon, Jul 20, 2020 at 1:13 AM Daniel Thompson > wrote: > > > > On Fri, Jul 17, 2020 at 03:39:58PM -0700, Doug Anderson wrote: > > > Hi, > > > > > > On Thu, Jul 16, 2020 at 8:20 AM Daniel Thompson > > > wrote: > > > > > > > > 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(+) > > > > > > I could just be missing something, but... > > > > > > I understand not adding "NOKPROBE_SYMBOL" to generic kernel functions > > > that kgdb happens to call, but I'm not quite sure I understand why all > > > of the kdb / kgdb code itself shouldn't be in the blocklist. I > > > certainly don't object to the functions you added to the blocklist, I > > > guess I'm must trying to understand why it's a bad idea to add more or > > > how you came up with the list of functions that you did. > > > > Relatively early in the trap handler execution (just after we bring the > > other CPUs to a halt) all breakpoints are replaced with the original > > opcodes. Therefore I only marked up functions that run between the trap > > firing and the breakpoints being removed (and also between the > > breakpoints being reinstated and trap exit). > > Ah, OK! Could that be added to the commit message? Will do. > Also, shouldn't you mark kgdb_arch_set_breakpoint()? What about > dbg_activate_sw_breakpoints()? I haven't gone and extensively > searched, but those two jump out to me as ones that were missed. Agree. I think I over-focusses on the entry path. I will review the exit path more closely. > I suppose that means that if someone tried to set a breakpoint on a > kgdb function that wasn't one of the ones that you listed then the > system would happily report that the breakpoint has been set (no error > given) but that the breakpoint would just have no effect? It wouldn't > crash (which is good), it just wouldn't detect that the breakpoint was > useless. Assuming the kgdb function is used exclusively from the trap handler then this is correct. > However, if these were in the NOKPROBE_SYMBOL then you'd get > a nice error message. Is there no way we could use a linker script to > just mark everything using a linker script or somesuch? You'd still get odd effects with library functions that are used inside and outside the debugger (which can be breakpointed but don't trigger inside kgdb). Arguably the effect is clearer to users if they can see kdb/kgdb functions behaving the same way as library functions. It's odd but it won't promote false expectations from users. Daniel.