From patchwork Mon Mar 1 16:10:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388660 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3520601jap; Mon, 1 Mar 2021 09:03:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhm+JPayU4KNjl7VomvmTDXxOCgZtTQVHWBgkisnkolRKycCYvLu0daLG3/9xgxRGnan6j X-Received: by 2002:a17:907:e8c:: with SMTP id ho12mr16660221ejc.435.1614618219662; Mon, 01 Mar 2021 09:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614618219; cv=none; d=google.com; s=arc-20160816; b=HBBLS/IMeJ6QAhrDZGWv54g+YsHfRLDrUHjVJampedNRV8sXBzbApHyDCmG18MR+gB 6+ro2WnHLPG3hFv5A46sFOPokpDIjvWXGCBzMLOu3K0v55VzNZs23geZEmoEe+2Nq8V0 4JMIe+hbgOrap5IPQlCoEZWs9IODh/A0H3RtzcU/gHpQ1XwSeqWdSY7soAfoIJMf3jiF x1kMpUOYKo73LknygCM2v5nuNhVyHDJ2xjnaBSlfJVscUYp1zL1HaU82xsENlVOfWLo8 BPp4oeqxQXuMwDpM055jKcaTFEVw0xmM6aIDlI6aFB+Vr1biUC/xjCeFjatrTYXDv3wM 8KAw== 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=tsH8dFasutqrDIod1iShRvoRpqwpDkaF8POp9SYXNMM=; b=HXzpcwvHc/K6k8QZY7kd/0cgOQC17/4Yo4SNJoIfNsWUII/E86Ox2ojMIHlBrPn7v/ 6p7s2B7oWZYRwxyipEXHSC2FXRX7QWFkmTpv0y+9OWYtj3rg4uSwWuuPDR+YvdUBa153 u39bhj9EkDwPt5PvDc0Eg98A9yl1USfbFFYuC3LaiGQfEA88ig+AWGmVAMtBWRPaX0Fb 9l7Hol8u+GNXfnIQ2TZiF6jbhbc1uJ0vBRVJJZepK9QswH+0MiGtdh3hal4Ims5zLAZa /AvrX2Sz1jk5NBtxWgESd/9dpZP4BFMjJ2vYYnF7svQ2FVM+4J5FxLnA1ZxknzPcaGSC QvZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tUMl+65a; 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 la25si4897662ejb.703.2021.03.01.09.03.38; Mon, 01 Mar 2021 09:03:39 -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=tUMl+65a; 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 S236011AbhCARC1 (ORCPT + 13 others); Mon, 1 Mar 2021 12:02:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:55018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235973AbhCAQzq (ORCPT ); Mon, 1 Mar 2021 11:55:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8351364FDD; Mon, 1 Mar 2021 16:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616562; bh=VzcM2zK0CXIH9uHqMj0F35NuxWY5WDsoXlYHg6auVLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUMl+65a45gWQSyPUv7dcn/XqgRu55HU/6vVGWlWMcxkliaT0xCA0U5uq27G/Fxlx 9W/b74IIhgXdsRVcIqXMHfvSZu8RY/9K8fbsiw0E05H2Wta/Z8JGjlwfkJ7uIVxOzi rnlBJ+6uS89oIC2EdYq1deJhngfKbVnvGY7hbs00= 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.19 018/247] kdb: Make memory allocations more robust Date: Mon, 1 Mar 2021 17:10:38 +0100 Message-Id: <20210301161032.586430700@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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 @@ -233,7 +233,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 *);