From patchwork Mon Mar 1 16:02:56 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: 388686 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3582525jap; Mon, 1 Mar 2021 10:21:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN2YJ4Ty3kVr5KVYBoMgzdkKUhBuvRGJ2XP+UbYMFZtfzR4Yf8/9rhW7QLEbcGNlAJwg0g X-Received: by 2002:a17:906:f10c:: with SMTP id gv12mr2428244ejb.53.1614622871080; Mon, 01 Mar 2021 10:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614622871; cv=none; d=google.com; s=arc-20160816; b=zOHict8zkrA8bmxZPtnZe0RwNnTTdqXQQNkQEfMSrZa+orMzvJxXrwbOKp+7BNWCj/ y7RJWoNZon7kQw4czNK6oYlK3DpSSocFHi5kLKi1LyK7yM2DWF1wpHnrw2y2tUvio4TY 5CtZ3YDhBJt1drUClL9ccnDHhQ290rWfftj0iZH4n9yd2lvSehhQiof28FQRfY1P/eBo YIUTrc89ogibtQuoT3PdIbs6WE1IZLLMF9VGw1noD9btsrqDqKkKa31xDCz8ZXLufs6V rnD1AsyJFL7KwjSraVfprmqlwl7BEMKnlbKzamhuBHiSN47Ailf/KVbbUdBymKP/ZV+k DqZw== 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=rlSWk99kaKu/xN8SGigy7y0sR59RiGji6TOV6VHvYrdIkw2wcLg1rov40lIAnAXBeT 1DeVB2Ql0nO92evlCeDC3MApEMw6NjJiyT0Knxk2JucIzZ2gM/tQadB/8nt1oGZvGJjQ opLWDrGGdbRer7QXkUuKMS0iB7buK+7XXNAtvqYC8vFTYXu1mdGk12OC40ooRHu7BhQI RBhW1i/7PePUZih+uLdgU2a4aULPaHuHokxpy/ueC7yaymJuo4TQqVlNmTVYqgMzMUrX Wc4n081kNogz4W63xnZPveTqSDKtc6wISheiPjO6FcLYbzdauNQ85Qb6QzrDzKdN88TI ZxbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=STh0GVFa; 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 ss17si5378329ejb.678.2021.03.01.10.21.10; Mon, 01 Mar 2021 10:21:11 -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=STh0GVFa; 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 S239712AbhCASUQ (ORCPT + 13 others); Mon, 1 Mar 2021 13:20:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:34280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239309AbhCASOK (ORCPT ); Mon, 1 Mar 2021 13:14:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B06FF64E38; Mon, 1 Mar 2021 17:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614620123; bh=EGQN54Ymvb8+0zhCacNLIY1ay2EdJOvFaCpwQ2xvMIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=STh0GVFaP6Y6l9s6/Y2JS3113PaLeQ4ecmmVA5+U53QZa9y7DgUV0UhXWLyvm+c42 kOKzsp5Uufacuv/0OGClQOD1vlaMycHhByJTJVWrmxqm7w0hyQmM4701BbaBP4CTBS VtxWnEYlbSdtcN8kFSrWqZaUotthKZfFHqELMrh8= 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.11 008/775] kdb: Make memory allocations more robust Date: Mon, 1 Mar 2021 17:02:56 +0100 Message-Id: <20210301161202.118996226@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161201.679371205@linuxfoundation.org> References: <20210301161201.679371205@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 *);