From: Duoming Zhou <duoming@zju.edu.cn>
To: linux-nvme@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, james.smart@broadcom.com,
kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me,
Duoming Zhou <duoming@zju.edu.cn>
Subject: [PATCH] nvme-fc: fix sleep-in-atomic-context bug caused by nvme_fc_rcv_ls_req
Date: Sun, 2 Oct 2022 08:19:09 +0800 [thread overview]
Message-ID: <20221002001909.20070-1-duoming@zju.edu.cn> (raw)
The function lpfc_poll_timeout() is a timer handler that runs in an
atomic context, but it calls "kzalloc(.., GFP_KERNEL)" that may sleep.
As a result, the sleep-in-atomic-context bug will happen. The processes
is shown below:
lpfc_poll_timeout()
lpfc_sli_handle_fast_ring_event()
lpfc_sli_process_unsol_iocb()
lpfc_complete_unsol_iocb()
lpfc_nvme_unsol_ls_handler()
lpfc_nvme_handle_lsreq()
nvme_fc_rcv_ls_req()
kzalloc(sizeof(.., GFP_KERNEL) //may sleep
This patch changes the gfp_t parameter of kzalloc() from GFP_KERNEL to
GFP_ATOMIC in order to mitigate the bug.
Fixes: 14fd1e98afaf ("nvme-fc: Add Disconnect Association Rcv support")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
drivers/nvme/host/fc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 127abaf9ba5..36698dfc8b3 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1754,7 +1754,7 @@ nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *portptr,
lsop = kzalloc(sizeof(*lsop) +
sizeof(union nvmefc_ls_requests) +
sizeof(union nvmefc_ls_responses),
- GFP_KERNEL);
+ GFP_ATOMIC);
if (!lsop) {
dev_info(lport->dev,
"RCV %s LS failed: No memory\n",
--
2.17.1
next reply other threads:[~2022-10-02 0:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 0:19 Duoming Zhou [this message]
2022-10-02 17:12 ` [PATCH] nvme-fc: fix sleep-in-atomic-context bug caused by nvme_fc_rcv_ls_req James Smart
2022-10-03 1:50 ` duoming
2022-10-03 2:56 ` James Smart
2022-10-03 17:48 ` James Smart
2022-10-04 11:10 ` duoming
2022-10-04 13:51 ` James Smart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221002001909.20070-1-duoming@zju.edu.cn \
--to=duoming@zju.edu.cn \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).