From patchwork Mon Mar 1 16:04:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 388676 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3570618jap; Mon, 1 Mar 2021 10:06:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJydPmYd3Rg3XTqNPsYI++5uS/jTW6IQApUKq7pTAoGJeN3pGKXHriX/sJ8GStjIFRzS2ZGU X-Received: by 2002:a05:6402:1152:: with SMTP id g18mr17929335edw.18.1614621993811; Mon, 01 Mar 2021 10:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614621993; cv=none; d=google.com; s=arc-20160816; b=Owk0XqzcFYzDzd1+I4xXtVSDrj4iq7PNPnq+uOyq+pqvHH9ROAUSJDSyTbw6EEynuO T+Rt630nj0mdS0f/W0v75Vnw/5PLo9xCHF4Hk8Wd91K9ozzf+NsP8lxsIsSQW59W09be tzwyPMnQKX+zTqvDCWIQkBdhDe4JQ7yhPTvA8+Fzww994m2sGpiDYHHdzND+HSnuuHY2 mtFesq1ADqBt8Z/MjEe3cncDeiXE55I2QddMDPBQ3y2r6kmU2I70TEjGGPvrtZpBx/ZF l/rCNp5aqn3Rdg2jeUNbokJ/lbaSRNv7A/AXkjXWM3dH3Lh/3AY/P93F4a9AwWP1ErzF goHw== 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=mYv94wfVGxW7lgu1yHNOYAPJHc4U/nsUJLqphrMNkmY=; b=tUSkQKSN/M1r14KUAA4NLUhhTToTqTUyuKFEKB6uyK45OVyG8F3QQEf3o9basvnq9X Prz/Ka0blXrgxFiZMDqEIQHUvRzknXP166GBFT/HWLGHmoz2XR0I5L/GqUH7boma0yO/ hqWeYPLVrThefD56FpuOpmkJvHF+9/LwV2ih7P7d4E1AknJN+6ovJnn1MvSCX0IUSsgb PVIqMzPMw8dDEom2zqkf9/fwlgtVdIZEvIp8Uv9tBIIHYdkUbP4tfbmf8ZM9cJ+YDJyZ Ip2SY6SsOvyxxuw5/awBXcAeskUqyWQQqJQtBTMBCaPe5xxoV4foyysWeCm5TCncIPPt kMGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=plNAQC0w; 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 r21si11607533ejo.123.2021.03.01.10.06.33; Mon, 01 Mar 2021 10:06:33 -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=plNAQC0w; 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 S238609AbhCASFJ (ORCPT + 13 others); Mon, 1 Mar 2021 13:05:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:54168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239240AbhCAR7G (ORCPT ); Mon, 1 Mar 2021 12:59:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E77B65146; Mon, 1 Mar 2021 17:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618293; bh=EGQN54Ymvb8+0zhCacNLIY1ay2EdJOvFaCpwQ2xvMIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plNAQC0wXYruZL1zsY5ufRFPolAVA0QJ8o9a11kA1PYOf8ZTd+53ao6S9yYhEAVPF m/Bi9iLVAt45I0GiqEiv/jDVXMuC91hGQQWyv2Mq/K8Han5EHXr9vtdOCTbEdWsuy5 QXcDtg8yfSSqyiHS1CvBlcp0yCf4S1JL7UrVKXxI= 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.10 007/663] kdb: Make memory allocations more robust Date: Mon, 1 Mar 2021 17:04:15 +0100 Message-Id: <20210301161142.138913117@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@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 @@ -230,7 +230,7 @@ extern struct task_struct *kdb_curr_task #define kdb_task_has_cpu(p) (task_curr(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 *);