Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp896598pxb; Fri, 22 Jan 2021 01:50:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJytgBmP8lzRqGicMPTC6WYC5JnyBMZMVjBM401cIgA3CIbIY/QI7jzpXHOcg/58mUC0lbrL X-Received: by 2002:a17:906:1bf2:: with SMTP id t18mr2548045ejg.166.1611309008568; Fri, 22 Jan 2021 01:50:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611309008; cv=none; d=google.com; s=arc-20160816; b=YvNUomjEcI8CGrpOvEpllh7iNIG8oN7tO7A9HlMVwne3gjoHHVLOd9epLOp6ejV1C3 1sRXmYaLiNWYdZu2qUclzWY3u91bEG6JBuZ5l7iNETGYvf2hOZ7gXeglAa6ad/C7+PRT 3DKbrR4nOt0kPcqVB1OCkfo+bnH1IDt3A32g3xxGPzB81RZra/H1Ptv6T2vI3H/JMmBH caJkAfNEkbzB9O9ENM5P5Npf0poui/YvAEUZS3dWRaE5KiLx2RXUh1lmiAdhVJr28UpC 4R43TMxVMRQEap7Xc/3jGwyLbAoO5y3c/6zquHRHckMrp2Pk1o590ycT+7m6GQwmbWgz EQOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=5XkfPIeaOJLsy0Tv+oZGNxT8cNyK2rUePBRvJsE8fKA=; b=IL6tDMiZuW6pHG/r/J9D9rc4jjO/STkhMuRtgo2dwul6nwwJHdwit2wTU2dLUpboN6 dGaczEOr5iKfLJkPTLXA2YKw15qUaWL+YALulVHAxNsQDWvHZGxM6wh3kg1D5Nf/8NPL UlzTTxJnNvd9BBCIw/xZIqO8BlqqZljtf+QRMtu1ap96w1HExTgIuWrxSfEqSGDrKvVS NDFGqUvLR0lwfB4hcU36kj2otZt8LPHLOCI/iV2ZxN1UkyUA2AnmDZ1CNbJzwk3RwlHD 2WoxGrwBa4muGGob4e+aOuQUdE3rCpdAjp06lmDnGRKYw7Q8DtCfuG/uwZlQye7c7f60 Gq6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hh6PmUhw; 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 x12si2793859ejf.85.2021.01.22.01.49.45; Fri, 22 Jan 2021 01:50:08 -0800 (PST) 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=hh6PmUhw; 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 S1726239AbhAVJqP (ORCPT + 99 others); Fri, 22 Jan 2021 04:46:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727336AbhAVJje (ORCPT ); Fri, 22 Jan 2021 04:39:34 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9349C06174A for ; Fri, 22 Jan 2021 01:38:53 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id c132so3353519pga.3 for ; Fri, 22 Jan 2021 01:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5XkfPIeaOJLsy0Tv+oZGNxT8cNyK2rUePBRvJsE8fKA=; b=hh6PmUhwxLRoyQ/oYOx+tc2FT99ESSRDcHrUQuCUnmt1POfYLRkHJzzroCEVrCArrH Ogk0tzqX+rO/FTJA86Lx9TT5HAM+RBM3Th9/Wk4W9cjBhTNNAkkt8oOJdUghNuNSIl7F 3GWARhehbMK/YFBoecnfuxZIZCwGm9SNDuLNxW2Uy1tP+GuN4xe5/e2xcoN4KH5qaAJQ Mgy3eknMBe5cYRzlPkw4/FvlgXWHNuT8Sf1RBkoBQ3KFHchAqLYYnYxVEDGRPC3gJ0xa 0nTukggDzea0NV8Jpiuatf9HaEzcf4hPgqPBzN5mhr8MXkM9c+53Nk0SfdjjMhgNI5mi s0YA== 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; bh=5XkfPIeaOJLsy0Tv+oZGNxT8cNyK2rUePBRvJsE8fKA=; b=M4hi2Z8tfP9uGnsL5ZaAXKaKTy4Ggz5Umafv5/KDu4cN61rzAT76DY8+vAb7XOzfMj sSopRcousKx9RiPc65SA1pQWAg8F91/GNxf9szJI+t0KoheoSyfp7adxp++lAlK3aYUG xf8ilz3cN/YNQP+uUjBgsgFWF0CoMFU1MLJZsFgyV+93T+XXe8FFjXJEmwGyY+ols/Pr t9eCQeMlbdZGAaDtuRQxSMV7vmKcWtEm2o282WZs9mtr3abH8RGBWsbN1xcmEYTu1mAI 87tQZXTCQk6UT69o7KYDew6BIIfch63HUmeY9Mkk8B9Fn2WmgOrNXJWy40qLvWSSBCOV cL7Q== X-Gm-Message-State: AOAM532xIE79e+AjDuQ+fiAxIR6xDCmWBUkQV1xaB0Zm88+biTXYCgdx FFQSd0D48XIs9thQYaxJJ+J0USa1XFAEqw== X-Received: by 2002:a62:5b07:0:b029:1ae:177d:69e1 with SMTP id p7-20020a625b070000b02901ae177d69e1mr3853738pfb.25.1611308333324; Fri, 22 Jan 2021 01:38:53 -0800 (PST) Received: from localhost.localdomain ([122.173.53.31]) by smtp.gmail.com with ESMTPSA id y26sm8543616pgk.42.2021.01.22.01.38.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jan 2021 01:38:52 -0800 (PST) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net Cc: jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH] kdb: Make memory allocations more robust Date: Fri, 22 Jan 2021 15:08:31 +0530 Message-Id: <1611308311-2530-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently kdb uses in_interrupt() to determine whether it's library code has been called from the kgdb trap handler or from a saner calling context such as driver init. This approach is broken because in_interrupt() alone isn't able to determine kgdb trap handler entry via normal task context such as [1]. We can improve this by adding check for in_dbg_master() which explicitly determines if we are running in debugger context. Also, use in_atomic() instead of in_interrupt() as the former is more appropriate to know atomic context and moreover the later one is deprecated. [1] $ echo g > /proc/sysrq-trigger Signed-off-by: Sumit Garg --- kernel/debug/kdb/kdb_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h index 7a4a181..7a9ebd9 100644 --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h @@ -231,7 +231,7 @@ extern struct task_struct *kdb_curr_task(int); #define kdb_task_has_cpu(p) (task_curr(p)) -#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) +#define GFP_KDB (in_atomic() || in_dbg_master() ? GFP_ATOMIC : GFP_KERNEL) extern void *debug_kmalloc(size_t size, gfp_t flags); extern void debug_kfree(void *); -- 2.7.4