From: "Matias Bjørling" <mb@lightnvm.io>
To: baijiaju1990@gmail.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
javier@cnexlabs.com, hans.holmberg@cnexlabs.com
Subject: Re: [PATCH] lightnvm: pblk: Fix two sleep-in-atomic-context bugs in pblk_line_submit_smeta_io()
Date: Tue, 4 Sep 2018 12:11:51 +0200 [thread overview]
Message-ID: <cbff381f-c2c7-5656-b121-eb1ec3c75da4@lightnvm.io> (raw)
In-Reply-To: <20180901115318.30416-1-baijiaju1990@gmail.com>
On 09/01/2018 01:53 PM, Jia-Ju Bai wrote:
> The driver may sleep with holding a spinlock.
>
> The function call paths (from bottom to top) in Linux-4.16 are:
>
> [FUNC] nvm_dev_dma_alloc(GFP_KERNEL)
> drivers/lightnvm/pblk-core.c, 754:
> nvm_dev_dma_alloc in pblk_line_submit_smeta_io
> drivers/lightnvm/pblk-core.c, 1048:
> pblk_line_submit_smeta_io in pblk_line_init_bb
> drivers/lightnvm/pblk-core.c, 1434:
> pblk_line_init_bb in pblk_line_replace_data
> drivers/lightnvm/pblk-recovery.c, 980:
> pblk_line_replace_data in pblk_recov_l2p
> drivers/lightnvm/pblk-recovery.c, 976:
> spin_lock in pblk_recov_l2p
>
> [FUNC] bio_map_kern(GFP_KERNEL)
> drivers/lightnvm/pblk-core.c, 762:
> bio_map_kern in pblk_line_submit_smeta_io
> drivers/lightnvm/pblk-core.c, 1048:
> pblk_line_submit_smeta_io in pblk_line_init_bb
> drivers/lightnvm/pblk-core.c, 1434:
> pblk_line_init_bb in pblk_line_replace_data
> drivers/lightnvm/pblk-recovery.c, 980:
> pblk_line_replace_data in pblk_recov_l2p
> drivers/lightnvm/pblk-recovery.c, 976:
> spin_lock in pblk_recov_l2p
>
> To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.
>
> These bugs are found by my static analysis tool DSAC.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> drivers/lightnvm/pblk-core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index ed9cc977c8b3..5d915c93b6cf 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -802,7 +802,7 @@ static int pblk_line_submit_smeta_io(struct pblk *pblk, struct pblk_line *line,
>
> memset(&rqd, 0, sizeof(struct nvm_rq));
>
> - rqd.meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL,
> + rqd.meta_list = nvm_dev_dma_alloc(dev->parent, GFP_ATOMIC,
> &rqd.dma_meta_list);
> if (!rqd.meta_list)
> return -ENOMEM;
> @@ -810,7 +810,7 @@ static int pblk_line_submit_smeta_io(struct pblk *pblk, struct pblk_line *line,
> rqd.ppa_list = rqd.meta_list + pblk_dma_meta_size;
> rqd.dma_ppa_list = rqd.dma_meta_list + pblk_dma_meta_size;
>
> - bio = bio_map_kern(dev->q, line->smeta, lm->smeta_len, GFP_KERNEL);
> + bio = bio_map_kern(dev->q, line->smeta, lm->smeta_len, GFP_ATOMIC);
> if (IS_ERR(bio)) {
> ret = PTR_ERR(bio);
> goto free_ppa_list;
>
Javier,
What do you think? I'm OK with applying this, but one could also move
the allocs outside the spinlocks?
-Matias
next prev parent reply other threads:[~2018-09-04 10:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-01 11:53 Jia-Ju Bai
2018-09-04 10:11 ` Matias Bjørling [this message]
2018-09-04 17:52 ` Javier Gonzalez
2018-09-05 8:40 ` Jia-Ju Bai
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=cbff381f-c2c7-5656-b121-eb1ec3c75da4@lightnvm.io \
--to=mb@lightnvm.io \
--cc=baijiaju1990@gmail.com \
--cc=hans.holmberg@cnexlabs.com \
--cc=javier@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®