From patchwork Mon Mar 1 16:12:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388646 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3487007jap; Mon, 1 Mar 2021 08:22:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvELZmhlEdYYlxO8B3DKW8QMflgdr3KyhM1ZWDqVCfK45AXn+TjLoSq18ebOGl6PsM5nPN X-Received: by 2002:a05:6402:1b1a:: with SMTP id by26mr17399758edb.3.1614615744035; Mon, 01 Mar 2021 08:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614615744; cv=none; d=google.com; s=arc-20160816; b=ZWxRjm8r5k7ZolMxFJh+6X8lrlICPQAmm86RHQFkGWN8d7pI9IKZdOADHFgiYzUSKR ds9hLPXJ7QHKVdvQ7XMEdwrdyivCeIRkcvos1wrRe+9dL9/A5EjPOjbnQOJJevoLSTzr SA/9zzPUlx6GZT93948yyPM/gR/1aTJeHm07mMoeM3RqyuDIg1IUtEooHbOKLeg6qRAz /L7mn3iurkKr1Gs+lqbFKhiCz6DyL/FigcufHptFYkrqbkiMzyIoyQa4uuoXVIknUXip eT+Lt1ZBJKFcZyH354P3q2Cbzn0he5JQa0C1m/nccEhYQaBcKygDcjclBNEu+4gjC9tj TvTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=305gEp1g9nAFPu3aVeuZSMWjeC/iVInZ1vgmhYfShYI=; b=Mx49xCRbkVQ5cHMm1nS8CK96tj+j4d0n9JuvccQ61ZfgYsraJm1U1k+pAOr1PPmXKE nj4XPE8AnynKPT4bepgHn7dLw+KkCQME/xAUZM3uZ4zwqqoFW3/wvKfj1ecSYRI+tha5 OuGNRBsMfOn+zqz03EwqS36aTywyJPyv3hh98KQcmqAXxYfCUvD3Ri0as+1CTUcS+N7r fxxVeGB7fnGbnKZ428M8LKXb5mHru2xuKpQgsIZT6varvFcPY/f2zLM5K94DkE8YDKpV mXtpVnULiFhiB41oL5zfrx5bUPP0wtz6iT8Alzn4KG7vQaOo+ZtDgCPndcVSjhEg4T+L uv/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ah3h5si8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si11300797ejd.80.2021.03.01.08.22.23; Mon, 01 Mar 2021 08:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=Ah3h5si8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234060AbhCAQU5 (ORCPT + 13 others); Mon, 1 Mar 2021 11:20:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:56662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237762AbhCAQTF (ORCPT ); Mon, 1 Mar 2021 11:19:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23A7864E89; Mon, 1 Mar 2021 16:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614615427; bh=iPXy742P8sRdpLi3cQoN84MtFgXqylTY+KqIjcXKuNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ah3h5si88KIQSnR3kIUL3lxDHZllmv1z2haQxmS1vLu5EPDM6XkZFLhlcDk7Flkve n8wnlIR4ypMQ6hZGGahn2LFhYhcOkfMHA9WMeNJx55ftQrUTv115CCjnO6reAG+Bwq OcTNPu+6VqcU8hfQy5X6M64vveBIV8nWMwcusLfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Daniel Thompson Subject: [PATCH 4.4 07/93] kdb: Make memory allocations more robust Date: Mon, 1 Mar 2021 17:12:19 +0100 Message-Id: <20210301161007.257063465@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161006.881950696@linuxfoundation.org> References: <20210301161006.881950696@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sumit Garg commit 93f7a6d818deef69d0ba652d46bae6fbabbf365c upstream. Currently kdb uses in_interrupt() to determine whether its 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 from normal task context. This can happen during normal use of basic features such as breakpoints and can also be trivially reproduced using: echo g > /proc/sysrq-trigger We can improve this by adding check for in_dbg_master() instead which explicitly determines if we are running in debugger context. Cc: stable@vger.kernel.org Signed-off-by: Sumit Garg Link: https://lore.kernel.org/r/1611313556-4004-1-git-send-email-sumit.garg@linaro.org Signed-off-by: Daniel Thompson Signed-off-by: Greg Kroah-Hartman --- kernel/debug/kdb/kdb_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h @@ -234,7 +234,7 @@ extern struct task_struct *kdb_curr_task #define kdb_do_each_thread(g, p) do_each_thread(g, p) #define kdb_while_each_thread(g, p) while_each_thread(g, p) -#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) +#define GFP_KDB (in_dbg_master() ? GFP_ATOMIC : GFP_KERNEL) extern void *debug_kmalloc(size_t size, gfp_t flags); extern void debug_kfree(void *);