From patchwork Sat Jul 23 03:56:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duoming Zhou X-Patchwork-Id: 12927085 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB366C43334 for ; Sat, 23 Jul 2022 03:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234609AbiGWD5Q (ORCPT ); Fri, 22 Jul 2022 23:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiGWD5P (ORCPT ); Fri, 22 Jul 2022 23:57:15 -0400 Received: from zg8tmtyylji0my4xnjqunzqa.icoremail.net (zg8tmtyylji0my4xnjqunzqa.icoremail.net [162.243.164.74]) by lindbergh.monkeyblade.net (Postfix) with SMTP id B43AC74DDA; Fri, 22 Jul 2022 20:57:12 -0700 (PDT) Received: from ubuntu.localdomain (unknown [106.117.76.127]) by mail-app3 (Coremail) with SMTP id cC_KCgCHbah+cdtiivhQAQ--.2627S2; Sat, 23 Jul 2022 11:56:57 +0800 (CST) From: Duoming Zhou To: linux-hams@vger.kernel.org Cc: ralf@linux-mips.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Duoming Zhou Subject: [PATCH net] netrom: fix sleep in atomic context bugs in timer handlers Date: Sat, 23 Jul 2022 11:56:46 +0800 Message-Id: <20220723035646.29857-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgCHbah+cdtiivhQAQ--.2627S2 X-Coremail-Antispam: 1UD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gACsf Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are sleep in atomic context bugs in timer handlers of netrom such as nr_t1timer_expiry(), nr_t2timer_expiry(), nr_heartbeat_expiry(), nr_idletimer_expiry() and so on. The root cause is kmemdup() with GFP_KERNEL parameter that may sleep could be called by different timer handlers which is in interrupt context. One of the call paths that could trigger bug is shown below: (interrupt context) nr_heartbeat_expiry nr_write_internal nr_transmit_buffer nr_route_frame nr_add_node kmemdup(..,GFP_KERNEL) //may sleep This patch changes gfp_t parameter of kmemdup in nr_add_node() from GFP_KERNEL to GFP_ATOMIC in order to prevent sleep in atomic context bugs. Fixes: eafff86d3bd8 ("[NETROM]: Use kmemdup") Signed-off-by: Duoming Zhou --- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index baea3cbd76c..1ddcf13de6a 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -163,7 +163,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic, if (ax25_digi != NULL && ax25_digi->ndigi > 0) { nr_neigh->digipeat = kmemdup(ax25_digi, sizeof(*ax25_digi), - GFP_KERNEL); + GFP_ATOMIC); if (nr_neigh->digipeat == NULL) { kfree(nr_neigh); if (nr_node)