RDMA/irdma: Initialize struct members in irdma_reg_user_mr()
Subsystems (3)
PATCH 1/1 RDMA/irdma: Initialize struct members in irdma_reg_user_mr()
The ib_copy_from_udata() function does not always initialize the whole struct. It depends on the value of udata->inlen. So initialize it to zero at the start.
---
What I know is that RDMA takes fast paths very seriously.
This is probably a fast path so you may want to implement a different solution. If you want to do something else then, just feel free to do that and give me a Reported-by tag.
That business about you guys trying to explain what you want me to type and then I wait for a day and resend but I misunderstood something so I have to redo it again. You all are very dear to my heart, but what a headache! None of us need a long back an forth over trivial stuff like this. It's just easier for everyone if people write their own patches. It takes five minutes instead of three days or whatever.
drivers/infiniband/hw/irdma/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -2741,7 +2741,7 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,struct irdma_pbl *iwpbl;struct irdma_mr *iwmr;struct ib_umem *region; -struct irdma_mem_reg_req req; +struct irdma_mem_reg_req req = {};u32 total, stag =0 ;u8 shadow_pgcnt =1 ;bool use_pbles = false;
Signature · 1 line
2.35.1
Quoted 8 lines
Subject: [PATCH] RDMA/irdma: Initialize struct members in
irdma_reg_user_mr()The
ib_copy_from_udata()function does not always initialize the whole struct. It depends on the value ofudata->inlen. So initialize it to zero at the start.Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")Signed-off-by Dan Carpenter <[email protected]>---
Quoted 11 lines · Dan Carpenter
The
ib_copy_from_udata()function does not always initialize the whole struct. It depends on the value ofudata->inlen. So initialize it to zero at the start.Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")Signed-off-by Dan Carpenter <[email protected]>What I know is that RDMA takes fast paths very seriously.
This is probably a fast path so you may want to implement a different solution. If you want to do something else then, just feel free to do that and give me a Reported-by tag.
This isn't fast path..
But the bug here is not validating inlen properly and should be fixed there, not by zero-initing and allowing userspace to pass in an invalid inlen..
Jason
Quoted 13 lines
Subject: Re: [PATCH] RDMA/irdma: Initialize struct members in
irdma_reg_user_mr()Quoted 9 lines · Dan Carpenter
The
ib_copy_from_udata()function does not always initialize the whole struct. It depends on the value ofudata->inlen. So initialize it to zero at the start.Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verbAPIs")
Signed-off-by Dan Carpenter <[email protected]> What I know isthat RDMA takes fast paths very seriously.
Quoted 9 lines
Quoted 3 lines
This is probably a fast path so you may want to implement a different solution. If you want to do something else then, just feel free to do that and give me a Reported-by tag.
This isn't fast path..
But the bug here is not validating inlen properly and should be fixed there, not by zero-initing and allowing userspace to pass in an invalid inlen..
Hi Jason -
So something like this is appropriate?
drivers/infiniband/hw/irdma/verbs.c +3 -0
@@ -2735,6 +2735,9 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)return ERR_PTR (-EINVAL ); +if (udata->inlen <sizeof (req)) +return ERR_PTR (-EINVAL ); + region =ib_umem_get (pd->device, start, len, access);if (IS_ERR (region)) {
Quoted 17 lines · Shiraz
Quoted 17 lines
Subject: Re: [PATCH] RDMA/irdma: Initialize struct members in
irdma_reg_user_mr()Quoted 12 lines · Dan Carpenter
The
ib_copy_from_udata()function does not always initialize the whole struct. It depends on the value ofudata->inlen. So initialize it to zero at the start.Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verbAPIs")
Signed-off-by Dan Carpenter <[email protected]> What I know isthat RDMA takes fast paths very seriously.
This is probably a fast path so you may want to implement a different solution. If you want to do something else then, just feel free to do that and give me a Reported-by tag.
Quoted 8 lines
Quoted 5 lines
This isn't fast path..
But the bug here is not validating inlen properly and should be fixed there, not by zero-initing and allowing userspace to pass in an invalid inlen..
Hi Jason -
So something like this is appropriate?
Yes
Jason
Quoted 25 lines
Subject: Re: [PATCH] RDMA/irdma: Initialize struct members in
irdma_reg_user_mr()Quoted 13 lines · Shiraz
Quoted 13 lines
Subject: Re: [PATCH] RDMA/irdma: Initialize struct members in
irdma_reg_user_mr()Quoted 9 lines · Dan Carpenter
The
ib_copy_from_udata()function does not always initialize the whole struct. It depends on the value ofudata->inlen. So initialize it to zero at the start.Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verbAPIs")
Signed-off-by Dan Carpenter <[email protected]> What Iknow is that RDMA takes fast paths very seriously.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
This is probably a fast path so you may want to implement a different solution. If you want to do something else then, just feel free to do that and give me a Reported-by tag.
This isn't fast path..
But the bug here is not validating inlen properly and should be fixed there, not by zero-initing and allowing userspace to pass in an invalid
Quoted 8 lines
inlen..
Quoted 4 lines
Quoted 1 line
Hi Jason -
So something like this is appropriate?
Yes
Ok. Thanks. It seems we have other places in irdma which should be fixed this way too. I will send a fix.
Shiraz