All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c
@ 2020-11-30  7:23 tangzhenhao
  2020-12-08 16:43 ` Matias Bjørling
  2020-12-08 17:03 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: tangzhenhao @ 2020-11-30  7:23 UTC (permalink / raw)
  To: linux-block; +Cc: mb, tangzhenhao

At line 294 in drivers/lightnvm/pblk-write.c, function pblk_gen_run_ws is called with actual param GFP_ATOMIC. pblk_gen_run_ws call mempool_alloc using "GFP_ATOMIC" flag, so mempool_alloc can return null. So we need to check the return-val of mempool_alloc to avoid null-ptr-deref bug.

Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
---
 drivers/lightnvm/pblk-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 97c68731406b..1dddba11e721 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1869,6 +1869,10 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
 	struct pblk_line_ws *line_ws;
 
 	line_ws = mempool_alloc(&pblk->gen_ws_pool, gfp_mask);
+	if (!line_ws) {
+		pblk_err(pblk, "pblk: could not allocate memory\n");
+		return;
+	}
 
 	line_ws->pblk = pblk;
 	line_ws->line = line;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c
  2020-11-30  7:23 [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c tangzhenhao
@ 2020-12-08 16:43 ` Matias Bjørling
  2020-12-08 17:03 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Matias Bjørling @ 2020-12-08 16:43 UTC (permalink / raw)
  To: tangzhenhao, linux-block, Jens Axboe

On 30/11/2020 08.23, tangzhenhao wrote:
> At line 294 in drivers/lightnvm/pblk-write.c, function pblk_gen_run_ws is called with actual param GFP_ATOMIC. pblk_gen_run_ws call mempool_alloc using "GFP_ATOMIC" flag, so mempool_alloc can return null. So we need to check the return-val of mempool_alloc to avoid null-ptr-deref bug.
>
> Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
> ---
>   drivers/lightnvm/pblk-core.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index 97c68731406b..1dddba11e721 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -1869,6 +1869,10 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
>   	struct pblk_line_ws *line_ws;
>   
>   	line_ws = mempool_alloc(&pblk->gen_ws_pool, gfp_mask);
> +	if (!line_ws) {
> +		pblk_err(pblk, "pblk: could not allocate memory\n");
> +		return;
> +	}
>   
>   	line_ws->pblk = pblk;
>   	line_ws->line = line;

Thank you, Hao. Good catch.

Reviewed-by: Matias Bjørling <mb@lightnvm.io>

Hi Jens, would you be so kind to pick this up when convenient?

Thanks!

Best, Matias


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c
  2020-11-30  7:23 [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c tangzhenhao
  2020-12-08 16:43 ` Matias Bjørling
@ 2020-12-08 17:03 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-12-08 17:03 UTC (permalink / raw)
  To: tangzhenhao, linux-block; +Cc: mb

On 11/30/20 12:23 AM, tangzhenhao wrote:
> At line 294 in drivers/lightnvm/pblk-write.c, function pblk_gen_run_ws
> is called with actual param GFP_ATOMIC. pblk_gen_run_ws call
> mempool_alloc using "GFP_ATOMIC" flag, so mempool_alloc can return
> null. So we need to check the return-val of mempool_alloc to avoid
> null-ptr-deref bug.

Please line-break at 72/74 chars for future patches, I fixed this one
up. Applied for 5.11, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-08 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30  7:23 [PATCH] drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c tangzhenhao
2020-12-08 16:43 ` Matias Bjørling
2020-12-08 17:03 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.