* [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap
@ 2020-07-24 8:06 Dinghao Liu
2020-07-24 23:57 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-07-24 8:06 UTC (permalink / raw)
To: dinghao.liu, kjlu
Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
David S. Miller, Jakub Kicinski, netdev, linux-kernel
If req->ctype does not match any of NIX_AQ_CTYPE_CQ,
NIX_AQ_CTYPE_SQ or NIX_AQ_CTYPE_RQ, pointer bmap will remain
uninitialized and be accessed in test_bit(), which can lead
to kernal crash.
Fix this by returning an error code if this case is triggered.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 36953d4f51c7..20a64ed24474 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -869,19 +869,18 @@ static int nix_lf_hwctx_disable(struct rvu *rvu, struct hwctx_disable_req *req)
aq_req.cq_mask.bp_ena = 1;
q_cnt = pfvf->cq_ctx->qsize;
bmap = pfvf->cq_bmap;
- }
- if (req->ctype == NIX_AQ_CTYPE_SQ) {
+ } else if (req->ctype == NIX_AQ_CTYPE_SQ) {
aq_req.sq.ena = 0;
aq_req.sq_mask.ena = 1;
q_cnt = pfvf->sq_ctx->qsize;
bmap = pfvf->sq_bmap;
- }
- if (req->ctype == NIX_AQ_CTYPE_RQ) {
+ } else if (req->ctype == NIX_AQ_CTYPE_RQ) {
aq_req.rq.ena = 0;
aq_req.rq_mask.ena = 1;
q_cnt = pfvf->rq_ctx->qsize;
bmap = pfvf->rq_bmap;
- }
+ } else
+ return NIX_AF_ERR_AQ_ENQUEUE;
aq_req.ctype = req->ctype;
aq_req.op = NIX_AQ_INSTOP_WRITE;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap
2020-07-24 8:06 [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap Dinghao Liu
@ 2020-07-24 23:57 ` David Miller
2020-07-25 5:55 ` dinghao.liu
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-07-24 23:57 UTC (permalink / raw)
To: dinghao.liu
Cc: kjlu, sgoutham, lcherian, gakula, jerinj, kuba, netdev, linux-kernel
From: Dinghao Liu <dinghao.liu@zju.edu.cn>
Date: Fri, 24 Jul 2020 16:06:57 +0800
> If req->ctype does not match any of NIX_AQ_CTYPE_CQ,
> NIX_AQ_CTYPE_SQ or NIX_AQ_CTYPE_RQ, pointer bmap will remain
> uninitialized and be accessed in test_bit(), which can lead
> to kernal crash.
This can never happen.
> Fix this by returning an error code if this case is triggered.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
I strongly dislike changes like this.
Most callers of nix_lf_hwctx_disable() inside of rvu_nix.c set
req->ctype to one of the handled values.
The only other case, rvu_mbox_handler_nix_hwctx_disable(), is a
completely unused function and should be removed.
There is no functional problem in this code at all.
It is not possible show a code path where the stated problem can
actually occur.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Re: [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap
2020-07-24 23:57 ` David Miller
@ 2020-07-25 5:55 ` dinghao.liu
0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2020-07-25 5:55 UTC (permalink / raw)
To: David Miller
Cc: kjlu, sgoutham, lcherian, gakula, jerinj, kuba, netdev, linux-kernel
> From: Dinghao Liu <dinghao.liu@zju.edu.cn>
> Date: Fri, 24 Jul 2020 16:06:57 +0800
>
> > If req->ctype does not match any of NIX_AQ_CTYPE_CQ,
> > NIX_AQ_CTYPE_SQ or NIX_AQ_CTYPE_RQ, pointer bmap will remain
> > uninitialized and be accessed in test_bit(), which can lead
> > to kernal crash.
>
> This can never happen.
>
> > Fix this by returning an error code if this case is triggered.
> >
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
>
> I strongly dislike changes like this.
>
> Most callers of nix_lf_hwctx_disable() inside of rvu_nix.c set
> req->ctype to one of the handled values.
>
> The only other case, rvu_mbox_handler_nix_hwctx_disable(), is a
> completely unused function and should be removed.
>
> There is no functional problem in this code at all.
>
> It is not possible show a code path where the stated problem can
> actually occur.
It's clear to me now. Thanks.
Regards,
Dinghao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-25 5:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 8:06 [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap Dinghao Liu
2020-07-24 23:57 ` David Miller
2020-07-25 5:55 ` dinghao.liu
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.