RDMA/mthca: Check for null udata during reg_user_mr
PATCH 1/1 RDMA/mthca: Check for null udata during reg_user_mr
The mthca driver was unconditionally checking udata->inlen, but udata could be null if the user intentionally triggers the UVERBS_METHOD_REG_MR ioctl. Prevent the potential null deref by adding a check.
--- drivers/infiniband/hw/mthca/mthca_provider.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/mthca/mthca_provider.c +3 -0
@@ -863,6 +863,9 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,if (dmah)return ERR_PTR (-EOPNOTSUPP ); +if (!udata) +return ERR_PTR (-EINVAL ); +if (udata->inlen <sizeof ucmd) {if (!context->reg_mr_warned) { mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
Quoted 4 lines · Jacob Moroni
The mthca driver was unconditionally checking
udata->inlen, but udata could be null if the user intentionally triggers theUVERBS_METHOD_REG_MRioctl. Prevent the potential null deref by adding a check.
???
reg_user_mr should never have a null udata how does this happen?
Jason
For irdma at least, I was able to trigger it with a one-off test binary that directly invokes the UVERBS_METHOD_REG_MR ioctl.
The handler in the kernel then calls ops.reg_user_mr with null as the last argument.
drivers/infiniband/core/uverbs_std_types_mr.c#L366
Thanks,
Jake
Quoted 7 lines · Jacob Moroni
For irdma at least, I was able to trigger it with a one-off test binary that directly invokes the
UVERBS_METHOD_REG_MRioctl.The handler in the kernel then calls ops.reg_user_mr with null as the last argument.
drivers/infiniband/core/uverbs_std_types_mr.c#L366
I think that is a bug, would need to research why it turned out like that.
"user mr" should always have an attrs.
Jason