From patchwork Mon Mar 1 16:09:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388670 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3542970jap; Mon, 1 Mar 2021 09:29:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPZShTTKlQxlnIQLterBwM9OgBVv8SpJIjJpPp1ZjMCaD78X3TsZIDhSeAPD9ybjn/AhmH X-Received: by 2002:aa7:da0f:: with SMTP id r15mr5102270eds.111.1614619783268; Mon, 01 Mar 2021 09:29:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614619783; cv=none; d=google.com; s=arc-20160816; b=q/R1chWeNxqquydxi5GG8OqNtTxOZMta7dxZ2C5NkUpqPbrcbNpCdK/oWG8cmTMVno 18TshDMKeSn26o9Zg5teOcR+rm2BskIJsGslfE9ddxCFSVPYFr1g1ewTmXUyNe5TFul2 /FOPtMij7/1HsDIIPdOzRpKOBmDlmZax7zerrfnucTfuUMVo8BNLkOuUefp44CbKHloa UBK93rQRro2u09Z5FG2htgOtZh/r5oSEU1o3pY73mB5VL2R9da1WqBwKm4anAr0iAmEB LD+Fg7OyBOLJBKBBmoP3rp8NxCYeAJi5S5k6IEjAeljkzg258QoHcK4nA+6tk9SxODyF G7HQ== 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=tD44eaORRbuHCp6UxE+FrIZIDbIIxLadokudNBP3NPMdnxlPywk9Byf6iM3npZ1qWP tIORqYKOiaNKZpPmtOHj3QE0GiOmyU8gkHjm/zFmn4K4usDEmQOqGObrVmtqhZiaWrSN xud9t8vOcMoIYTWwL2cGGwGi2Y0mcO/hyYgxjLrVVWaFA860Lo5+0WORg79BgI4b9U3H 4FyDA5J8lUqGxBL3Ba6MVLkBcf0qPHjIkv6kD/BUDefV5roTJ3oKRNP3myXn3uZarviD TECYGXVQJcSkdF2C9dNls9TiH2enzAf95VDZKsOuyHFfZ3CZpezaYkYgAjFxJn6PIkG/ +ZYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TCvhmMvB; 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 u2si3206538ejg.288.2021.03.01.09.29.42; Mon, 01 Mar 2021 09:29:43 -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=TCvhmMvB; 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 S238493AbhCAR21 (ORCPT + 13 others); Mon, 1 Mar 2021 12:28:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:36726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238113AbhCARXE (ORCPT ); Mon, 1 Mar 2021 12:23:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D3C9965071; Mon, 1 Mar 2021 16:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617320; bh=VzcM2zK0CXIH9uHqMj0F35NuxWY5WDsoXlYHg6auVLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TCvhmMvB4zDAb4GXK3CYVETktTHsA/MK7df3vzHkC9fUjyjs824vBBe4pDUMBBT8a neWIAfG3zpzFzCivw8aOSPFH8K3gPKL5pci65PjYX+BOriILld7/aylWyaGjZzwwP4 81+uGPhn1Y7fYIaQG+wwaXLe+MPkvSW77LIxWTF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Daniel Thompson Subject: [PATCH 5.4 005/340] kdb: Make memory allocations more robust Date: Mon, 1 Mar 2021 17:09:09 +0100 Message-Id: <20210301161048.566334508@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161048.294656001@linuxfoundation.org> References: <20210301161048.294656001@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 *);