From patchwork Sun Oct 2 01:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duoming Zhou X-Patchwork-Id: 612157 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 22835C4332F for ; Sun, 2 Oct 2022 01:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbiJBBlO (ORCPT ); Sat, 1 Oct 2022 21:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiJBBlN (ORCPT ); Sat, 1 Oct 2022 21:41:13 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 44ABC564FF; Sat, 1 Oct 2022 18:41:10 -0700 (PDT) Received: from ubuntu.localdomain (unknown [10.190.65.158]) by mail-app3 (Coremail) with SMTP id cC_KCgAXaLQg7DhjDY5WBw--.53562S2; Sun, 02 Oct 2022 09:41:00 +0800 (CST) From: Duoming Zhou To: linux-kernel@vger.kernel.org Cc: martin.petersen@oracle.com, kuba@kernel.org, davem@davemloft.net, andrii@kernel.org, gregkh@linuxfoundation.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Duoming Zhou Subject: [PATCH] scsi: target: iscsi: cxgbit: fix sleep-in-atomic-context bug in cxgbit_abort_conn Date: Sun, 2 Oct 2022 09:40:47 +0800 Message-Id: <20221002014047.23066-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgAXaLQg7DhjDY5WBw--.53562S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykKF18trW7uw43Aw1f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kernel.org The function iscsit_handle_time2retain_timeout() is a timer handler that runs in an atomic context, but it calls "alloc_skb(0, GFP_KERNEL | ...)" that may sleep. As a result, the sleep-in-atomic-context bug will happen. The process is shown below: iscsit_handle_time2retain_timeout() iscsit_close_session() iscsit_free_connection_recovery_entries() iscsit_free_cmd() __iscsit_free_cmd() cxgbit_unmap_cmd() cxgbit_abort_conn() alloc_skb(0, GFP_KERNEL | ...) //may sleep This patch changes the gfp_t parameter of alloc_skb() from GFP_KERNEL to GFP_ATOMIC in order to mitigate the bug. Fixes: 1ae01724ae92 ("cxgbit: Abort the TCP connection in case of data out timeout") Signed-off-by: Duoming Zhou --- drivers/target/iscsi/cxgbit/cxgbit_cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index 3336d2b78bf..eb3da6d2c62 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c @@ -697,7 +697,7 @@ __cxgbit_abort_conn(struct cxgbit_sock *csk, struct sk_buff *skb) void cxgbit_abort_conn(struct cxgbit_sock *csk) { - struct sk_buff *skb = alloc_skb(0, GFP_KERNEL | __GFP_NOFAIL); + struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC | __GFP_NOFAIL); cxgbit_get_csk(csk); cxgbit_init_wr_wait(&csk->com.wr_wait);